LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • LangGraph Checkpoint
    Checkpoint Postgres
    Store Postgres
    Checkpoint SQLite
    LangGraph Prebuilt
    LangGraph CLI
    LangGraph SDK
    LangGraph Supervisor
    LangGraph Swarm
    ⌘I

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

    LangGraph Checkpoint
    Checkpoint Postgres
    Store Postgres
    Checkpoint SQLite
    LangGraph Prebuilt
    LangGraph CLI
    LangGraph SDK
    LangGraph Supervisor
    LangGraph Swarm
    Language
    Theme
    Pythonlanggraph.checkpoint.postgresPostgresSaver
    Class●Since v1.0

    PostgresSaver

    Checkpointer that stores checkpoints in a Postgres database.

    Copy
    PostgresSaver(
      self,
      conn: _internal.Conn,
      pipe: Pipeline | None = None,
      serde: SerializerProtocol | 

    Bases

    BasePostgresSaver

    Used in Docs

    • Memory
    • Persistence
    • Short-term memory

    Constructors

    Attributes

    Methods

    Inherited fromBasePostgresSaver

    Attributes

    ASELECT_SQL: SELECT_SQLASELECT_PENDING_SENDS_SQL: SELECT_PENDING_SENDS_SQLAMIGRATIONS: MIGRATIONSAUPSERT_CHECKPOINT_BLOBS_SQL: UPSERT_CHECKPOINT_BLOBS_SQL
    View source on GitHub
    None
    =
    None
    )
    AUPSERT_CHECKPOINTS_SQL: UPSERT_CHECKPOINTS_SQL
    AUPSERT_CHECKPOINT_WRITES_SQL: UPSERT_CHECKPOINT_WRITES_SQL
    AINSERT_CHECKPOINT_WRITES_SQL: INSERT_CHECKPOINT_WRITES_SQL

    Methods

    Mget_next_version
    constructor
    __init__
    NameType
    conn_internal.Conn
    pipePipeline | None
    serdeSerializerProtocol | None
    attribute
    lock: threading.Lock
    attribute
    conn: conn
    attribute
    pipe: pipe
    attribute
    supports_pipeline
    method
    from_conn_string
    method
    setup
    method
    list
    method
    get_tuple
    method
    put
    method
    put_writes
    method
    delete_thread
    method
    get_delta_channel_history

    Create a new PostgresSaver instance from a connection string.

    Set up the checkpoint database asynchronously.

    This method creates the necessary tables in the Postgres database if they don't already exist and runs database migrations. It MUST be called directly by the user the first time checkpointer is used.

    List checkpoints from the database.

    This method retrieves a list of checkpoint tuples from the Postgres database based on the provided config. The checkpoints are ordered by checkpoint ID in descending order (newest first).

    Get a checkpoint tuple from the database.

    This method retrieves a checkpoint tuple from the Postgres database based on the provided config. If the config contains a checkpoint_id key, the checkpoint with the matching thread ID and timestamp is retrieved. Otherwise, the latest checkpoint for the given thread ID is retrieved.

    Save a checkpoint to the database.

    This method saves a checkpoint to the Postgres database. The checkpoint is associated with the provided config and its parent config (if any).

    Store intermediate writes linked to a checkpoint.

    This method saves intermediate writes associated with a checkpoint to the Postgres database.

    Delete all checkpoints and writes associated with a thread ID.

    Fast-path override of BaseCheckpointSaver.get_delta_channel_history.

    Two-stage query, both stages cover ALL requested channels:

    • Stage 1 (paged): dynamic SELECT over checkpoints with K parallel JSONB key lookups (one column pair per channel) — no subquery, no aggregation. Pages newest-first by checkpoint_id with a cursor; page size is _DELTA_PAGE_SIZE. Stops paging when every channel has found its seed or the chain is exhausted.

    • Stage 2 (per-channel UNION ALL): one branch per channel reading checkpoint_writes filtered to that channel's specific chain_cids, plus one branch per channel that has a seed reading checkpoint_blobs for that channel + version. Avoids the over-fetch of a single channel = ANY(channels) filter when channels have different chain depths.