Re: Why is the wrong index used? (with "gist" index) - Mailing list pgsql-general

From Tom Lane
Subject Re: Why is the wrong index used? (with "gist" index)
Date
Msg-id 17994.1347902617@sss.pgh.pa.us
Whole thread Raw
In response to Why is the wrong index used? (with "gist" index)  (Christian Hammers <ch@lathspell.de>)
List pgsql-general
Christian Hammers <ch@lathspell.de> writes:
> Just because I added a "LIMIT 1" to the following query, PostgreSQL decided to
> use a different index which gives a far worse performance :-(

The problem is the off-by-four-orders-of-magnitude rowcount estimate
(20949 rows estimated to match, only 2 actually do).  You need to get
that to be closer to reality.  I'm not sure if increasing the statistics
target would help --- it depends on whether the prefix extension has any
non-dummy selectivity estimation support.  If not, you might want to
consider switching to a more-fully-supported data type.

            regards, tom lane


pgsql-general by date:

Previous
From: Christian Hammers
Date:
Subject: Why is the wrong index used? (with "gist" index)
Next
From: Dann Corbit
Date:
Subject: Re: Slow counting still true?