Citus Con: An Event for Postgres 2023 will happen virtually Apr 18-19 in 2023. Big news, the Call for Speakers is open! 💥
In recent years, PostgreSQL has seen several improvements which make sorting faster. In the PostgreSQL 15 development cycle—which ended in April 2022—Ronan Dunklau, Thomas Munro, Heikki Linnakangas, and I contributed some changes to PostgreSQL to make sorts go even faster.
Each of the improvements to sort should be available when PostgreSQL 15 is out in late 2022.
Why care about sort performance? When you run your application on PostgreSQL, there are several scenarios where PostgreSQL needs to sort records (aka rows) on your behalf. The main one is for ORDER BY queries. Sorting can also be used in:
- Aggregate functions with an ORDER BY clause
- GROUP BY queries
- Queries with a plan containing a Merge Join
- UNION queries
- DISTINCT queries
- Queries with window functions with a PARTITION BY and/or ORDER BY clause
If PostgreSQL is able to sort records faster, then queries using sort will run more quickly.Keep reading