ignite icon indicating copy to clipboard operation
ignite copied to clipboard

sql query use "in ..." is very slow

Open kongshanxuelin opened this issue 2 months ago • 1 comments

this is query very slow,aboult 1s: SELECT f1,f2,f3 FROM table_x WHERE f1IN (107,108) AND f2= 1 AND ydate = 20230616

this is query very fast,about 20ms: SELECT f1,f2,f3 FROM table_x WHERE f1=107 AND f2= 1 AND ydate = 20230616 UNION ALL SELECT f1,f2,f3 FROM table_x WHERE f1=108 AND f2 = 1 AND ydate = 20230616

this is why?

CREATE INDEX table_x_IDX ON PUBLIC.table_x (f1,f2 DESC,f3,f4);

kongshanxuelin avatar Jun 23 '24 11:06 kongshanxuelin