how to evaluate a function only once for a query?
От | Nicolae Mihalache |
---|---|
Тема | how to evaluate a function only once for a query? |
Дата | |
Msg-id | 3D11B109.9020409@abcpages.com обсуждение исходный текст |
Ответы |
Re: how to evaluate a function only once for a query?
Re: how to evaluate a function only once for a query? |
Список | pgsql-general |
Hello! I'm tring to use postgesql functions written in pgtcl. I've created a function timevalue(text) that returns a timestamp as result. The function works just fine. However, when I do a query like: "select * from mytable where time<timevalue('something')" I see that my function is evaluated once for each row in mytable. The problem is that it will return each time the same value (because the argument is constant) and takes a lot of time to execute because my function is slow. The ideal behaviour would be that the function is called only once when the query is interpreted and then the value is used as a constant. Is there any possibility to make it behave like that? I know that I can make a "select timevalue('something')" before and then invoke my query with the result, but I'd like to have only one query for this. Thanks, Nicolae Mihalache
В списке pgsql-general по дате отправления: