September 26, 2024: PostgreSQL 17 Released!
Supported Versions: Current (17) / 16 / 15 / 14 / 13 / 12
Development Versions: devel
Unsupported versions: 11 / 10 / 9.6 / 9.5 / 9.4 / 9.3 / 9.2 / 9.1 / 9.0 / 8.4 / 8.3
This documentation is for an unsupported version of PostgreSQL.
You may want to view the same page for the current version, or one of the other supported versions listed above instead.

DISCARD

Name

DISCARD -- discard session state

Synopsis

DISCARD { ALL | PLANS | TEMPORARY | TEMP }

Description

DISCARD releases internal resources associated with a database session. These resources are normally released at the end of the session.

DISCARD TEMP drops all temporary tables created in the current session. DISCARD PLANS releases all internally cached query plans. DISCARD ALL resets a session to its original state, discarding temporary resources and resetting session-local configuration changes.

Parameters

TEMPORARY or TEMP

Drops all temporary tables created in the current session.

PLANS

Releases all cached query plans.

ALL

Releases all temporary resources associated with the current session and resets the session to its initial state. Currently, this has the same effect as executing the following sequence of statements:

SET SESSION AUTHORIZATION DEFAULT;
RESET ALL;
DEALLOCATE ALL;
CLOSE ALL;
UNLISTEN *;
SELECT pg_advisory_unlock_all();
DISCARD PLANS;
DISCARD TEMP;

Notes

DISCARD ALL cannot be executed inside a transaction block.

Compatibility

DISCARD is a PostgreSQL extension.