Prepared statements - Mailing list pgsql-general

From Tim Cross
Subject Prepared statements
Date
Msg-id 87o9jhjfv2.fsf@gmail.com
Whole thread Raw
Responses Re: Prepared statements  (Rakesh Kumar <rakeshkumar464@aol.com>)
Re: Prepared statements  (Steve Atkins <steve@blighty.com>)
List pgsql-general
a simple question I wasn't able to get a clear answer on....

It is general best practice to use prepared statements and parameters
rather than concatenated strings to build sql statements as mitigation
against SQL injection. However, in some databases I've used, there is
also a performance advantage. For example, the planner may be able to
more easily recognise a statement and reuse an existing plan rather than
re-planning the query.

I wasn't sure what the situation is with postgres - is there a
performance benefit in using prepared statements over a query string
where the values are just concatenated into the string?

thanks,

Tim

--
Tim Cross


pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: postgresql-10.3 on unbuntu-17.10 - how??
Next
From: Adrian Klaver
Date:
Subject: Re: JDBC connectivity issue