trinodb / trino

Official repository of Trino, the distributed SQL query engine for big data, formerly known as PrestoSQL (https://trino.io)
https://trino.io
Apache License 2.0
10.46k stars 3.01k forks source link

Simplify `LIKE '%'` predicates #17124

Closed findepi closed 1 year ago

findepi commented 1 year ago

information_schema and system.jdbc queries would benefit if we simplified table_name LIKE '%' (and table_name LIKE '%%' etc.) queries to table_name IS NOT NULL.

findepi commented 1 year ago

cc @huberty89 @kokosing @martint

kokosing commented 1 year ago

Is this only information_schema specific? It sounds like it could be a generic optimization. Does % match an empty string too?

findepi commented 1 year ago

yes, the optimization should be generic. i mentioned information_schema and system.jdbc to emphasize importance of such optimization. In these places, today we take different, less optimal code path when LIKE '%' predicate is present.

chenjian2664 commented 1 year ago

I am interested in this part, Could you guide me on how to start on this part?

kokosing commented 1 year ago

I am under impression that this rewrite could be handled by io.trino.sql.planner.iterative.rule.SimplifyExpressions

chenjian2664 commented 1 year ago

@kokosing Thank you