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.25k stars 2.95k forks source link

Choose whether to use WindowOperator or TopNRowNumberOperator based on stats #5319

Closed sopel39 closed 3 years ago

sopel39 commented 4 years ago

TopNRowNumberOperator is very memory inefficient when most of the groups are singletons or contain just few rows. In such case it's better to use WindowOprator. Behavior which operator to use is determined by optimize_top_n_row_number toggle. We could add optimize_top_n_row_number=AUTO option which would trigger usage of CBO to determine whether to use TopNRowNumberOperator or WindowOprator

sopel39 commented 3 years ago

This is no longer relevant after https://github.com/trinodb/trino/pull/6333