[repost] partial index / funxtional idx or bad sql?

From: csajl <csajl(at)yahoo(dot)com>
To: pgsql-performance(at)postgresql(dot)org
Subject: [repost] partial index / funxtional idx or bad sql?
Date: 2003-05-13 00:07:46
Message-ID: 20030513000746.70481.qmail@web40301.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance


my apologies - a strange key combination sent the message early.

----
greetings.

i have a query that is taking a rather long time to execute and have been
looking into setting up a partial index to help, although i'm not sure if this
is what i want.

here is the (simplified) table "posts":

id serial
type_id int
areacode smallint
content text

and the other table (areacodes) referenced:

site_id smallint
areacode smallint

the query is:

SELECT p.id, p.areacode, p.content
FROM posts p
WHERE p.type_id = ?
AND p.areacode in (
select areacode from areacodes
where site_id = ?
)

the "posts" table has 100,000 rows of varying data, across areacodes and types.
given the type_id and site_id, the query is currently taking ~4 seconds to
return 8500 rows (on a dual proc/ gig ram linux box).

indexes on table "posts" are:
primary key (id)
and another on both (type_id, areacode)

index on the table "areacodes" is (site_id, areacode).

would a parital index help in speeding up this query?
are my current indexes counter productive?
or is it just my sql that need help?

thanks much for any help or pointers to information.

- seth

__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Josh Berkus 2003-05-13 00:13:38 Re: [repost] partial index / funxtional idx or bad sql?
Previous Message csajl 2003-05-12 23:51:00 partial index / funxtional idx or bad sql?