From: | Ralph Smith <smithrn(at)washington(dot)edu> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Using a User-Def function in a query |
Date: | 2008-09-27 00:06:37 |
Message-ID: | FCCEE477-304B-4AD6-82D5-954F8BAB1F1A@washington.edu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Sep 23, 2008, at 7:50 PM, Tom Lane wrote:
> Ralph Smith <smithrn(at)washington(dot)edu> writes:
>> I've written several user-defined functions (UDFs) for converting
>> dates to unix time, every which way.
>> ... but when I try to use the function in a query
>> # select count(distinct username) from stats where eventtime >
>> dtu_dmony('22 Sep 2008') ;
>> it never comes back...
> =======================================
> Did you EXPLAIN that query? Is it using the index I suppose you've
> got
> on eventtime? I'll bet that it's not, and that the reason why not is
> that you didn't mark the function IMMUTABLE (or STABLE, which is the
> correct marking if it depends on the timezone setting). The planner
> won't try to use volatile functions in index conditions.
>
> regards, t lane
========================================
IMMUTABLE Worked!
Thank you!
Ralph
From | Date | Subject | |
---|---|---|---|
Next Message | vk | 2008-09-27 00:43:12 | circular stderr logging - truncation issue |
Previous Message | Ralph Smith | 2008-09-26 23:27:22 | Re: Using a User-Def function in a query |