Skip to content

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

@kongshanxuelin

Description

@kongshanxuelin

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);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions