Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Join Order + EXPLAIN Improvements #5891

Merged
merged 5 commits into from
Jan 16, 2023

Conversation

lnkuiper
Copy link
Contributor

This PR started off as improvements to the EXPLAIN ANALYZE output.

We found that expected cardinalities were not being reported properly if we have a FILTER on top of a SEQ_SCAN with filters pushed into it. This is rare since the expressions in the FILTER can usually be pushed into the SEQ_SCAN. However, sometimes a few filters are pushed into the scan, but others are not, causing us to report cardinality estimates for neither the FILTER nor the SEQ_SCAN.

When investigating this, I found that when this occurred, we also only applied the filters that were pushed into the SEQ_SCAN in our cardinality estimates, and we did not consider the FILTER on top of it. I've addressed this, and we now apply all filters properly, and we report the estimated cardinalities properly as well (for both the FILTER and the SEQ_SCAN nodes.

While I was doing this, I also found that we do not re-order joins in sub-plans that contain a DELIM_GET. This is tricky to fix, but in many cases, we optimize the DELIM_GET away with the Deliminator optimizer, which is invoked right after the JoinOrderOptimizer. Once the DELIM_GET is gone, we can simply optimize the join order of the sub-plan. So, I've added a call to the JoinOrderOptimizer within the Deliminator when this occurs.

Both of these optimizations are applicable to TPC-H query 2, and our plan_cost_runner.py benchmark script seems to be happy, as we reduce the size of the intermediates by ~11.5x.

====================================================
===========     IMPROVEMENTS DETECTED     ==========
====================================================

Query: q02
Old cost: 1921196
New cost: 167216

This is the new plan for this query:

┌───────────────────────┐                                                                                                                                                                                                        
│    EXPLAIN_ANALYZE    │                                                                                                                                                                                                        
│   ─ ─ ─ ─ ─ ─ ─ ─ ─   │                                                                                                                                                                                                        
│           0           │                                                                                                                                                                                                        
│        (0.00s)        │                                                                                                                                                                                                        
└───────────┬───────────┘                                                                                                                                                                                                                                 
┌───────────┴───────────┐                                                                                                                                                                                                        
│         TOP_N         │                                                                                                                                                                                                        
│   ─ ─ ─ ─ ─ ─ ─ ─ ─   │                                                                                                                                                                                                        
│        Top 100        │                                                                                                                                                                                                        
│   ─ ─ ─ ─ ─ ─ ─ ─ ─   │                                                                                                                                                                                                        
│supplier.s_acctbal DESC│                                                                                                                                                                                                        
│   nation.n_name ASC   │                                                                                                                                                                                                        
│  supplier.s_name ASC  │                                                                                                                                                                                                        
│   part.p_partkey ASC  │                                                                                                                                                                                                        
│   ─ ─ ─ ─ ─ ─ ─ ─ ─   │                                                                                                                                                                                                        
│          100          │                                                                                                                                                                                                        
│        (0.00s)        │                                                                                                                                                                                                        
└───────────┬───────────┘                                                                                                                                                                                                                                 
┌───────────┴───────────┐                                                                                                                                                                                                        
│       PROJECTION      │                                                                                                                                                                                                        
│   ─ ─ ─ ─ ─ ─ ─ ─ ─   │                                                                                                                                                                                                        
│       s_acctbal       │                                                                                                                                                                                                        
│         s_name        │                                                                                                                                                                                                        
│         n_name        │                                                                                                                                                                                                        
│       p_partkey       │                                                                                                                                                                                                        
│         p_mfgr        │                                                                                                                                                                                                        
│       s_address       │                                                                                                                                                                                                        
│        s_phone        │                                                                                                                                                                                                        
│       s_comment       │                                                                                                                                                                                                        
│   ─ ─ ─ ─ ─ ─ ─ ─ ─   │                                                                                                                                                                                                        
│          460          │                                                                                                                                                                                                        
│        (0.00s)        │                                                                                                                                                                                                        
└───────────┬───────────┘                                                                                                                                                                                                                                 
┌───────────┴───────────┐                                                                                                                                                                                                        
│       PROJECTION      │                                                                                                                                                                                                        
│   ─ ─ ─ ─ ─ ─ ─ ─ ─   │                                                                                                                                                                                                        
│           #0          │                                                                                                                                                                                                        
│           #3          │                                                                                                                                                                                                        
│           #4          │                                                                                                                                                                                                        
│           #5          │                                                                                                                                                                                                        
│           #6          │                                                                                                                                                                                                        
│           #7          │                                                                                                                                                                                                        
│           #8          │                                                                                                                                                                                                        
│           #9          │                                                                                                                                                                                                        
│   ─ ─ ─ ─ ─ ─ ─ ─ ─   │                                                                                                                                                                                                        
│          460          │                                                                                                                                                                                                        
│        (0.00s)        │                                                                                                                                                                                                        
└───────────┬───────────┘                                                                                                                                                                                                                                 
┌───────────┴───────────┐                                                                                                                                                                                                        
│         FILTER        │                                                                                                                                                                                                        
│   ─ ─ ─ ─ ─ ─ ─ ─ ─   │                                                                                                                                                                                                        
│    (ps_supplycost =   │                                                                                                                                                                                                        
│        SUBQUERY)      │                                                                                                                                                                                                        
│   ─ ─ ─ ─ ─ ─ ─ ─ ─   │                                                                                                                                                                                                        
│         EC: 0         │                                                                                                                                                                                                        
│   ─ ─ ─ ─ ─ ─ ─ ─ ─   │                                                                                                                                                                                                        
│          460          │                                                                                                                                                                                                        
│        (0.00s)        │                                                                                                                                                                                                        
└───────────┬───────────┘                                                                                                                                                                                                                                 
┌───────────┴───────────┐                                                                                                                                                                                                        
│       HASH_JOIN       │                                                                                                                                                                                                        
│   ─ ─ ─ ─ ─ ─ ─ ─ ─   │                                                                                                                                                                                                        
│         SINGLE        │                                                                                                                                                                                                        
│    p_partkey IS NOT   │                                                                                                                                                                                                        
│ DISTINCT FROM p_p...  │                                                                                                                                                                                                        
│   ─ ─ ─ ─ ─ ─ ─ ─ ─   ├────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐                                                                                       
│         EC: 0         │                                                                                                                │                                                                                       
│        Cost: 0        │                                                                                                                │                                                                                       
│   ─ ─ ─ ─ ─ ─ ─ ─ ─   │                                                                                                                │                                                                                       
│          642          │                                                                                                                │                                                                                       
│        (0.00s)        │                                                                                                                │                                                                                       
└───────────┬───────────┘                                                                                                                │                                                                                                                
┌───────────┴───────────┐                                                                                                    ┌───────────┴───────────┐                                                                           
│       HASH_JOIN       │                                                                                                    │       PROJECTION      │                                                                           
│   ─ ─ ─ ─ ─ ─ ─ ─ ─   │                                                                                                    │   ─ ─ ─ ─ ─ ─ ─ ─ ─   │                                                                           
│         INNER         │                                                                                                    │   min(ps_supplycost)  │                                                                           
│ ps_suppkey = s_suppkey│                                                                                                    │           #0          │                                                                           
│   ─ ─ ─ ─ ─ ─ ─ ─ ─   │                                                                                                    │   ─ ─ ─ ─ ─ ─ ─ ─ ─   │                                                                           
│        EC: 587        ├─────────────────────────────────────┐                                                              │         117422        │                                                                           
│       Cost: 5970      │                                     │                                                              │        (0.00s)        │                                                                           
│   ─ ─ ─ ─ ─ ─ ─ ─ ─   │                                     │                                                              │                       │                                                                           
│          642          │                                     │                                                              │                       │                                                                           
│        (0.00s)        │                                     │                                                              │                       │                                                                           
└───────────┬───────────┘                                     │                                                              └───────────┬───────────┘                                                                                                    
┌───────────┴───────────┐                         ┌───────────┴───────────┐                                                  ┌───────────┴───────────┐                                                                           
│       HASH_JOIN       │                         │       HASH_JOIN       │                                                  │     HASH_GROUP_BY     │                                                                           
│   ─ ─ ─ ─ ─ ─ ─ ─ ─   │                         │   ─ ─ ─ ─ ─ ─ ─ ─ ─   │                                                  │   ─ ─ ─ ─ ─ ─ ─ ─ ─   │                                                                           
│         INNER         │                         │         INNER         │                                                  │           #0          │                                                                           
│ ps_partkey = p_partkey│                         │     s_nationkey =     │                                                  │        min(#1)        │                                                                           
│   ─ ─ ─ ─ ─ ─ ─ ─ ─   │                         │       n_nationkey     │                                                  │   ─ ─ ─ ─ ─ ─ ─ ─ ─   │                                                                           
│        EC: 3377       ├────────────┐            │   ─ ─ ─ ─ ─ ─ ─ ─ ─   ├────────────┐                                     │         117422        │                                                                           
│       Cost: 3377      │            │            │        EC: 2000       │            │                                     │        (0.03s)        │                                                                           
│   ─ ─ ─ ─ ─ ─ ─ ─ ─   │            │            │       Cost: 2005      │            │                                     │                       │                                                                           
│          2988         │            │            │   ─ ─ ─ ─ ─ ─ ─ ─ ─   │            │                                     │                       │                                                                           
│        (0.00s)        │            │            │          1987         │            │                                     │                       │                                                                           
│                       │            │            │        (0.00s)        │            │                                     │                       │                                                                           
└───────────┬───────────┘            │            └───────────┬───────────┘            │                                     └───────────┬───────────┘                                                                                                    
┌───────────┴───────────┐┌───────────┴───────────┐┌───────────┴───────────┐┌───────────┴───────────┐                         ┌───────────┴───────────┐                                                                           
│        SEQ_SCAN       ││       PROJECTION      ││        SEQ_SCAN       ││       HASH_JOIN       │                         │       PROJECTION      │                                                                           
│   ─ ─ ─ ─ ─ ─ ─ ─ ─   ││   ─ ─ ─ ─ ─ ─ ─ ─ ─   ││   ─ ─ ─ ─ ─ ─ ─ ─ ─   ││   ─ ─ ─ ─ ─ ─ ─ ─ ─   │                         │   ─ ─ ─ ─ ─ ─ ─ ─ ─   │                                                                           
│        partsupp       ││           #0          ││        supplier       ││         INNER         │                         │       ps_partkey      │                                                                           
│   ─ ─ ─ ─ ─ ─ ─ ─ ─   ││           #2          ││   ─ ─ ─ ─ ─ ─ ─ ─ ─   ││     n_regionkey =     │                         │     ps_supplycost     │                                                                           
│       ps_partkey      ││   ─ ─ ─ ─ ─ ─ ─ ─ ─   ││       s_suppkey       ││       r_regionkey     │                         │   ─ ─ ─ ─ ─ ─ ─ ─ ─   │                                                                           
│       ps_suppkey      ││          747          ││      s_nationkey      ││   ─ ─ ─ ─ ─ ─ ─ ─ ─   │                         │         158960        │                                                                           
│     ps_supplycost     ││        (0.00s)        ││       s_acctbal       ││         EC: 5         │                         │        (0.00s)        │                                                                           
│   ─ ─ ─ ─ ─ ─ ─ ─ ─   ││                       ││         s_name        ││        Cost: 5        │                         │                       │                                                                           
│       EC: 800000      ││                       ││       s_address       ││   ─ ─ ─ ─ ─ ─ ─ ─ ─   ├────────────┐            │                       │                                                                           
│   ─ ─ ─ ─ ─ ─ ─ ─ ─   ││                       ││        s_phone        ││           5           │            │            │                       │                                                                           
│         800000        ││                       ││       s_comment       ││        (0.00s)        │            │            │                       │                                                                           
│        (0.00s)        ││                       ││   ─ ─ ─ ─ ─ ─ ─ ─ ─   ││                       │            │            │                       │                                                                           
│                       ││                       ││       EC: 10000       ││                       │            │            │                       │                                                                           
│                       ││                       ││   ─ ─ ─ ─ ─ ─ ─ ─ ─   ││                       │            │            │                       │                                                                           
│                       ││                       ││         10000         ││                       │            │            │                       │                                                                           
│                       ││                       ││        (0.00s)        ││                       │            │            │                       │                                                                           
└───────────────────────┘└───────────┬───────────┘└───────────────────────┘└───────────┬───────────┘            │            └───────────┬───────────┘                                                                                                    
                         ┌───────────┴───────────┐                         ┌───────────┴───────────┐┌───────────┴───────────┐┌───────────┴───────────┐                                                                           
                         │         FILTER        │                         │        SEQ_SCAN       ││        SEQ_SCAN       ││       PROJECTION      │                                                                           
                         │   ─ ─ ─ ─ ─ ─ ─ ─ ─   │                         │   ─ ─ ─ ─ ─ ─ ─ ─ ─   ││   ─ ─ ─ ─ ─ ─ ─ ─ ─   ││   ─ ─ ─ ─ ─ ─ ─ ─ ─   │                                                                           
                         │suffix(p_type, 'BRASS')│                         │         nation        ││         region        ││           #0          │                                                                           
                         │   ─ ─ ─ ─ ─ ─ ─ ─ ─   │                         │   ─ ─ ─ ─ ─ ─ ─ ─ ─   ││   ─ ─ ─ ─ ─ ─ ─ ─ ─   ││           #2          │                                                                           
                         │        EC: 800        │                         │      n_nationkey      ││      r_regionkey      ││   ─ ─ ─ ─ ─ ─ ─ ─ ─   │                                                                           
                         │   ─ ─ ─ ─ ─ ─ ─ ─ ─   │                         │      n_regionkey      ││   ─ ─ ─ ─ ─ ─ ─ ─ ─   ││         158960        │                                                                           
                         │          747          │                         │         n_name        ││ Filters: r_name=EUROPE││        (0.00s)        │                                                                           
                         │        (0.00s)        │                         │   ─ ─ ─ ─ ─ ─ ─ ─ ─   ││ AND r_name IS NOT NULL││                       │                                                                           
                         │                       │                         │         EC: 25        ││   ─ ─ ─ ─ ─ ─ ─ ─ ─   ││                       │                                                                           
                         │                       │                         │   ─ ─ ─ ─ ─ ─ ─ ─ ─   ││         EC: 1         ││                       │                                                                           
                         │                       │                         │           25          ││   ─ ─ ─ ─ ─ ─ ─ ─ ─   ││                       │                                                                           
                         │                       │                         │        (0.00s)        ││           1           ││                       │                                                                           
                         │                       │                         │                       ││        (0.00s)        ││                       │                                                                           
                         └───────────┬───────────┘                         └───────────────────────┘└───────────────────────┘└───────────┬───────────┘                                                                                                    
                         ┌───────────┴───────────┐                                                                           ┌───────────┴───────────┐                                                                           
                         │        SEQ_SCAN       │                                                                           │       HASH_JOIN       │                                                                           
                         │   ─ ─ ─ ─ ─ ─ ─ ─ ─   │                                                                           │   ─ ─ ─ ─ ─ ─ ─ ─ ─   │                                                                           
                         │          part         │                                                                           │         INNER         │                                                                           
                         │   ─ ─ ─ ─ ─ ─ ─ ─ ─   │                                                                           │ ps_suppkey = s_suppkey│                                                                           
                         │       p_partkey       │                                                                           │   ─ ─ ─ ─ ─ ─ ─ ─ ─   │                                                                           
                         │         p_type        │                                                                           │       EC: 139057      │                                                                           
                         │         p_mfgr        │                                                                           │      Cost: 141062     │                                                                           
                         │   ─ ─ ─ ─ ─ ─ ─ ─ ─   │                                                                           │   ─ ─ ─ ─ ─ ─ ─ ─ ─   ├────────────┐                                                              
                         │ Filters: p_size=15 AND│                                                                           │         158960        │            │                                                              
                         │   p_size IS NOT NULL  │                                                                           │        (0.01s)        │            │                                                              
                         │   ─ ─ ─ ─ ─ ─ ─ ─ ─   │                                                                           │                       │            │                                                              
                         │        EC: 4000       │                                                                           │                       │            │                                                              
                         │   ─ ─ ─ ─ ─ ─ ─ ─ ─   │                                                                           │                       │            │                                                              
                         │          3907         │                                                                           │                       │            │                                                              
                         │        (0.00s)        │                                                                           │                       │            │                                                              
                         └───────────────────────┘                                                                           └───────────┬───────────┘            │                                                                                       
                                                                                                                             ┌───────────┴───────────┐┌───────────┴───────────┐                                                  
                                                                                                                             │        SEQ_SCAN       ││       HASH_JOIN       │                                                  
                                                                                                                             │   ─ ─ ─ ─ ─ ─ ─ ─ ─   ││   ─ ─ ─ ─ ─ ─ ─ ─ ─   │                                                  
                                                                                                                             │        partsupp       ││         INNER         │                                                  
                                                                                                                             │   ─ ─ ─ ─ ─ ─ ─ ─ ─   ││     s_nationkey =     │                                                  
                                                                                                                             │       ps_partkey      ││       n_nationkey     │                                                  
                                                                                                                             │       ps_suppkey      ││   ─ ─ ─ ─ ─ ─ ─ ─ ─   │                                                  
                                                                                                                             │     ps_supplycost     ││        EC: 2000       ├────────────┐                                     
                                                                                                                             │   ─ ─ ─ ─ ─ ─ ─ ─ ─   ││       Cost: 2005      │            │                                     
                                                                                                                             │       EC: 800000      ││   ─ ─ ─ ─ ─ ─ ─ ─ ─   │            │                                     
                                                                                                                             │   ─ ─ ─ ─ ─ ─ ─ ─ ─   ││          1987         │            │                                     
                                                                                                                             │         800000        ││        (0.00s)        │            │                                     
                                                                                                                             │        (0.00s)        ││                       │            │                                     
                                                                                                                             └───────────────────────┘└───────────┬───────────┘            │                                                              
                                                                                                                                                      ┌───────────┴───────────┐┌───────────┴───────────┐                         
                                                                                                                                                      │        SEQ_SCAN       ││       HASH_JOIN       │                         
                                                                                                                                                      │   ─ ─ ─ ─ ─ ─ ─ ─ ─   ││   ─ ─ ─ ─ ─ ─ ─ ─ ─   │                         
                                                                                                                                                      │        supplier       ││         INNER         │                         
                                                                                                                                                      │   ─ ─ ─ ─ ─ ─ ─ ─ ─   ││     n_regionkey =     │                         
                                                                                                                                                      │       s_suppkey       ││       r_regionkey     │                         
                                                                                                                                                      │      s_nationkey      ││   ─ ─ ─ ─ ─ ─ ─ ─ ─   ├────────────┐            
                                                                                                                                                      │   ─ ─ ─ ─ ─ ─ ─ ─ ─   ││         EC: 5         │            │            
                                                                                                                                                      │       EC: 10000       ││        Cost: 5        │            │            
                                                                                                                                                      │   ─ ─ ─ ─ ─ ─ ─ ─ ─   ││   ─ ─ ─ ─ ─ ─ ─ ─ ─   │            │            
                                                                                                                                                      │         10000         ││           5           │            │            
                                                                                                                                                      │        (0.00s)        ││        (0.00s)        │            │            
                                                                                                                                                      └───────────────────────┘└───────────┬───────────┘            │                                     
                                                                                                                                                                               ┌───────────┴───────────┐┌───────────┴───────────┐
                                                                                                                                                                               │        SEQ_SCAN       ││        SEQ_SCAN       │
                                                                                                                                                                               │   ─ ─ ─ ─ ─ ─ ─ ─ ─   ││   ─ ─ ─ ─ ─ ─ ─ ─ ─   │
                                                                                                                                                                               │         nation        ││         region        │
                                                                                                                                                                               │   ─ ─ ─ ─ ─ ─ ─ ─ ─   ││   ─ ─ ─ ─ ─ ─ ─ ─ ─   │
                                                                                                                                                                               │      n_nationkey      ││      r_regionkey      │
                                                                                                                                                                               │      n_regionkey      ││   ─ ─ ─ ─ ─ ─ ─ ─ ─   │
                                                                                                                                                                               │   ─ ─ ─ ─ ─ ─ ─ ─ ─   ││ Filters: r_name=EUROPE│
                                                                                                                                                                               │         EC: 25        ││ AND r_name IS NOT NULL│
                                                                                                                                                                               │   ─ ─ ─ ─ ─ ─ ─ ─ ─   ││   ─ ─ ─ ─ ─ ─ ─ ─ ─   │
                                                                                                                                                                               │           25          ││         EC: 1         │
                                                                                                                                                                               │        (0.00s)        ││   ─ ─ ─ ─ ─ ─ ─ ─ ─   │
                                                                                                                                                                               │                       ││           1           │
                                                                                                                                                                               │                       ││        (0.00s)        │
                                                                                                                                                                               └───────────────────────┘└───────────────────────┘ 

As we can see, we report cardinality estimates for the FILTER as well as the SEQ_SCAN it sits on top of. The top-most join is a comparison join with JoinType::SINGLE. This was a delim join before. The right-hand side child of this contained DELIM_GETs, and was therefore not re-ordered. Because we did not re-order this, we did not report any cardinality estimates either. As we can see, we re-order and report cardinality estimates now.

The FILTER optimization has implications for the Join Order Benchmark as well. The DELIM_GET optimization does not, as there are no correlated subqueries in JOB. Here is the output of the plan_cost_runner.py script:

====================================================
===========     IMPROVEMENTS DETECTED     ==========
====================================================

Query: 08b
Old cost: 37036
New cost: 342

Query: 09b
Old cost: 285908
New cost: 223418

Query: 18a
Old cost: 8003364
New cost: 1408455

Query: 19b
Old cost: 278320
New cost: 155

Query: 23b
Old cost: 1515144
New cost: 2536

Query: 30b
Old cost: 555902
New cost: 618

====================================================
===========     REGRESSIONS DETECTED     ===========
====================================================

Query: 31a
Old cost: 829467
New cost: 1877939

Query: 31c
Old cost: 1364844
New cost: 1940553

As we can see, we improve the cost of 6 queries, while regressing on 2 queries. I'd say that the difference is an improvement overall.

Finally, I've cleaned up some code.

double inspect_result = (double)InspectTableFilters(card_after_filters, op, table_filters);
card_after_filters = MinValue(inspect_result, (double)card_after_filters);
}
if (has_logical_filter) {
card_after_filters *= DEFAULT_SELECTIVITY;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing this code caused the bug where we don't apply any filters? My initial thinking here was that if there are 1+ filters to a table, apply the default selectivity once. I didn't want to apply multiple filter selectivities independently as that could lead to greater inaccuracies. Looks like that can still happen here?

I think the issue might then be in the function InspectTableFilters? Maybe in that function the Default selectivity doesn't get applied for some reason?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is indeed the code that caused the bug. It checked whether there was a LogicalFilter. If there is one, it would ignore the filters that were pushed into the base tables. We now apply multiple filter selectivities independently, but I don't see why that would be a problem.

In InspectTableFilters, we only apply the filters on the base table, and not those in the LogicalFilter that might be on top. So the bug is similar. Maybe we can check together how to properly fix this tomorrow?

auto &filter_props = *result_operator->estimated_props;
auto &child_operator = *result_operator->children[0];
child_operator.estimated_props = make_unique<EstimatedProperties>(
filter_props.GetCardinality<double>() / CardinalityEstimator::DEFAULT_SELECTIVITY, filter_props.GetCost());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need estimated properties on both? If I'm not mistaken, the properties of a join order node are just pulled up from all the nodes below it. Those properties are then used by the JOO.

Or is this so prevent confusion when we print join plans?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is purely to improve EXPLAIN ANALYZE output.

@lnkuiper
Copy link
Contributor Author

We just went over this and agreed that the implementation is good as is @Mytherin

@Tmonster Tmonster self-requested a review January 13, 2023 09:26
Copy link
Contributor

@Tmonster Tmonster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm 👍

Important to note that we sometimes apply default selectivity twice in the case of 2+ filters. Specifically when one filter can be pushed into the sequential scan, and one cannot. For the TPCH query that Laurens mentioned in the description, the sequential scan has a filter on an integer type (an equality filter), and a logical filter is on a string type. After a brief discussion, we realized it is reasonable to assume the filters are independent in this case. In these cases, we now apply the default selectivity twice.

image

Copy link
Collaborator

@Mytherin Mytherin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! LGTM. Ready to merge after tests pass.

@lnkuiper
Copy link
Contributor Author

The failing test is due to 2 plans in JOB regressing as mentioned

@Mytherin Mytherin merged commit 88f5458 into duckdb:master Jan 16, 2023
@lnkuiper lnkuiper deleted the explain_cardinalities branch January 24, 2023 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants