# Removing redundant ORDER BY

DevFeed: [Removing redundant ORDER BY](<https://devfeed.tech/articles/removing-redundant-order-by-8621.md>)

Original publisher: [Read original article](<https://trino.io/blog/2019/06/03/redundant-order-by.html>)

Author: Martin Traverso

Published: 2019-06-03T00:00:00Z

Content type: article

Language: en

Sources: [Trino Blog](<https://devfeed.tech/sources/trino-blog.md>)

Topics: [SQL](<https://devfeed.tech/topics/sql.md>), [Sorting](<https://devfeed.tech/topics/sorting.md>), [Databases](<https://devfeed.tech/topics/databases.md>), [Concurrent Programming](<https://devfeed.tech/topics/concurrent-programming.md>)

Tags: [cpu](<https://devfeed.tech/tags/cpu.md>), [memory](<https://devfeed.tech/tags/memory.md>), [performance](<https://devfeed.tech/tags/performance.md>), [resources](<https://devfeed.tech/tags/resources.md>), [sorting](<https://devfeed.tech/tags/sorting.md>), [sql](<https://devfeed.tech/tags/sql.md>)

## AI overview

The article explains how redundant ORDER BY clauses can cause unnecessary sorting and degrade query performance. It describes a fix in Presto 312 that allows the engine to remove ORDER BY clauses when they cannot affect query semantics, while noting cases where ordering remains meaningful.

## Source excerpt

Optimizers are all about doing work in the most cost-effective manner and avoiding unnecessary work. Some SQL constructs such as ORDER BY do not affect query results in many situations, and can negatively affect performance unless the optimizer is smart enough to remove them.