Re: Optimizing the same PREPAREd static query (without parameters)

From: David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>
To: Mitar <mmitar(at)gmail(dot)com>
Cc: "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Optimizing the same PREPAREd static query (without parameters)
Date: 2019-01-07 08:08:49
Message-ID: CAKJS1f-oH6BOMgfDMveMd69TDuaxVn8eK0+eWmBv1s9bDmPV-g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, 7 Jan 2019 at 18:54, Mitar <mmitar(at)gmail(dot)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;

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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Mitar 2019-01-07 08:40:38 Re: Optimizing the same PREPAREd static query (without parameters)
Previous Message Achilleas Mantzios 2019-01-07 07:35:44 Re: Use bytearray for blobs or not?