From: | Willem Buitendyk <willem(at)pcfish(dot)ca> |
---|---|
To: | Greg Smith <gsmith(at)gregsmith(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Mechanics of Select |
Date: | 2008-02-11 01:23:39 |
Message-ID: | 47AFA39B.4020903@pcfish.ca |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(at)gregsmith(dot)com http://www.gregsmith.com Baltimore, MD
>
From | Date | Subject | |
---|---|---|---|
Next Message | Pierre Thibaudeau | 2008-02-11 02:28:16 | Re: 8.3: where's the replacement tsearch2 module? |
Previous Message | Alban Hertroys | 2008-02-11 00:23:33 | Re: Mechanics of Select |