[pgpool-general: 8400] Re: Extended query and cache

Avi Raboah avi.raboah at gmail.com
Wed Sep 14 20:04:21 JST 2022


Hi,
I am not sure I understood what you mean when you mentioned “close message”

But i’ll try to ask you in a different way.

Let look on the following example:

1. Select * from users where id = $1; using extended query. —> miss

2. Now in case i’ll run the same query i’ll get it back from cache.

So I am understanding why the parse message should be pass to the backend
and not read the result from cache due to that Parse message didn’t
contains the query params. That’s make sense.

But in Bind message the packet already contains the query params. So why
you can’t read the result from cache here and we need to wait to the
execute message?

One more question is why we need to send the bind message anyway to the
backend in case we have already the result of the execute message in cache?

I am asking the above questions because I am looking in the rds performance
insights.
And I can see that in case I am sending a lot of queries concurrently when
I have cache enabled I can see a very big wait because of a lot of
connections in idle ClientRead wait event.

And I am asking myself why the db needs to know about queries we already
have in cache?

Hope it was clear.


Thanks a lot,

Avi



On Wed, 14 Sep 2022 at 2:42 Tatsuo Ishii <ishii at sraoss.co.jp> wrote:

> > Hi,
> >
> > In case query already cached, why in extended query mode the db knows
> about
> > that query?
> > Because in that case pgpool should return the result from the cache in
> > order to save db resources.
> > But I found that although we have the query in cache pgpool still send
> > parse and bind request to the db.
> >
> > Please share your thoughts 🙏
>
> Yes, Pgpool-II only caches the result of execute message. The main
> reason is, to not return stale cache.  After receiving a close message
> for the statement or the portal that is bound to the execute message,
> the cache for the execute message should not be returned. When
> Pgpool-II receives close messages, they remove the internal record of
> previpusly received statement or portal. When an execute message
> arrives, Pgpool-II checks whether the record for the execute message
> exists. If does not, the request fails. This strategy is simple but
> works well.
>
> I think the saving by caching parse message is not small for
> especially complex queries. But in this case users already reuse the
> prepared statement anyway.
>
> I think the saving of bind message is usually small because it does
> not involve planning in most cases.
>
> Best reagards,
> --
> Tatsuo Ishii
> SRA OSS LLC
> English: http://www.sraoss.co.jp/index_en/
> Japanese:http://www.sraoss.co.jp
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.pgpool.net/pipermail/pgpool-general/attachments/20220914/20c5efc9/attachment.htm>


More information about the pgpool-general mailing list