Re: Support prepared statement invalidation when result types change

Поиск
Список
Период
Сортировка
От Jelte Fennema-Nio
Тема Re: Support prepared statement invalidation when result types change
Дата
Msg-id CAGECzQQJTZAPqLfcLkTg7ftt=WFSJVdZAsfjriOOBwp9GN8KGA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Support prepared statement invalidation when result types change  (Shay Rojansky <roji@roji.org>)
Список pgsql-hackers
On Sun, 7 Jan 2024 at 07:55, vignesh C <vignesh21@gmail.com> wrote:
> One of the test has aborted in CFBot at [1] with:

Rebased the patchset and removed patch 0003 since it was causing the
CI issue reported by vignesh and it seems much less useful and more
controversial to me anyway (due to the extra required roundtrip).


On Sun, 7 Jan 2024 at 09:17, Shay Rojansky <roji@roji.org> wrote:
> Just to point out, FWIW, that the .NET Npgsql driver does indeed cache RowDescriptions... The whole point of
preparationis to optimize things as much as possible for repeated execution of the query; I get that the value there is
muchlower than e.g. doing another network roundtrip, but that's still extra work that's better off being cut if it can
be.

Hmm, interesting. I totally agree that it's always good to do less
when possible. The problem is that in the face of server side prepared
statement invalidations due to DDL changes to the table or search path
changes, the row types might change. Or the server needs to constantly
throw an error, like it does now, but that seems worse imho.

I'm wondering though if we can create a middleground, where a client
can still cache the RowDescription client side when no DDL or
search_patch changes are happening. But still tell the client about a
new RowDescription when they do happen.

The only way of doing that I can think of is changing the Postgres
protocol in a way similar to this: Allow Execute to return a
RowDescription too, but have the server only do so when the previously
received RowDescription for this prepared statement is now invalid.

This would definitely require some additional tracking at PgBouncer to
make it work, i.e. per client and per server it should now keep track
of the last RowDescription for each prepared statement. But that's
definitely something we could do.

This would make this patch much more involved though, as now it would
suddenly involve an actual protocol change, and that basically depends
on this patch moving forward[1].

[1]: https://www.postgresql.org/message-id/flat/CAGECzQTg2hcmb5GaU53uuWcdC7gCNJFLL6mnW0WNhWHgq9UTgw@mail.gmail.com

Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Nazir Bilal Yavuz
Дата:
Сообщение: Re: Use streaming read API in ANALYZE
Следующее
От: Amit Kapila
Дата:
Сообщение: Re: Introduce XID age and inactive timeout based replication slot invalidation