GithubHelp home page GithubHelp logo

Comments (2)

vogelsgesang avatar vogelsgesang commented on June 10, 2024

Hi @l1t1,

The performance difference between Hyper and DuckDB has nothing to do with whether the CTE gets materialized or not. In fact, Hyper's optmizer already decides that in this case the CTE should be materialized.

The performance difference is rather due to DuckDB implementing specialized join algorithms for inequality joins, while Hyper falls back to a blockwise-nested-loop join here. We already have inequality joins on the radar, but currently don't have a compelling use case on why we should invest into improving performance for inequality joins

from hyper-api-samples.

l1t1 avatar l1t1 commented on June 10, 2024

the execute plan of duckdb

┌─────────────────────────────┐
│┌───────────────────────────┐│
│└───────────────────────────┘│
└─────────────────────────────┘
┌─────────────────────────────────────┐
│┌───────────────────────────────────┐│
││    Query Profiling Information    ││
│└───────────────────────────────────┘│
└─────────────────────────────────────┘
explain analyze WITH t AS  MATERIALIZED ( SELECT i, i*i*i*i*i AS i5 FROM range(1,150)t(i) ) SELECT a.i, b.i, c.i, d.i, e.i FROM t a, t b, t c, t d, t e WHERE a.i < b.i AND b.i < c.i AND c.i < d.i AND d.i < e.i AND a.i5 + b.i5 + c.i5 + d.i5 = e.i5;
┌─────────────────────────────────────┐
│┌───────────────────────────────────┐│
││         Total Time: 1.07s         ││
│└───────────────────────────────────┘│
└─────────────────────────────────────┘
┌───────────────────────────┐
│      EXPLAIN_ANALYZE      │
│   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   │
│             0             │
│          (0.00s)          │
└─────────────┬─────────────┘
┌─────────────┴─────────────┐
│            CTE            │
│   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   │
│             t             │
│   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   │
│           idx: 0          ├──────────────┐
│   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   │              │
│             1             │              │
│          (1.07s)          │              │
└─────────────┬─────────────┘              │
┌─────────────┴─────────────┐┌─────────────┴─────────────┐
│         PROJECTION        ││         PROJECTION        │
│   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   ││   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   │
│             i             ││             i             │
│             i5            ││             i             │
│   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   ││             i             │
│            149            ││             i             │
│          (0.00s)          ││             i             │
│                           ││   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   │
│                           ││             1             │
│                           ││          (0.00s)          │
└─────────────┬─────────────┘└─────────────┬─────────────┘
┌─────────────┴─────────────┐┌─────────────┴─────────────┐
│           RANGE           ││         HASH_JOIN         │
│   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   ││   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   │
│          EC: 149          ││           INNER           │
│   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   ││ (((i5 + i5) + i5) + i5) = │
│            149            ││             i5            │
│          (0.00s)          ││           i < i           ├─────────────────────────────────────────────────────────────────────────────────────────────────────┐
│                           ││   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   │                                                                                                     │
│                           ││           EC: 0           │                                                                                                     │
│                           ││   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   │                                                                                                     │
│                           ││             1             │                                                                                                     │
│                           ││          (0.75s)          │                                                                                                     │
└───────────────────────────┘└─────────────┬─────────────┘                                                                                                     │
                             ┌─────────────┴─────────────┐                                                                                       ┌─────────────┴─────────────┐
                             │      NESTED_LOOP_JOIN     │                                                                                       │          CTE_SCAN         │
                             │   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   │                                                                                       │   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   │
                             │           INNER           │                                                                                       │           idx: 0          │
                             │           i < i           │                                                                                       │   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   │
                             │   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   ├────────────────────────────────────────────────────────────────────────┐              │            149            │
                             │           EC: 0           │                                                                        │              │          (0.00s)          │
                             │   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   │                                                                        │              │                           │
                             │          19720001         │                                                                        │              │                           │
                             │          (0.32s)          │                                                                        │              │                           │
                             └─────────────┬─────────────┘                                                                        │              └───────────────────────────┘
                             ┌─────────────┴─────────────┐                                                          ┌─────────────┴─────────────┐
                             │      NESTED_LOOP_JOIN     │                                                          │          CTE_SCAN         │
                             │   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   │                                                          │   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   │
                             │           INNER           │                                                          │           idx: 0          │
                             │           i < i           │                                                          │   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   │
                             │   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   ├───────────────────────────────────────────┐              │            149            │
                             │           EC: 0           │                                           │              │          (0.00s)          │
                             │   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   │                                           │              │                           │
                             │           540274          │                                           │              │                           │
                             │          (0.00s)          │                                           │              │                           │
                             └─────────────┬─────────────┘                                           │              └───────────────────────────┘
                             ┌─────────────┴─────────────┐                             ┌─────────────┴─────────────┐
                             │      NESTED_LOOP_JOIN     │                             │          CTE_SCAN         │
                             │   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   │                             │   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   │
                             │           INNER           │                             │           idx: 0          │
                             │           i < i           │                             │   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   │
                             │   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   ├──────────────┐              │            149            │
                             │           EC: 0           │              │              │          (0.00s)          │
                             │   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   │              │              │                           │
                             │           11026           │              │              │                           │
                             │          (0.00s)          │              │              │                           │
                             └─────────────┬─────────────┘              │              └───────────────────────────┘
                             ┌─────────────┴─────────────┐┌─────────────┴─────────────┐
                             │          CTE_SCAN         ││          CTE_SCAN         │
                             │   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   ││   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   │
                             │           idx: 0          ││           idx: 0          │
                             │   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   ││   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   │
                             │            149            ││            149            │
                             │          (0.00s)          ││          (0.00s)          │
                             └───────────────────────────┘└───────────────────────────┘


┌─────────────────────────────┐
│┌───────────────────────────┐│
│└───────────────────────────┘│
└─────────────────────────────┘
┌─────────────────────────────────────┐
│┌───────────────────────────────────┐│
││    Query Profiling Information    ││
│└───────────────────────────────────┘│
└─────────────────────────────────────┘
explain analyze WITH t AS ( SELECT i, i*i*i*i*i AS i5 FROM range(1,150)t(i) ) SELECT a.i, b.i, c.i, d.i, e.i FROM t a, t b, t c, t d, t e WHERE a.i < b.i AND b.i < c.i AND c.i < d.i AND d.i < e.i AND a.i5 + b.i5 + c.i5 + d.i5 = e.i5;
┌─────────────────────────────────────┐
│┌───────────────────────────────────┐│
││         Total Time: 24.25s        ││
│└───────────────────────────────────┘│
└─────────────────────────────────────┘
┌───────────────────────────┐
│      EXPLAIN_ANALYZE      │
│   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   │
│             0             │
│          (0.00s)          │
└─────────────┬─────────────┘
┌─────────────┴─────────────┐
│         PROJECTION        │
│   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   │
│             i             │
│             i             │
│             i             │
│             i             │
│             i             │
│   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   │
│             1             │
│          (0.00s)          │
└─────────────┬─────────────┘
┌─────────────┴─────────────┐
│           FILTER          │
│   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   │
│ ((((i5 + i5) + i5) + i5) =│
│             i5)           │
│   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   │
│          EC: 149          │
│   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   │
│             1             │
│          (10.00s)         │
└─────────────┬─────────────┘
┌─────────────┴─────────────┐
│    PIECEWISE_MERGE_JOIN   │
│   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   │
│           INNER           │
│           i < i           │
│   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   ├──────────────┐
│          EC: 149          │              │
│   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   │              │
│         571880029         │              │
│          (11.05s)         │              │
└─────────────┬─────────────┘              │
┌─────────────┴─────────────┐┌─────────────┴─────────────┐
│         PROJECTION        ││    PIECEWISE_MERGE_JOIN   │
│   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   ││   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   │
│             i             ││           INNER           │
│             i5            ││           i < i           │
│   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   ││   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   ├──────────────┐
│            149            ││          EC: 149          │              │
│          (0.00s)          ││   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   │              │
│                           ││          19720001         │              │
│                           ││          (0.27s)          │              │
└─────────────┬─────────────┘└─────────────┬─────────────┘              │
┌─────────────┴─────────────┐┌─────────────┴─────────────┐┌─────────────┴─────────────┐
│           RANGE           ││         PROJECTION        ││    PIECEWISE_MERGE_JOIN   │
│   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   ││   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   ││   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   │
│          EC: 149          ││             i             ││           INNER           │
│   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   ││             i5            ││           i < i           │
│            149            ││   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   ││   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   ├──────────────┐
│          (0.00s)          ││            149            ││          EC: 149          │              │
│                           ││          (0.00s)          ││   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   │              │
│                           ││                           ││           540274          │              │
│                           ││                           ││          (0.01s)          │              │
└───────────────────────────┘└─────────────┬─────────────┘└─────────────┬─────────────┘              │
                             ┌─────────────┴─────────────┐┌─────────────┴─────────────┐┌─────────────┴─────────────┐
                             │           RANGE           ││         PROJECTION        ││    PIECEWISE_MERGE_JOIN   │
                             │   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   ││   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   ││   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   │
                             │          EC: 149          ││             i             ││           INNER           │
                             │   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   ││             i5            ││           i < i           │
                             │            149            ││   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   ││   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   ├──────────────┐
                             │          (0.00s)          ││            149            ││          EC: 149          │              │
                             │                           ││          (0.00s)          ││   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   │              │
                             │                           ││                           ││           11026           │              │
                             │                           ││                           ││          (0.00s)          │              │
                             └───────────────────────────┘└─────────────┬─────────────┘└─────────────┬─────────────┘              │
                                                          ┌─────────────┴─────────────┐┌─────────────┴─────────────┐┌─────────────┴─────────────┐
                                                          │           RANGE           ││         PROJECTION        ││         PROJECTION        │
                                                          │   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   ││   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   ││   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   │
                                                          │          EC: 149          ││             i             ││             i             │
                                                          │   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   ││             i5            ││             i5            │
                                                          │            149            ││   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   ││   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   │
                                                          │          (0.00s)          ││            149            ││            149            │
                                                          │                           ││          (0.00s)          ││          (0.00s)          │
                                                          └───────────────────────────┘└─────────────┬─────────────┘└─────────────┬─────────────┘
                                                                                       ┌─────────────┴─────────────┐┌─────────────┴─────────────┐
                                                                                       │           RANGE           ││           RANGE           │
                                                                                       │   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   ││   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   │
                                                                                       │          EC: 149          ││          EC: 149          │
                                                                                       │   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   ││   ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─   │
                                                                                       │            149            ││            149            │
                                                                                       │          (0.00s)          ││          (0.00s)          │
                                                                                       └───────────────────────────┘└───────────────────────────┘

from hyper-api-samples.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.