Re: timestamped archive data index searches

From: "Stephen Birch" <sgbirch(at)hotmail(dot)com>
To: merlyn(at)stonehenge(dot)com, pgsql-general(at)postgresql(dot)org
Subject: Re: timestamped archive data index searches
Date: 2002-07-20 20:29:04
Message-ID: F252BGDQgJ9lZnmFNdZ000125b0@hotmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Huh!!

I just tried this and it didn't work for me, it was very slow. I did an
EXPLAIN and it was back to sequence scan again.

Steve

>From: merlyn(at)stonehenge(dot)com (Randal L. Schwartz)
>To: pgsql-general(at)postgresql(dot)org
>Subject: Re: [GENERAL] timestamped archive data index searches
>Date: 20 Jul 2002 12:51:00 -0700
>
> >>>>> "Tom" == Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:
>
>Tom> "Stephen Birch" <sgbirch(at)hotmail(dot)com> writes:
> >> I also tried the following, which explain said is also using a sequence
>scan
> >> :-(
>
> >> SELECT sum(vol) FROM det
> >> WHERE tstamp > (current_timestamp - '5 seconds'::interval);
>
>Tom> This doesn't work (in 7.2 and before) because the planner doesn't
>think
>Tom> current_timestamp is a constant. You can get around that with a
>custom
>Tom> function that hides the current_timestamp computation and is marked
>Tom> isCachable --- this is a cheat but works well enough in interactive
>Tom> queries. (It'd not work inside plpgsql unfortunately.) See past
>Tom> archived discussions --- searching for isCachable should turn up
>Tom> examples.
>
>I've found this to work:
>
>SELECT sum(vol) FROM det
>WHERE tstamp > (select current_timestamp - '5 seconds'::interval);
>
>I don't know where I got that trick from, but it works fine.
>
>--
>Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
><merlyn(at)stonehenge(dot)com> <URL:http://www.stonehenge.com/merlyn/>
>Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
>See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl
>training!
>
>---------------------------(end of broadcast)---------------------------
>TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)

_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com

Browse pgsql-general by date

  From Date Subject
Next Message Stephen Birch 2002-07-20 20:38:29 Re: psql wishes or even realized?
Previous Message Glen Parker 2002-07-20 20:17:21 Re: Linux max on shared buffers?