Re: [GENERAL] Index scan vs. Seq scan on timestamps

2004-12-11 Thread Michael Fuhr
On Tue, Dec 07, 2004 at 09:25:20AM +0100, Per Jensen wrote: > Den Tue, Dec 07, 2004 at 03:13:04AM - eller der omkring skrev Andrew - > Supernews: > > On 2004-12-07, Stephen Frost <[EMAIL PROTECTED]> wrote: > > > Is there a way to say "just take the value of this function at the start > > > of

Re: [GENERAL] Index scan vs. Seq scan on timestamps

2004-12-11 Thread Per Jensen
Den Tue, Dec 07, 2004 at 03:13:04AM - eller der omkring skrev Andrew - Supernews: > On 2004-12-07, Stephen Frost <[EMAIL PROTECTED]> wrote: > > Is there a way to say "just take the value of this function at the start > > of the transaction and then have it be constant" in a query? > > Why not

Re: [GENERAL] Index scan vs. Seq scan on timestamps

2004-12-11 Thread Per Jensen
Den Tue, Dec 07, 2004 at 03:13:04AM - eller der omkring skrev Andrew - Supernews: > On 2004-12-07, Stephen Frost <[EMAIL PROTECTED]> wrote: > > Is there a way to say "just take the value of this function at the start > > of the transaction and then have it be constant" in a query? > > Why not

Re: [GENERAL] Index scan vs. Seq scan on timestamps

2004-12-07 Thread Stephan Szabo
On Mon, 6 Dec 2004, Stephen Frost wrote: > * Stephan Szabo ([EMAIL PROTECTED]) wrote: > > On Mon, 6 Dec 2004, Per Jensen wrote: > > > select count(*) > > > from accesslog > > > where time between (timeofday()::timestamp - INTERVAL '30 d') and > > > timeofday()::timestamp; > > > > Besides the type

Re: [GENERAL] Index scan vs. Seq scan on timestamps

2004-12-06 Thread Andrew - Supernews
On 2004-12-07, Stephen Frost <[EMAIL PROTECTED]> wrote: > Is there a way to say "just take the value of this function at the start > of the transaction and then have it be constant" in a query? Why not use CURRENT_TIMESTAMP, etc., which do exactly that? -- Andrew, Supernews http://www.supernews.

Re: [GENERAL] Index scan vs. Seq scan on timestamps

2004-12-06 Thread Stephen Frost
* Stephan Szabo ([EMAIL PROTECTED]) wrote: > On Mon, 6 Dec 2004, Per Jensen wrote: > > select count(*) > > from accesslog > > where time between (timeofday()::timestamp - INTERVAL '30 d') and > > timeofday()::timestamp; > > Besides the type issue, timeofday() is volatile and thus is not allowed t

Re: [GENERAL] Index scan vs. Seq scan on timestamps

2004-12-06 Thread Stephan Szabo
On Mon, 6 Dec 2004, Per Jensen wrote: > select count(*) > from accesslog > where time between (timeofday()::timestamp - INTERVAL '30 d') and > timeofday()::timestamp; Besides the type issue, timeofday() is volatile and thus is not allowed to be turned into a constant in order to do an index sca

Re: [GENERAL] Index scan vs. Seq scan on timestamps

2004-12-06 Thread Per Jensen
Andrew - Supernews wrote: On 2004-12-06, Per Jensen <[EMAIL PROTECTED]> wrote: Why does PG not use the index on the time column in the second select, timeofday() has been cast to a timestamp after all. "timestamp" is "timestamp without time zone" (not the most useful type in the world). Your colu

Re: [GENERAL] Index scan vs. Seq scan on timestamps

2004-12-06 Thread Andrew - Supernews
On 2004-12-06, Per Jensen <[EMAIL PROTECTED]> wrote: > Why does PG not use the index on the time column in the second select, > timeofday() has been cast to a timestamp after all. "timestamp" is "timestamp without time zone" (not the most useful type in the world). Your column is of type "timesta

[GENERAL] Index scan vs. Seq scan on timestamps

2004-12-06 Thread Per Jensen
List, PG version is 7.4.2 I log apache hits to a postgres server. The table layout is as follows: apachelog=# \d accesslog Table "public.accesslog" Column | Type | Modifiers --+--+--- id | integer | n