Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Postgres Prepared Transactions vs Prepared Statements

Tags:

postgresql

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?
like image 478
Devin Dixon Avatar asked Mar 16 '23 00:03

Devin Dixon


1 Answers

  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.

like image 50
harmic Avatar answered Apr 13 '23 00:04

harmic