pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tomas Vondra <tomas.vondra@2ndquadrant.com>
To: Behrang Saeedzadeh <behrangsa@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-performance@lists.postgresql.org
Subject: Re: Slow PostgreSQL 10.6 query
Date: Sun, 6 Oct 2019 22:37:53 +0200
Message-ID: <20191006203753.wobkgsg625ej7k2m@development> (raw)
In-Reply-To: <CAERAJ+_C981pYAbjZm8Eqn2p+9uk2XJWaL7D934doP3+97+dUw@mail.gmail.com>
References: <CAERAJ+-1buiJ+_JWEo0a9Ao-CVMWpgp=EnFx1dJtnB3WmMi2zQ@mail.gmail.com>
	<9624.1569936426@sss.pgh.pa.us>
	<CAERAJ+_C981pYAbjZm8Eqn2p+9uk2XJWaL7D934doP3+97+dUw@mail.gmail.com>

On Tue, Oct 01, 2019 at 11:42:33PM +1000, Behrang Saeedzadeh wrote:
>Thanks. That eliminated the bottleneck!
>
>Any ideas why adding ORDER BY to the subquery also changes the plan in a
>way that eliminates the bottleneck?
>

IIRC the ORDER BY clause makes it impossible to "collapse" the subquery
into the main (upper) one, and it probably happens to constrict the
choices so that the planner ends up picking a good plan. I guess adding
"OFFSET 0" to the subquery would have the same effect.


regards

-- 
Tomas Vondra                  http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services 





view thread (5+ messages)  latest in thread

Message-ID: <20191006203753.wobkgsg625ej7k2m@development>
Permalink:  ../20191006203753.wobkgsg625ej7k2m@development/
Also on:    postgresql.org/message-id/20191006203753.wobkgsg625ej7k2m@development

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: tomas.vondra@2ndquadrant.com, behrangsa@gmail.com, tgl@sss.pgh.pa.us, pgsql-performance@lists.postgresql.org
  Subject: Re: Slow PostgreSQL 10.6 query
  In-Reply-To: <20191006203753.wobkgsg625ej7k2m@development>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox