Re: Mechanics of Select - Mailing list pgsql-general

From Willem Buitendyk
Subject Re: Mechanics of Select
Date
Msg-id 47AFA39B.4020903@pcfish.ca
Whole thread Raw
In response to Re: Mechanics of Select  (Greg Smith <gsmith@gregsmith.com>)
Responses Re: Mechanics of Select
List pgsql-general
As others have suggested my big problem with the function I wrote was
that I had made it Volatile instead of Immutable (it is no doubt
suffering from code bloat as well).  That made all the difference.
Curiously though - I tried it just with the date_trunc function and it
was just as slow as my old Volatile function.

select * from track where datetime >= '2007-04-01' and datetime <
date_trunc('month','2007-04-01'::timestamp)+interval '1 month'; was
about 55s
select * from track where datetime >= '2007-04-01' and datetime <
first_day_next_month('2007-04-01'); was about 36s

cheers

Greg Smith wrote:
> On Sun, 10 Feb 2008, Willem Buitendyk wrote:
>
>> I have the following function that returns the first day of the next
>> month from whatever date is inserted.
>
> See if you can do this with date_trunc instead to avoid calling a
> function, which avoids the whole thing.  The first day of next month is:
>
> select date_trunc('month',now())+interval '1 month';
>
> I'd be curious how the runtime using that compares with the plpgsql
> version you've done.
>
> --
> * Greg Smith gsmith@gregsmith.com http://www.gregsmith.com Baltimore, MD
>


pgsql-general by date:

Previous
From: Alban Hertroys
Date:
Subject: Re: Mechanics of Select
Next
From: "Pierre Thibaudeau"
Date:
Subject: Re: 8.3: where's the replacement tsearch2 module?