Re: Why is the wrong index used? (with "gist" index)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Christian Hammers <ch(at)lathspell(dot)de>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Why is the wrong index used? (with "gist" index)
Date: 2012-09-17 17:23:37
Message-ID: 17994.1347902617@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Christian Hammers <ch(at)lathspell(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Dann Corbit 2012-09-17 17:59:55 Re: Slow counting still true?
Previous Message Christian Hammers 2012-09-17 16:25:06 Why is the wrong index used? (with "gist" index)