Re: Big table - using wrong index - why? - Mailing list pgsql-sql

From Joe Conway
Subject Re: Big table - using wrong index - why?
Date
Msg-id 01d501c11916$b81603f0$48d210ac@jecw2k1
Whole thread Raw
In response to Big table - using wrong index - why?  ("Chris Ruprecht" <chrup999@yahoo.com>)
List pgsql-sql
> phones=# \d i_pl_pseq
>         Index "i_pl_pseq"
>  Attribute |         Type
> -----------+----------------------
>  entity    | character varying(3)
>  pseq      | bigint
> btree
>
> phones=# explain select * from phonelog where entity = '001' and pseq >=
> 9120 and pseq <= 9123;
> NOTICE:  QUERY PLAN:
>
> Index Scan using i_pl_loadtimestamp on phonelog  (cost=0.00..209247.39
> rows=607 width=137)
>
> EXPLAIN
>
> phones=# \d i_pl_loadtimestamp
>     Index "i_pl_loadtimestamp"
>  Attribute |         Type
> -----------+----------------------
>  entity    | character varying(3)
>  loaddate  | date
>  loadtime  | time
> btree

Just a guess, but what happens if you build i_pl_pseq(pseq, entity), i.e.
reverse the key fields? Also, has the table been vacuum analyzed?

-- Joe





pgsql-sql by date:

Previous
From: Jan Wieck
Date:
Subject: Re: Why does this plpgslq always return 1?
Next
From: "John Oakes"
Date:
Subject: plpgsql function return multiple values?