public inbox for pgsql-general@postgresql.org  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Igor Korot <ikorot01@gmail.com>
Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: Double prepare
Date: Sat, 16 May 2026 09:46:27 -0400
Message-ID: <1495292.1778939187@sss.pgh.pa.us> (raw)
In-Reply-To: <CA+FnnTycS2E-Bb7Wm+-mmTXwRQ-t4Wyfg=S2Upysf-zF0ty_2w@mail.gmail.com>
References: <CA+FnnTycS2E-Bb7Wm+-mmTXwRQ-t4Wyfg=S2Upysf-zF0ty_2w@mail.gmail.com>

Igor Korot <ikorot01@gmail.com> writes:
> Is there a way to see if the query has been prepared already (in libpq)?

Use the pg_prepared_statements view.  I don't think libpq keeps any
client-side state about this.

> Or is it better to run PQprepare for all known parameterized queries
> in the very beginning of the program and just execute them when needed?

Very probably.  Querying pg_prepared_statements every time would be
expensive.

			regards, tom lane





reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, ikorot01@gmail.com, pgsql-general@lists.postgresql.org
  Subject: Re: Double prepare
  In-Reply-To: <1495292.1778939187@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox