Re: Why is PostgreSQL 9.1 not using index for simple equality select

From: Yang Zhang <yanghatespam(at)gmail(dot)com>
To: John R Pierce <pierce(at)hogranch(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Why is PostgreSQL 9.1 not using index for simple equality select
Date: 2013-04-12 08:45:15
Message-ID: CAKxBDU-vqLkpeL95ga4MrVG6f-0oyQT91e1G_MgMtmUe-jp-kg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Doesn't seem to be the case. This table has been around for a while
and should have been auto-analyzed by now. But anyway:

db=> analyze lead;
ANALYZE
db=> explain select * from lead where email = 'foo(at)blah(dot)com';
QUERY PLAN
---------------------------------------------------------------------------
Seq Scan on lead (cost=10000000000.00..10000319666.99 rows=1 width=5208)
Filter: (email = 'foo(at)blah(dot)com'::text)
(2 rows)

On Fri, Apr 12, 2013 at 1:13 AM, John R Pierce <pierce(at)hogranch(dot)com> wrote:
> On 4/12/2013 1:03 AM, Yang Zhang wrote:
>>
>> db=> explain select * from lead where email = 'blah';
>> QUERY PLAN
>> ------------------------------------------------------------
>> Seq Scan on lead (cost=0.00..319599.38 rows=1 width=5108)
>> Filter: (email = 'blah'::text)
>
>
>
> try EXPLAIN ANALYZE ..... its more useful.
>
> my guess is, there's no statistics on this table, and doing an ANALYZE lead;
> would rectify this.
>
>
>
> --
> john r pierce 37N 122W
> somewhere on the middle of the left coast
>
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general

--
Yang Zhang
http://yz.mit.edu/

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message stephane.schildknecht 2013-04-12 08:48:20 Automatic restart while upgrade
Previous Message John R Pierce 2013-04-12 08:13:59 Re: Why is PostgreSQL 9.1 not using index for simple equality select