Re: Highly obscure and erratic - Mailing list pgsql-general

From Shaun Thomas
Subject Re: Highly obscure and erratic
Date
Msg-id Pine.LNX.4.44.0206190931560.16252-100000@hamster.lee.net
Whole thread Raw
In response to Highly obscure and erratic  (Varun Kacholia <varunk@cse.iitb.ac.in>)
List pgsql-general
On Wed, 19 Jun 2002, Varun Kacholia wrote:

> 1. SELECT * FROM dbmedia WHERE ID IN ((SELECT id FROM wdmedia WHERE
> word = 'whatever') )  LIMIT 20;

You probably didn't know this, but postgres is notorious for being
*very* bad at optimizing IN queries.  Try this instead:

SELECT * FROM dbmedia d WHERE EXISTS
  (SELECT 1 FROM wdmedia w WHERE w.id = d.id AND word = 'whatever')
 LIMIT 20;

--
+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+
| Shaun M. Thomas                INN Database Administrator           |
| Phone: (309) 743-0812          Fax  : (309) 743-0830                |
| Email: sthomas@townnews.com    AIM  : trifthen                      |
| Web  : www.townnews.com                                             |
|                                                                     |
|     "Most of our lives are about proving something, either to       |
|      ourselves or to someone else."                                 |
|                                           -- Anonymous              |
+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+



pgsql-general by date:

Previous
From: Shaun Thomas
Date:
Subject: Re: db grows and grows
Next
From: Richard Huxton
Date:
Subject: Re: pl/pgsql function not working