Re: slow queries, possibly disk io

From: Josh Close <narshe(at)gmail(dot)com>
To: POSTGRES-PERFORMANCE <pgsql-performance(at)postgresql(dot)org>
Subject: Re: slow queries, possibly disk io
Date: 2005-05-27 14:54:52
Message-ID: 4a0cafe205052707541373ab8a@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

> I think you really want that seqscan to be an indexscan, instead.
> I'm betting this is PG 7.4.something? If so, probably the only
> way to make it happen is to simplify the now() expression to a constant:
>
> SELECT COALESCE( SUM( iNumSent ), 0 ) AS iNumSent
> FROM adaption.tblBatchHistory_\' || this_rServerIds.iId || \'
> WHERE tStamp > \\\'' || (now() - interval \'5 mins\')::text ||
> \'\\\'\';

The dollar sign thing would be a lot easier. I can't get this to work.
I'm using a db manager where I can just use ' instead of \'. How would
it look for that? In other words, it doesn't have the "create or
replace function as ' --stuff ' language 'plpgsql'" it just has the
actual function. Makes things a little easier. I'm getting an error at
or near "5".

>
> because pre-8.0 the planner won't realize that the inequality is
> selective enough to favor an indexscan, unless it's comparing to
> a simple constant.
>
> (BTW, 8.0's dollar quoting makes this sort of thing a lot less painful)
>
> regards, tom lane
>

--
-Josh

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Josh Close 2005-05-27 15:00:23 Re: slow queries, possibly disk io
Previous Message Tom Lane 2005-05-27 14:29:18 Re: slow queries, possibly disk io