Performance of a query - Mailing list pgsql-general

From Edmund Dengler
Subject Performance of a query
Date
Msg-id Pine.BSO.4.44.0306112004030.149-100000@cyclops4.esentire.com
Whole thread Raw
Responses Re: Performance of a query
List pgsql-general
Greetings all!

So I have had a look at the documentation to see what options I have in
separating the "select now() - '2 hours'::interval" from the rest of my
query. As far as I can tell, I have the following options:

(1) Do it in my calling code (Perl). Create two statements, execute the
first to get the time interval, then the second to get the results.

(2) Create a custom function that will enable me to have a variable. This
is now feasible with SETOF. Any issues with size of result set that would
be any different than if I do it directly?

(3) Use a temporary table. Ugly if the statement appears more than once in
the complex expression. Not sure if the constant folding would work
without some experimentation. Performance hits with creating temporary
tables?

(4) Use code to generate the time in my calling code, and then execute the
one statement. Would probably work, but I would need to see if all my
cases fall into this strategy.

Overall, none of them are appealing. Doesn't look like I have the option
of using PL/pgSQL without going through the whole process of creating a
function (which is possible in Oracle, as far as I can recall).

Any other appraches or recommended coding methods?

Regards,
Ed



pgsql-general by date:

Previous
From: "Maksim Likharev"
Date:
Subject: Re: TABLE FUNCTION, ERROR: WRONG RECORD TYPE IN RETURN NEXT
Next
From: "Jay O'Connor"
Date:
Subject: Re: need a method to ping a running database