Re: Incorrect assumptions with low LIMITs

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Simon Riggs <simon(at)2ndQuadrant(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Incorrect assumptions with low LIMITs
Date: 2012-03-16 21:11:38
Message-ID: 21171.1331932298@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Simon Riggs <simon(at)2ndQuadrant(dot)com> writes:
> 2. We assume that if values do exist that they have rows uniformly
> distributed across the whole table like rungs on a ladder.

Well, yeah. That's sometimes wrong, but not always. In the absence
of evidence to the contrary, I think it's a better assumption than
most others.

> Any time we apply a LIMIT clause to a plan with a SeqScan or
> unqualified IndexScan, we shouldn't assume the scan will do less than
> say 10% of the table.

This is a horrid idea, because it will stop the planner from using
fast-start plans in many situations where they are wins.

> Other ideas welcome.

You are not the first person to have run into this type of problem.
If it were easily solved by some minor hack, we would have done that
long since. The problem is to not throw the baby out with the
bathwater.

I can see an argument for downgrading the assumed effectiveness of
restrictions that are applied as qpquals (ie, not indexquals), but
the LIMIT node coster doesn't have easy access to the information
needed for that, especially not in situations more complicated than
a single-table scan.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2012-03-16 21:31:57 Re: Command Triggers, patch v11
Previous Message Andres Freund 2012-03-16 21:07:23 Re: Command Triggers, patch v11