DISCARD(7)
β¨ DISCARD β¨ (that's the page, bestie β DISCARD(7), PostgreSQL 18.6 vibes only)
π NAME
DISCARD β discard session state. like, clearing the group chat, but for your database session π§Ήβ¨
πΈ SYNOPSIS
DISCARD { ALL | PLANS | SEQUENCES | TEMPORARY | TEMP }
π¦ DESCRIPTION
okay so. DISCARD releases internal resources associated with a database session. it's giving factory reset but make it optional. this command is useful for partially or fully resetting the session's state.
there are several subcommands to release different types of resources; the DISCARD ALL variant subsumes all the others, and also resets additional state. so ALL is the main character, obviously π
π PARAMETERS
PLANSβ releases all cached query plans, forcing re-planning to occur the next time the associated prepared statement is used. bye bye cached plans, you were cute but we're moving on πSEQUENCESβ discards all cached sequence-related state, includingcurrval()/lastval()information and any preallocated sequence values that have not yet been returned bynextval(). (peepCREATE SEQUENCE(CREATE_SEQUENCE(7)) for a description of preallocated sequence values, iykyk π₯)TEMPORARYorTEMPβ drops all temporary tables created in the current session. poof. gone. not a single trace left πALLβ releases all temporary resources associated with the current session and resets the session to its initial state. the full glow-up β¨
currently, this has the same effect as executing the following sequence of statements:
CLOSE ALL;
SET SESSION AUTHORIZATION DEFAULT;
RESET ALL;
DEALLOCATE ALL;
UNLISTEN *;
SELECT pg_advisory_unlock_all();
DISCARD PLANS;
DISCARD TEMP;
DISCARD SEQUENCES;
like... she does it ALL. no cap π«Ά
β οΈ NOTES
DISCARD ALL cannot be executed inside a transaction block. that's the rule bestie, no exceptions, it will not be negotiated with π
π COMPATIBILITY
DISCARD is a PostgreSQL extension. homegrown, iconic, one of ours π
and that's the whole page fr fr π tysm for reading, this was DISCARD(7) from the PostgreSQL 18.6 documentation, dated 2026. stan a clean session, mwah πβ¨
π¦ where this page comes from
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms