Re: [SQL] Yet Another (Simple) Case of Index not used

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: "Denis (at) Next2Me" <denis(at)next2me(dot)com>
Cc: <josh(at)agliodbs(dot)com>, <pgsql-performance(at)postgresql(dot)org>
Subject: Re: [SQL] Yet Another (Simple) Case of Index not used
Date: 2003-04-09 01:59:37
Message-ID: 20030408185412.C57783-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-performance pgsql-sql


On Tue, 8 Apr 2003, Denis @ Next2Me wrote:

> The kind of requests that I am really interested in are:
> select count(*) from table where table.column like 'pattern%'

If you think an index scan should be faster, you can try
set enable_seqscan=off;
and see if that changes the plan generated by explain and with analyze
you can compare the time used. Without information on the estimated
selectivity it's hard to say what's right.

If it doesn't use the index (ie, it's still using a sequential scan)
after the enable_seqscan=off it's likely that you didn't initdb in "C"
locale in which case like won't use indexes currently (you can see the
archives for long description, but the short one is that some of the
locale rules can cause problems with using the index).

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Christopher Kings-Lynne 2003-04-09 02:35:22 Re: [SQL] Yet Another (Simple) Case of Index not used
Previous Message Neil Conway 2003-04-09 01:08:04 Re: How does PostgreSQL treat null values in unique

Browse pgsql-performance by date

  From Date Subject
Next Message Christopher Kings-Lynne 2003-04-09 02:35:22 Re: [SQL] Yet Another (Simple) Case of Index not used
Previous Message Brent Wood 2003-04-09 00:44:48 Re: Yet Another (Simple) Case of Index not used

Browse pgsql-sql by date

  From Date Subject
Next Message Christopher Kings-Lynne 2003-04-09 02:35:22 Re: [SQL] Yet Another (Simple) Case of Index not used
Previous Message Brent Wood 2003-04-09 00:44:48 Re: Yet Another (Simple) Case of Index not used