Prepared statements

From: Tim Cross <theophilusx(at)gmail(dot)com>
To: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Prepared statements
Date: 2018-03-21 21:09:05
Message-ID: 87o9jhjfv2.fsf@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2018-03-21 21:13:04 Re: JDBC connectivity issue
Previous Message Adrian Klaver 2018-03-21 21:08:09 Re: postgresql-10.3 on unbuntu-17.10 - how??