From: | Sam Mason <sam(at)samason(dot)me(dot)uk> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Slow select |
Date: | 2009-12-16 17:39:47 |
Message-ID: | 20091216173947.GQ5407@samason.me.uk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Wed, Dec 16, 2009 at 04:56:16AM -0800, yuliada wrote:
> I have a table with column of character varying(100). There are about
> 150.000.000 rows in a table. Index was created as
>
> CREATE INDEX idx_stringv
> ON bn_stringvalue
> USING btree
> (lower(value::text));
>
> I'm trying to execute queries like 'select * from stringvalue where
> value=lower(?)'.
Wouldn't this be "lower(value) = lower(?)" ?
> Making 1000 selects takes about 4-5 min.
So each query is taking approx 300ms? How much data does each one
return?
> I did vacuum and
> analyze on this table and checked that query plan uses index. What can I do
> to make it faster?
How about combining all 1000 selects into one? Maybe something like:
SELECT * FROM stringvalue
WHERE lower(value) = ANY (ARRAY ['a','b','c']);
--
Sam http://samason.me.uk/
From | Date | Subject | |
---|---|---|---|
Next Message | Mihamina Rakotomandimby | 2009-12-16 18:04:45 | Re: Counts and percentages and such |
Previous Message | Grzegorz Jaśkiewicz | 2009-12-16 17:39:04 | Re: Slow select |