Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

ORDER BY requires that all rows be sent to a single worker which then sorts them. ORDER BY might often require a lot of memory on a Presto worker. When you want to look up the top or bottom N records, use LIMIT which can reduce the sort cost and memory pressure.

SQL Example

 

good

SELECT * FROM tbl ORDER BY time LIMIT 100

bad

SELECT * FROM tbl ORDER BY time