↑↓ select↵ open⌫ change scopeOpen full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

Wiki / Plan Nodes

Sort

Sorts rows from its child according to the plan sort keys.

Reading PG 18·Select a recorded version

Core node tag
T_Sort
Structured EXPLAIN Node Type
Sort
Inputs
One child plan
Output
Sorted tuples
Executor initializer
ExecInitSort
Memory mechanism
tuplesort
evidence kind
source and documentation
explain names
Sort
explain prefixes
Parallel, Async
node tag
T_Sort
parallel callbacks
ExecSortEstimate, ExecSortInitializeDSM, ExecSortInitializeWorker, ExecSortRetrieveInstrumentation
partial modes
Unknown
runtime verified
false
strategies
Unknown

Definition PG 18

Sorts rows from its child according to the plan sort keys.

EXPLAIN labels in this source build

Text-format labelStructured node identity
SortSort

Compare versions

Complete source facts

memory

{"description":"The node passes work_mem to tuplesort. Sorting can use memory or temporary files; the actual method and space use depend on the input and plan.","evidence":[{"archive_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","label":"src/backend/executor/nodeSort.c","path":"src/backend/executor/nodeSort.c","sha256":"47c6b983626e15e112f904040e96d43190ae4b3226e7cd2b27234dc95adf54a2","url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2"},{"archive_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","label":"src/backend/utils/sort/tuplesort.c","path":"src/backend/utils/sort/tuplesort.c","sha256":"509d4cef598613bbf0725f697e1e1e33f3dfc8debed20169a6c4bf1ac9e5c2e3","url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2"}],"mechanism":"tuplesort","source_notes":["Sorts tuples from the outer subtree of the node using tuplesort, which saves the results in a temporary file or memory. After the initial call, returns a tuple from the file with each call."]}

source inventory

{"executor":"src/backend/executor/execProcnode.c","explain":"src/backend/commands/explain.c","implementation":"src/backend/executor/nodeSort.c"}

Source references

Full definition and evidence JSON

Definition sources

center · PostgreSQL 18 · 555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f

Text language: en · 555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f