PrepareStatement and parameters data types

Поиск
Список
Период
Сортировка
От ihab sabiq
Тема PrepareStatement and parameters data types
Дата
Msg-id DU0P192MB1615DEF3058031F8018F175BFE12A@DU0P192MB1615.EURP192.PROD.OUTLOOK.COM
обсуждение исходный текст
Список pgsql-general
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 : where cast($1 as text) is null or cast($2 as text) is null or ( date_field < cast(cast($3 as text) as date) and date_field > cast(cast($4 as text) as date) )

Thanks for your help.

Sabiq

В списке pgsql-general по дате отправления:

Предыдущее
От: Meera Nair
Дата:
Сообщение: RE: PostgreSQL 14.8 - server fails to start even though all transaction logs with base backup are restored
Следующее
От: Stephen Frost
Дата:
Сообщение: Re: PostgreSQL 14.8 - server fails to start even though all transaction logs with base backup are restored