Skip to content

SQL: a more compact way of translating the queries that have AND statements #30019

@elasticmachine

Description

@elasticmachine

Original comment by @astefan:

At the moment, a query like SELECT name,page_count,release_date AS DATE,my_boolean,SCORE() FROM library WHERE name='NULL' AND release_date>='1800-06-02' AND release_date<='2011-06-02' AND price>10.0000 AND match(name, 'dune') AND match(author, 'dan') AND match(author, 'frank') ORDER BY SCORE() (a series of simple AND statements) gets translated to something like LINK REDACTED, meaning a bunch of nested bool statements which basically have one filter statement per bool, except the very first condition after WHERE.

That long list of nested bools could have been written in a more compact way like LINK REDACTED. For now, I don't know if performance-wise there is any difference, but I'll update this issue with more details when I do find out. Even if there would be comparable from performance point of view, the second approach is much more compact/readable.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions