public inbox for pgsql-general@postgresql.org  
help / color / mirror / Atom feed
From: Igor Korot <ikorot01@gmail.com>
To: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Double prepare
Date: Sat, 16 May 2026 01:40:32 -0500
Message-ID: <CA+FnnTycS2E-Bb7Wm+-mmTXwRQ-t4Wyfg=S2Upysf-zF0ty_2w@mail.gmail.com> (raw)

Hi, ALL,
Is there a way to see if the query has been prepared already (in libpq)?

Trying to avoid a following scenario (pseudo-code):

[code]
int main()
{
    test();
    test();
}

void test()
{
    PGresult *res = PQprepare( conn, "my query", "SELECT * FROM
my_table", /* rest of params */ );
    PQclear( res );
}
[/code]

I presume there is a penalty for that even if the code succeeds.

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?

Thank you.





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: ikorot01@gmail.com, pgsql-general@lists.postgresql.org
  Subject: Re: Double prepare
  In-Reply-To: <CA+FnnTycS2E-Bb7Wm+-mmTXwRQ-t4Wyfg=S2Upysf-zF0ty_2w@mail.gmail.com>

* 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