stonedb icon indicating copy to clipboard operation
stonedb copied to clipboard

bug: slow-SQL-Q17-when subquery use avg sql spend too much time

Open adofsauron opened this issue 1 year ago • 0 comments

Describe the problem

  1. use tpch data
  2. exec sql

`

select sum(l_extendedprice) / 7.0 as avg_yearly from lineitem, part where p_partkey = l_partkey and p_brand = 'Brand#23' and p_container = 'MED BOX' and l_quantity < ( select 0.2 * avg(l_quantity) from lineitem where l_partkey = p_partkey );

`

`

id select_type table partitions type possible_keys key key_len ref rows filtered Extra    
1 PRIMARY lineitem   ALL         59986052 100      
1 PRIMARY part   eq_ref PRIMARY PRIMARY 4 tpch.lineitem.l_partkey 1 5 Using where with pushed condition ((tpch.part.p_brand = 'Brand#23') and (tpch.part.p_container = 'MED BOX'))(t0) Pckrows: 16, susp. 16 (0 empty 0 full). Conditions: 2    
2 DEPENDENT SUBQUERY lineitem   ALL         59986052 10 Using where    

`

Expected behavior

No response

How To Reproduce

No response

Environment

No response

Are you interested in submitting a PR to solve the problem?

  • [X] Yes, I will!

adofsauron avatar Jul 28 '22 14:07 adofsauron