Avoiding execution of some functions by query rewriting

Поиск
Список
Период
Сортировка
От Thomas Girault
Тема Avoiding execution of some functions by query rewriting
Дата
Msg-id CAMVHftSZDh+HZ9ag2F2H9K7RoS9dTySpDBVUa72Hi_wzbdj9FQ@mail.gmail.com
обсуждение исходный текст
Ответы Re: Avoiding execution of some functions by query rewriting  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Avoiding execution of some functions by query rewriting  (Florian Pflug <fgp@phlo.org>)
Список pgsql-hackers
Hello,

I would like to allow the execution of a function (my_function) only if its argument (my_table.x) belongs to a predefined interval (e.g. [100,1000]).

Let's take the following query example :
(q)  SELECT * FROM my_table WHERE my_function(mytable.x);

I would like this query automatically rewrites itself to check whether "mytable.x" belong to the interval [100,1000] :
(q')  SELECT * FROM my_table WHERE (my_table.x BETWEEN 100 AND 1000) AND my_function(my_table.x);

The command EXPLAIN ANALYSE shows that the second query is really faster than the first one.

How can I change the query execution plan in order to automate the process of query rewriting (q into q') ?
Where can I store suitably the metadata about the interval [100,1000] associated to my_function ?
 
Thanks by advance,

Thomas Girault

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Heikki Linnakangas
Дата:
Сообщение: Re: Interrupting long external library calls
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Avoiding execution of some functions by query rewriting