pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tim Cross <theophilusx@gmail.com>
To: Postgres General <pgsql-general@postgresql.org>
Subject: Prepared statements
Date: Thu, 22 Mar 2018 08:09:05 +1100
Message-ID: <87o9jhjfv2.fsf@gmail.com> (raw)


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




view thread (19+ messages)  latest in thread

Message-ID: <87o9jhjfv2.fsf@gmail.com>
Permalink:  ../87o9jhjfv2.fsf@gmail.com/
Also on:    postgresql.org/message-id/87o9jhjfv2.fsf@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: theophilusx@gmail.com
  Subject: Re: Prepared statements
  In-Reply-To: <87o9jhjfv2.fsf@gmail.com>
  References: <87o9jhjfv2.fsf@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox