↑↓ select↵ open⌫ change scopeOpen full search

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

Wiki / psql Commands

\flush

This group of commands implements pipelining of SQL statements. A pipeline must begin with a \startpipeline and end with an \endpipeline . In between there may be any number of \syncpipeline commands, which sends a sync message without ending the ongoing pipeline and flushing the send buffer. In pipeline mode, statements are sent to the server without waiting for the results of previous statements. See Section 32.5 for more details.

Reading PG 18·Select a recorded version

Client
psql 18.7
Case-sensitive spelling
\flush
command
\flush
manual path
app-psql.html#APP-PSQL-META-COMMAND-PIPELINE
modifiers
Unknown
signature
\startpipeline \sendpipeline \syncpipeline \endpipeline \flushrequest \flush \getresults [ number_results ]
spellings
\startpipeline, \sendpipeline, \syncpipeline, \endpipeline, \flushrequest, \flush, \getresults

Definition PG 18

\startpipeline
\sendpipeline
\syncpipeline
\endpipeline
\flushrequest
\flush
\getresults [ number_results ]

This group of commands implements pipelining of SQL statements. A pipeline must begin with a \startpipeline and end with an \endpipeline. In between there may be any number of \syncpipeline commands, which sends a sync message without ending the ongoing pipeline and flushing the send buffer. In pipeline mode, statements are sent to the server without waiting for the results of previous statements. See Section 32.5 for more details.

All queries executed while a pipeline is ongoing use the extended query protocol. Queries are appended to the pipeline when ending with a semicolon. The meta-commands \bind, \bind_named, \close_prepared or \parse can be used in an ongoing pipeline. While a pipeline is ongoing, \sendpipeline will append the current query buffer to the pipeline. Other meta-commands like \g, \gx or \gdesc are not allowed in pipeline mode.

\flushrequest appends a flush command to the pipeline, allowing to read results with \getresults without issuing a sync or ending the pipeline. \getresults will automatically push unsent data to the server. \flush can be used to manually push unsent data.

\getresults accepts an optional number_results parameter. If provided, only the first number_results pending results will be read. If not provided or 0, all pending results are read.

When pipeline mode is active, a dedicated prompt variable is available to report the pipeline status. See %P for more details

COPY is not supported while in pipeline mode.

Example:

\startpipeline
SELECT * FROM pg_class;
SELECT 1 \bind \sendpipeline
\flushrequest
\getresults
\endpipeline

Exact case-sensitive spellings

  • \startpipeline
  • \sendpipeline
  • \syncpipeline
  • \endpipeline
  • \flushrequest
  • \flush
  • \getresults

Spellings in this manual definition

CommandDocumented suffix modifiers
\startpipelineNone listed in this signature
\sendpipelineNone listed in this signature
\syncpipelineNone listed in this signature
\endpipelineNone listed in this signature
\flushrequestNone listed in this signature
\flushNone listed in this signature
\getresultsNone listed in this signature

Compare versions

Complete source facts

documentation revision

{"inputs":[{"file":"app-psql.html","kind":"same-version-reviewed-manual","locale":"en","sha256":"af50448485df02bdef2b72b8347192ba029c7082b8d0392ecb17db44ad533aaf","version":"18.7"},{"file":"app-psql.html","kind":"same-version-reviewed-manual","locale":"zh-Hans","sha256":"cb475c53a16d9e06358f5e6c9c5649645db92568cfd319f230c62c9f57ae090b","version":"18.7"}],"release":"18.7","runtime_remeasured":false,"source_revision":"pgdoc:b9f0e7232f60f380d642ac9b99226606c254b552"}

Source references

Full definition and evidence JSON

Definition sources

center · PostgreSQL 18 · 1b2d62b4845aa46374f2cb680f95d3392322cc8128646992ae4e18d0e7084915

Text language: en · 1b2d62b4845aa46374f2cb680f95d3392322cc8128646992ae4e18d0e7084915