From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
---|---|
To: | Simon Connah <simon(dot)n(dot)connah(at)protonmail(dot)com> |
Cc: | "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Prepared statements versus stored procedures |
Date: | 2023-11-19 18:07:38 |
Message-ID: | CAKFQuwb3Eb_o2wLUoJpQdH+OZnT=gxr5gN1yHftSw1e_jn3sNA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Sun, Nov 19, 2023 at 10:30 AM Simon Connah <simon(dot)n(dot)connah(at)protonmail(dot)com>
wrote:
> My question is this. If I make a stored procedure doesn't the database
> already pre-plan and optimise the query because it has access to the whole
> query?
No. Planning isn't about the text of the query, it's about the current
state of the database.
Or could I create a stored procedure and then turn it into a prepared
> statement for more speed?
Not usually.
I was also thinking a stored procedure would help as it requires less
> network round trips as the query is already on the server.
>
Unless your query is insanely large this benefit seems marginal.
> Sorry for the question but I'm not entirely sure how stored procedures and
> prepared statements work together.
They don't.
David J.
From | Date | Subject | |
---|---|---|---|
Next Message | Francisco Olarte | 2023-11-19 18:09:07 | Re: Prepared statements versus stored procedures |
Previous Message | Simon Connah | 2023-11-19 17:30:20 | Prepared statements versus stored procedures |