Devin Dixon
Devin Dixon

Reputation: 12363

Postgres Prepared Transactions vs Prepared Statements

I'm fine tuning a Postgres database and I am about to set the maximun number of with prepared transactions with max_prepared_transactions.

The application uses a lot of prepared statements but not prepared transactions in the sense PREPARE name AS xyz.

My question is:

  1. Is there a difference between prepared statements and prepared transactions?
  2. Does max_prepared_transactions affect prepared statements?

Upvotes: 4

Views: 3937

Answers (1)

harmic
harmic

Reputation: 30577

  1. Yes. PREPARE TRANSACTION is used to initiate a two-phase transaction, which is generally used if you want to commit atomically to two databases at the same time.

    Prepared statements relate to requesting the server to plan an SQL statement ahead of time, usually so that you can execute the statement multiple times without the overhead of planning it each time. See PREPARE.

    The two are unrelated.

  2. No, max_prepared_transactions does not affect prepared statements.

Upvotes: 7

Related Questions