DISCARD(7)
π NAME π
okay so this is the DISCARD(7) page from the PostgreSQL 17.11 Documentation, and it's literally about DISCARD - discard session state. periodt. π
β¨ SYNOPSIS β¨
DISCARD { ALL | PLANS | SEQUENCES | TEMPORARY | TEMP }
π¦ DESCRIPTION π¦
okay bestie, DISCARD releases internal resources associated with a database session. it's giving "reset button" energy: this command is useful for partially or fully resetting the session's state. there are several subcommands to release different types of resources, and the DISCARD ALL variant subsumes all the others, and also resets additional state. no cap. β¨
π PARAMETERS π
PLANSβ releases all cached query plans, forcing re-planning to occur the next time the associated prepared statement is used. so next time it's gotta think again, iykyk. π§SEQUENCESβ discards all cached sequence-related state, includingcurrval()/lastval()information and any preallocated sequence values that have not yet been returned bynextval(). (SeeCREATE SEQUENCE(CREATE_SEQUENCE(7)) for a description of preallocated sequence values.) π«TEMPORARYorTEMPβ drops all temporary tables created in the current session. bye-bye temp tables π«Ά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:
CLOSE ALL;
SET SESSION AUTHORIZATION DEFAULT;
RESET ALL;
DEALLOCATE ALL;
UNLISTEN *;
SELECT pg_advisory_unlock_all();
DISCARD PLANS;
DISCARD TEMP;
DISCARD SEQUENCES;
πΈ NOTES πΈ
major caveat bestie: DISCARD ALL cannot be executed inside a transaction block. so don't try it in there, fr fr. π
π COMPATIBILITY π
DISCARD is a PostgreSQL extension. slay. π
mwah π this iconic page comes from PostgreSQL 17.11 and it's dated 2026. that's the source/version + date sign-off, bestie. π
π¦ where this page comes from
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms