Re: slow query - Mailing list pgsql-performance

From Josh Berkus
Subject Re: slow query
Date
Msg-id 200302231252.30681.josh@agliodbs.com
Whole thread Raw
In response to slow query  (Oleg Lebedev <oleg.lebedev@waterford.org>)
Responses Re: slow query  (Ryan Bradetich <rbradetich@uswest.net>)
List pgsql-performance
Oleg,

> I VACUUM ANALYZED both databases and made sure they have same indexes on
> the tables.

Have you VACUUM FULL the main database?  And how about REINDEX?

> Here is the query:
> SELECT * FROM media m, speccharacter c
> WHERE m.mediatype IN (SELECT objectid FROM mediatype WHERE
> medianame='Audio')

The above should use an EXISTS clause, not IN, unless you are absolutely sure
that the subquery will never return more than 12 rows.

--
Josh Berkus
Aglio Database Solutions
San Francisco

pgsql-performance by date:

Previous
From: Josh Berkus
Date:
Subject: Re: performance issues for processing more then 150000
Next
From: Ryan Bradetich
Date:
Subject: Re: slow query