DISCARD(7)

πŸ“¦ version 13.23, in opensuse-leap 16.0

πŸ’– NAME πŸ’–

okay bestie, welcome to the DISCARD(7) manual page β€” the one all about discarding session state. DISCARD β€” discard session state. slay.

✨ SYNOPSIS ✨

DISCARD { ALL | PLANS | SEQUENCES | TEMPORARY | TEMP }

πŸŽ€ DESCRIPTION πŸŽ€

So DISCARD releases internal resources associated with a database session. It’s useful for partially or fully resetting the session’s state, fr fr. There are several subcommands to release different types of resources; the DISCARD ALL variant subsumes all the others, and also resets additional state. main character energy honestly.

🌸 PARAMETERS 🌸

  • PLANS β€” releases all cached query plans, forcing re-planning to occur the next time the associated prepared statement is used. no cap, it’s making the planner think again πŸ’…
  • SEQUENCES β€” discards all cached sequence-related state, including currval()/lastval() information and any preallocated sequence values that have not yet been returned by nextval(). (See CREATE SEQUENCE (CREATE_SEQUENCE(7)) for a description of preallocated sequence values.) 🫢
  • TEMPORARY or TEMP β€” 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 πŸ’€

bestie, important: DISCARD ALL cannot be executed inside a transaction block. not even a little. no cap 😭

⭐ COMPATIBILITY ⭐

DISCARD is a PostgreSQL extension. periodt.


hope that helped, bestie πŸŽ€ this page is from PostgreSQL 13.23 and it’s dated 2025 β€” mwah πŸ’œ

πŸ“¦ where this page comes from