Re: subselect requires offset 0 for good performance.

From: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>
To: Vik Fearing <vik(dot)fearing(at)dalibo(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org>
Subject: Re: subselect requires offset 0 for good performance.
Date: 2013-08-13 21:01:26
Message-ID: CAOR=d=0S6NqnX=TfX1=81M442=LM6QaN1fy7FHowVCfVskipOg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

OK I'm bumping this one last time in the hopes that someone has an
idea what to do to fix it.

Query plan: http://explain.depesz.com/s/kJ54

This query takes 180 seconds. It loops 17391 times across the lower
index using entries from the upper index. That seems buggy to me.
While the exact estimates are off, the fact that it estimates 10,433
rows in the above index scan means that it's expecting to do that many
loops on the bottom index scan.

This is one of those queries where adding an offset 0 to the inner
select reduces run time from 180s to 0.2s. And I can't imagine a plan
that thinks running 10k loops on an index scan is a good idea.

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Tom Lane 2013-08-13 22:50:50 Re: subselect requires offset 0 for good performance.
Previous Message Daniel Cristian Cruz 2013-08-13 20:47:52 Index on a range array