Re: WHERE with ORDER not using the best index

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



jugnooken <ken@xxxxxxxxxx> writes:
> Unfortunately, pg still thinks using
> index_social_feed_feed_items_on_social_feed_id is faster although they are
> about the same size :(. Any idea?

On further reflection, the cost estimate that is weird for this number of
rows is not the large one for your preferred index, but the small estimate
for the one the planner likes.  My guess is that that must be happening
because the latter index is nearly perfectly correlated with the table's
physical order, whereas yours is more or less random relative to table
order.

The fact that the former index is actually faster in use means that in
your environment, random access into the table is pretty cheap, which
means you should consider decreasing random_page_cost.  But first it'd
be a good idea to confirm that your test case is actually representative
of production behavior --- it's very easy to get fooled by all-in-cache
measurements, which are not reliable guides unless your database does in
fact fit in RAM.

			regards, tom lane


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




[Postgresql General]     [Postgresql PHP]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Yosemite]

  Powered by Linux