Re: Slow date comparison

From: Andrew McMillan <Andrew(at)catalyst(dot)net(dot)nz>
To: rudy <rudy(at)heymax(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Slow date comparison
Date: 2001-01-30 19:15:33
Message-ID: 3A7712D5.AE688647@catalyst.net.nz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

rudy wrote:
>
> Running Red Hat 7.0 kernel 2.2.16
> PostgreSQL 7.0.3
> Front End App is Cold Fusion
>
> We only have about 22000 rows in the article table and it will grow quite a bit
> larger.
> When I turn debugging on (cold fusion) this query takes a while. Almost 3
> sec...
>
> rstDispThread (Records=6, Time=2982ms)
> SQL =
> SELECT a.id_article,
> a.subject,
> getNumPostsInThread(a.id_article,0) AS numPosts,
> isThreadNew(a.id_article,'2001-01-2617:28:37',0) AS intThreadNew,
> a.is_hidden,
> a.is_locked,
> a.reply_to
> FROM ARTICLE a, USER_TAB ut
> WHERE a.id_article IN (75254,76255,79262,84264,94273,94277)
> AND a.author = ut.id_user
> ORDER BY a.date_create ASC

Don't use IN ( ... ), use EXISTS.

See the FAQ for more details, but IN won't use an index.

Cheers,
Andrew.
--
_____________________________________________________________________
Andrew McMillan, e-mail: Andrew(at)catalyst(dot)net(dot)nz
Catalyst IT Ltd, PO Box 10-225, Level 22, 105 The Terrace, Wellington
Me: +64 (21) 635 694, Fax: +64 (4) 499 5596, Office: +64 (4) 499 2267

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Andrew McMillan 2001-01-30 19:20:25 Re: truncated numeric data
Previous Message Alfred Perlstein 2001-01-30 19:10:40 Re: Best WebInterface...?