Re: Optimizer: limit not taken into account - Mailing list pgsql-performance

From Tom Lane
Subject Re: Optimizer: limit not taken into account
Date
Msg-id 24245.1147890622@sss.pgh.pa.us
Whole thread Raw
In response to Re: Optimizer: limit not taken into account  (Bruno Wolff III <bruno@wolff.to>)
Responses Re: Optimizer: limit not taken into account
List pgsql-performance
Bruno Wolff III <bruno@wolff.to> writes:
> I suspect it wasn't intended to be a full table scan. But rather a sequential
> scan until it found a matching row. If the data in the table is ordered by
> by id, this strategy may not work out well. Where as if the data is randomly
> ordered, it would be expected to find a match quickly.

Right.  You can see from the differential in the estimates for the
SeqScan and the Limit nodes that the planner is not expecting the
seqscan to run to completion, but rather to find a matching row quite
quickly.

There is not anything in there that considers whether the table's
physical order is so nonrandom that the search will take much longer
than it would given uniform distribution.  It might be possible to do
something with the correlation statistic in simple cases ...

            regards, tom lane

pgsql-performance by date:

Previous
From: Simon Riggs
Date:
Subject: Re: Optimizer: limit not taken into account
Next
From: "Craig A. James"
Date:
Subject: Re: Optimizer: limit not taken into account