public inbox for [email protected]  
help / color / mirror / Atom feed
From: ihab sabiq <[email protected]>
To: [email protected] <[email protected]>
Subject: PrepareStatement and parameters data types
Date: Tue, 8 Aug 2023 19:27:35 +0000
Message-ID: <PRAP192MB16285D5564F9EFEFDAAD1AC2FE0DA@PRAP192MB1628.EURP192.PROD.OUTLOOK.COM> (raw)

Hello,

I was doing some experimenting to try and reduce the execution time of a query used in a PreparedStatement. To do that, I normally use the Prepare and Execute statements of Postgresql. What I notice is that explicit casting has a considerable performance impact. So using the good data types in the Prepare and avoid casting gives much better performance. My questions are :

  *   Does the implementation of PreparedStatment in Postgresql driver uses the Prepare and Execute
  *   If so why I cannot see the Prepare and the parameters type in the logs if not how can I simulate the same mechanism from the command line
  *   Is it possible to avoid explicit casting without getting the error could not determine data type of parameter

The query is bit complex on large tables but the main part is :  cast($1 as text) is null or cast($2 as text) is null or ( field < cast(cast($3 as text) as date) and field > cast(cast($4 as text) as date) )

Thanks for your help.

Sabiq


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 using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected]
  Subject: Re: PrepareStatement and parameters data types
  In-Reply-To: <PRAP192MB16285D5564F9EFEFDAAD1AC2FE0DA@PRAP192MB1628.EURP192.PROD.OUTLOOK.COM>

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

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