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

2019-01-08 Thread David Rowley
On Tue, 8 Jan 2019 at 06:45, Mitar wrote: > So it could learn that the values used are not distinct values, or > that column values are not uniformly distributed? And maybe decide to > change the plan? So it makes a plan, runs it, determines that the plan > was not as good as expected, I run it ag

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

2019-01-07 Thread Mitar
Hi! On Mon, Jan 7, 2019 at 12:44 AM David Rowley wrote: > 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? For example, it could learn better statistics. In documentation [1] it is wr

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

2019-01-07 Thread David Rowley
On Mon, 7 Jan 2019 at 21:40, Mitar wrote: > > On Mon, Jan 7, 2019 at 12:09 AM David Rowley > wrote: > > On Mon, 7 Jan 2019 at 18:54, Mitar wrote: > > > If I have a PREPAREd query without parameters (static) and I EXECUTE > > > it repeatedly in the same session, does PostgreSQL learn/optimize > >

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

2019-01-07 Thread Mitar
Hi! On Mon, Jan 7, 2019 at 12:09 AM David Rowley wrote: > On Mon, 7 Jan 2019 at 18:54, Mitar 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 gene

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

2019-01-07 Thread David Rowley
On Mon, 7 Jan 2019 at 18:54, Mitar 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 p

Optimizing the same PREPAREd static query (without parameters)

2019-01-06 Thread Mitar
Hi! 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? Mitar -- http://mitar.tnode.com/ https://twitter.com/mitar_m