

The “aset” allocator always rounds memory allocation request sizes up to the next power of 2. They act as a buffer between PostgreSQL and the underlying operating system.

These memory allocators get used for managing memory in PostgreSQL. In PostgreSQL 14 and earlier, when memory is allocated to store records to be sorted, the “aset” memory allocator is used. When PostgreSQL stores records in preparation for sorting, it must copy the record into an area of memory ready to sort. Figure 1: Sorting a single column in PostgreSQL 15 performs 26% faster than in PostgreSQL 14.įor further information see the link to the Postgres 15 commit message Change 2: Reduce memory consumption by using generation memory context The graph below shows how much storing only the Datum can help by testing the performance of sorting 10,000 integer values. These are likely to appear in queries containing an EXISTS or NOT EXISTS clause. A more common reason to have single column sorts is for Merge Semi and Anti Joins. The first of the above queries is likely rare in the real world. SELECT col1, col2 FROM tab ORDER BY col1 The optimization works for the following query: Storing just the Datum means that the tuple no longer has to be copied into the sort’s memory. The change here makes it so that PostgreSQL 15 only stores a Datum when there is a single column in the result of the sort. PostgreSQL 14’s query executor always would store the entire tuple during a Sort operation.

> Index Only Scan using a_pkey on a (cost=.70 rows=130352 width=8) The query plan like this works: QUERY PLAN My (simplified) query: SELECT a.id FROM a LEFT JOIN b ON b.id = a.id WHERE b.id IS NULL ORDER BY id What you see will depend on your version, and the stats the planner sees. INSERT INTO tr SELECT s, 'text ' || s FROM generate_series(1,999999) s WHERE s % 3 = 0 ĮXPLAIN ANALYSE SELECT i,t FROM tl LEFT JOIN tr USING (i) WHERE tr.i IS NULL INSERT INTO tl SELECT s, 'text ' || s FROM generate_series(1,999999) s This is v9.0: CREATE TABLE tl (i int, t text) You'll need to provide version details, and as jmz says EXPLAIN ANALYSE output to get any useful advice.įranz - don't think whether it's possible, test and know.
