Re: Optimizing the same PREPAREd static query (without parameters) - Mailing list pgsql-general

From David Rowley
Subject Re: Optimizing the same PREPAREd static query (without parameters)
Date
Msg-id CAKJS1f8E_LU7RtsCuN+ezFBLXTZLf3726aNDf6McaUw3twGd3g@mail.gmail.com
Whole thread Raw
In response to Re: Optimizing the same PREPAREd static query (without parameters)  (Mitar <mmitar@gmail.com>)
Responses Re: Optimizing the same PREPAREd static query (without parameters)  (Mitar <mmitar@gmail.com>)
List pgsql-general
On Mon, 7 Jan 2019 at 21:40, Mitar <mmitar@gmail.com> wrote:
>
> On Mon, Jan 7, 2019 at 12:09 AM David Rowley
> <david.rowley@2ndquadrant.com> wrote:
> > On Mon, 7 Jan 2019 at 18:54, Mitar <mmitar@gmail.com> wrote:
> > > If I have a PREPAREd query without parameters (static) and I EXECUTE
> > > it repeatedly in the same session, does PostgreSQL learn/optimize
> > > anything across those runs?
> >
> > Yes, it will generate the query plan on the first invocation of
> > EXECUTE and use that plan for all subsequent EXECUTEs for the session
> > until you DEALLOCATE the prepared query or DISCARD PLANS/ALL;
>
> So this sounds more like no? So the same plan is used, so PostgreSQL
> is not further optimizing the plan based on any statistics or
> anything?

You asked if it learned anything. I mentioned that it learns the query
plan, so I'd have said "Yes".

If you're asking if it caches the result and foregoes scanning the
underlying tables, then that's a  "No". Else what further optimising
did you have in mind?

-- 
 David Rowley                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services


pgsql-general by date:

Previous
From: Mitar
Date:
Subject: Re: Optimizing the same PREPAREd static query (without parameters)
Next
From: Thomas Güttler
Date:
Subject: Re: Use bytearray for blobs or not?