From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
---|---|
To: | Adam Fletcher <adamfblahblah(at)gmail(dot)com> |
Cc: | "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Accessing parameters of a prepared query inside an FDW |
Date: | 2024-02-15 03:43:48 |
Message-ID: | CAKFQuwZvVxSJmiz16c-dj9eo7Nu=ebpzyqNap4WQBC7ifadx+w@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Wednesday, February 14, 2024, Adam Fletcher <adamfblahblah(at)gmail(dot)com>
wrote:
>
>
> Is it possible to get the parameterized prepared query inside an FDW such
> that it can be prepared/bind'd/execute'd on the receiving end of the FDW?
>
> For example, if I `PREPARE stmt(int) AS SELECT * from fdwrapped_tbl where
> pk = $1;` then `execute stmt(1);` I want my FDW be aware that the query was
> prepared.
>
That isn’t how the separation of responsibilities works in PostgreSQL.
Execute is capable of producing a custom plan where instead of adding in
parameters and then planning around those unknowns the newly created plan
uses the supplied constants while planning.
I do suspect that if a generic plan is chosen you will see the expected
parse nodes and can thus build a generic access plan to your foreign server
accordingly.
You can control this for ease of testing via plan_cache_mode
https://www.postgresql.org/docs/current/runtime-config-query.html#GUC-PLAN-CACHE-MODE
David J.
From | Date | Subject | |
---|---|---|---|
Next Message | veem v | 2024-02-15 04:58:33 | Re: How to do faster DML |
Previous Message | Adam Fletcher | 2024-02-15 02:50:42 | Accessing parameters of a prepared query inside an FDW |