Re: [HACKERS] WIP Patch: Precalculate stable functions,infrastructure v1
От | Dmitry Dolgov |
---|---|
Тема | Re: [HACKERS] WIP Patch: Precalculate stable functions,infrastructure v1 |
Дата | |
Msg-id | CA+q6zcX+0q_32J_VLjQ_jwr-MqNLmJZXAbCE+eKrsnhd8Dng5g@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: [HACKERS] WIP Patch: Precalculate stable functions,infrastructure v1 (Marina Polyakova <m.polyakova@postgrespro.ru>) |
Ответы |
Re: [HACKERS] WIP Patch: Precalculate stable functions,infrastructure v1
|
Список | pgsql-hackers |
> On 31 December 2017 at 06:55, Marina Polyakova <m.polyakova@postgrespro.ru> wrote:
>
> Secondly, here there's a sixth version of the patch for the precalculation of
> stable or immutable functions, stable or immutable operators and other
> nonvolatile expressions.
Thanks for your patch, looks quite interesting!
> To not send big patch I have split it (that's why version starts with the
> first again) and here I send infrastructure patch which includes:
Yeah, but it's still 18k lines :) After the first quick glance I have a few
small questions.
If I call a stable function from a query and subquery, looks like it's cached:
```
=# select stable_with_int(1) from (select stable_with_int(1) from x) q;
NOTICE: 00000: stable with int
LOCATION: exec_stmt_raise, pl_exec.c:3353
stable_with_int
-----------------
1
1
1
1
(4 rows)
```
But the same from CTE works different, is it supposed to be like that?
```
=# with data as (select stable_with_int(1) from x) select stable_with_int(1) from data;
NOTICE: 00000: stable with int
LOCATION: exec_stmt_raise, pl_exec.c:3353
NOTICE: 00000: stable with int
LOCATION: exec_stmt_raise, pl_exec.c:3353
stable_with_int
-----------------
1
1
1
1
(4 rows)
```
Also I see this pattern quite some time, maybe it makes sense to move it to a function?
```
+ /* create and return CachedExpr */
+ CachedExpr *new_node = makeNode(CachedExpr);
+ new_node->subexpr = (CacheableExpr *) current_node;
+
+ context->root->hasCachedExpr = true;
+
+ return (Node *) new_node;
```
В списке pgsql-hackers по дате отправления: