pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tomas Vondra <tomas.vondra@2ndquadrant.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
To: Eric Jiang <eric@doublemap.com>
Cc: pgsql-performance@postgresql.org, Eric Clark <eclark@doublemap.com>
Subject: Re: Querying with multicolumn index
Date: Sat, 10 Dec 2016 21:34:18 +0100
Message-ID: <b92cec0d-c4b2-5e44-a6b9-949d2b93e935@2ndquadrant.com> (raw)
In-Reply-To: <5353.1481327501@sss.pgh.pa.us>
References: <CAOfJSTwzQ7Fx6Yjeg9mFkMsM5OVKPoa=EgkHceGdkr1TWg8vkA@mail.gmail.com>
	<5353.1481327501@sss.pgh.pa.us>
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-performance>

Hi,

On 12/10/2016 12:51 AM, Tom Lane wrote:
> Eric Jiang <eric@doublemap.com> writes:
>> I have a query that I *think* should use a multicolumn index, but
>> sometimes isn't, resulting in slow queries.
>
> I tried to duplicate this behavior, without success.  Are you running
> with nondefault planner parameters?
>

My guess is this is a case of LIMIT the matching rows are uniformly 
distributed in the input data. The planner likely concludes that for a 
driver with a lot of data we'll find the first row using ix_updates_time 
very quickly, and that it will be cheaper than inspecting the larger 
multi-column index. But imagine a driver with a lots of data long time 
ago. That breaks the LIMIT fairly quickly.

regards

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


-- 
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance



view thread (12+ messages)  latest in thread

Message-ID: <b92cec0d-c4b2-5e44-a6b9-949d2b93e935@2ndquadrant.com>
Permalink:  ../b92cec0d-c4b2-5e44-a6b9-949d2b93e935@2ndquadrant.com/
Also on:    postgresql.org/message-id/b92cec0d-c4b2-5e44-a6b9-949d2b93e935@2ndquadrant.com

 · 

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, tgl@sss.pgh.pa.us, eric@doublemap.com, eclark@doublemap.com
  Subject: Re: Querying with multicolumn index
  In-Reply-To: <b92cec0d-c4b2-5e44-a6b9-949d2b93e935@2ndquadrant.com>

* 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