| From: | Rob Sargent <robjsargent(at)gmail(dot)com> |
|---|---|
| To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
| Cc: | Igor Korot <ikorot01(at)gmail(dot)com>, "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: Double prepare |
| Date: | 2026-05-16 14:07:01 |
| Message-ID: | 02D2D7C5-7932-4030-B65A-4BECB645E9F0@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
> On May 16, 2026, at 7:46 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> Igor Korot <ikorot01(at)gmail(dot)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 for all known parameterized queries
>> in the very beginning of the program and just execute them when needed?
>
> Very probably. Querying every time would be
> expensive.
>
If I am following correctly, one may query pg_prepared_statements with a specific query in hand. Should it not then be possible to cache that query as having been planned/prepared and proceed accordingly?
Might there be value in calling PQprepare as late as possible against most up-to-dare data?
>
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Vladimir Sitnikov | 2026-05-16 14:31:49 | Re: Double prepare |
| Previous Message | Tom Lane | 2026-05-16 13:46:27 | Re: Double prepare |