dbTalk Databases Forums  

indexed column but queries still slow

comp.databases.postgresql.novice comp.databases.postgresql.novice


Discuss indexed column but queries still slow in the comp.databases.postgresql.novice forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Amir Zicherman
 
Posts: n/a

Default indexed column but queries still slow - 08-17-2004 , 04:06 PM






hi,

i have a btree index on col1 in table1. The column has either values
1,2,3, or 4. 4 does not appear that much in the table (only 5 times).
there are about 20 million rows in the table. when i do a "select *
from table1 where col1=4" it takes very long time to get back to me
(around 4 minutes). why is it taking so long if i have an index on
it? I also tried this with a hash index and it was still slow.

thanx, amir

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings


Reply With Quote
  #2  
Old   
Gaetano Mendola
 
Posts: n/a

Default Re: indexed column but queries still slow - 08-17-2004 , 06:28 PM






Amir Zicherman wrote:

Quote:
hi,

i have a btree index on col1 in table1. The column has either values
1,2,3, or 4. 4 does not appear that much in the table (only 5 times).
there are about 20 million rows in the table. when i do a "select *
from table1 where col1=4" it takes very long time to get back to me
(around 4 minutes). why is it taking so long if i have an index on
it? I also tried this with a hash index and it was still slow.
May I see the result of
explain analyze select * from table1 where col1 = 4;

and also the table definition could be usefull.

Did you run recently an analyze on your table ?


Regards
Gaetano Mendola


Reply With Quote
  #3  
Old   
Bruno Wolff III
 
Posts: n/a

Default Re: indexed column but queries still slow - 08-18-2004 , 01:18 PM



On Tue, Aug 17, 2004 at 14:06:11 -0700,
Amir Zicherman <amir.zicherman (AT) gmail (DOT) com> wrote:
Quote:
hi,

i have a btree index on col1 in table1. The column has either values
1,2,3, or 4. 4 does not appear that much in the table (only 5 times).
there are about 20 million rows in the table. when i do a "select *
from table1 where col1=4" it takes very long time to get back to me
(around 4 minutes). why is it taking so long if i have an index on
it? I also tried this with a hash index and it was still slow.
With that kind of distribution, you may be better off with a partial
index on the table for col1=4 instead of the current index. If the
other values show up with roughly equal frequency, you aren't going to
want an index scan to be used anyway, so you might as well use the
smaller partial index.

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.