Skip to content

DISCARD

Enterprise command reference.

Command Snapshot

Field Value
Category Session and Transaction Control
Mutates Data Yes/Depends
Scope Session / Transaction
Privilege Model Session-scoped variants require session rights; global variants require administrative privilege.

Purpose

Executes the DISCARD SQL command with MonkDB distributed runtime semantics.

Syntax

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

Operational Notes

  • Use schema-qualified identifiers in automation and automation pipelines.
  • Validate behavior in staging for cluster-impacting or governance-impacting changes.
  • Confirm runtime effects through system tables and metrics before and after execution.

When to Use

  • Use to control session behavior, cursors, or transaction compatibility settings.
  • Use when client compatibility or session-scoped runtime behavior must be explicit.

When Not to Use

  • Avoid relying on PostgreSQL-compatible clauses whose behavior is intentionally no-op in MonkDB.

Common Errors and Troubleshooting

Symptom Likely Cause Action
Permission denied / unauthorized Missing privilege on object or cluster scope Re-run with required grants or elevated admin role.
Analysis/parse error Syntax variant or object shape mismatch Compare with canonical syntax and object definition.
Runtime failure under load Resource limits, breaker pressure, or node state transitions Check sys.jobs, sys.operations, sys.checks, and retry after mitigation.

Cross-References

Detailed Reference

The DISCARD statement in MonkDB is used to release session resources, offering a way to reset or clean up session state.

SQL Statement

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

Description

The DISCARD command provides options to release various types of resources within a database session. It supports the following subcommands:

  • ALL- Discards all session-related state.
  • PLANS- Discards prepared statement plans (MonkDB currently doesn’t cache these, so this is mostly a no-op).
  • SEQUENCES- Resets sequence-related state.
  • TEMPORARY or TEMP- Drops all temporary tables in the current session.

The other variations of the statement are irrelevant because MonkDB does not utilize query plan caching, lacks sequences, and does not support temporary tables.

Examples

Example 1. Discard all session state

DISCARD ALL;

Resets session to its initial state: drops temporary tables, resets sequences, discards prepared plans.

Example 2. Discard just temporary tables

DISCARD TEMPORARY;

or

DISCARD TEMP;

Useful if you want to remove all temporary tables created in the session without affecting other states.

Example 3. Discard sequences state

DISCARD SEQUENCES;

Resets sequence-related information like cached values.

Example 4. Discard query plans

DISCARD PLANS;

Intended to remove cached execution plans, though this is generally a no-op in MonkDB because it doesn't use cached plans the same way other DBMSs do.

DISCARD is usually used in backend applications, connection pools, or long-lived sessions to clean up resources. MonkDB doesn’t fully implement all Postgres-style session management features, so some DISCARD options may be placeholders or limited in utility.