Prepared statements versus stored procedures - Mailing list pgsql-general

From Simon Connah
Subject Prepared statements versus stored procedures
Date
Msg-id Kqgk_qyGD98su8jLVl1pTnkOJSD8qcyv3FhqFokRUCLKKZA8TF2oL0WQCVgm7DVGPTPHcjVxgPAfPP9QSgPWUXpT8swlSYKGMNDjP8Hzmbo=@protonmail.com
Whole thread Raw
Responses Re: Prepared statements versus stored procedures
Re: Prepared statements versus stored procedures
Re: Prepared statements versus stored procedures
List pgsql-general
Hi,

First of all please forgive me. I'm not very experienced with databases.

I was reading about prepared statements and how they allow the server to plan the query in advance so that if you
executethat query multiple times it gets sped up as the database has already done the planning work. 

My question is this. If I make a stored procedure doesn't the database already pre-plan and optimise the query because
ithas access to the whole query? Or could I create a stored procedure and then turn it into a prepared statement for
morespeed? I was also thinking a stored procedure would help as it requires less network round trips as the query is
alreadyon the server. 

Sorry for the question but I'm not entirely sure how stored procedures and prepared statements work together.
Attachment

pgsql-general by date:

Previous
From: Achilleas Mantzios
Date:
Subject: Re: Getting most records possibly from an Inner/Left Join
Next
From: "David G. Johnston"
Date:
Subject: Re: Prepared statements versus stored procedures