Thread: the same time value return different values,is it a problem

the same time value return different values,is it a problem

From
姜梦洋
Date:

I find the time type accuracy of the database. Using PreparedStatement, the accuracy found out for the sixth time is different from the first five times. This number is exactly the same as the threshold of the PreparedStatement. I can understand that the database can optimize PreparedStatements and reduce repeated parsing and other unnecessary operations. but I don’t quite understand how such processing will affect the execution results(Or maybe I don’t have a deep understanding of PreparedStatement.). now I run the code and get some results

1.jpeg2.jpeg3.jpeg4.jpeg5.jpeg

Attachment

Re: the same time value return different values,is it a problem

From
姜梦洋
Date:
sorry for images,here are clear;


On Sep 13, 2023, at 3:24 PM, 姜梦洋 <minesunny@icloud.com> wrote:

I find the time type accuracy of the database. Using PreparedStatement, the accuracy found out for the sixth time is different from the first five times. This number is exactly the same as the threshold of the PreparedStatement. I can understand that the database can optimize PreparedStatements and reduce repeated parsing and other unnecessary operations. but I don’t quite understand how such processing will affect the execution results(Or maybe I don’t have a deep understanding of PreparedStatement.). now I run the code and get some results
<1.jpeg><2.jpeg><3.jpeg><4.jpeg><5.jpeg>

Attachment

Re: the same time value return different values,is it a problem

From
Tom Lane
Date:
=?utf-8?B?5aec5qKm5rSL?= <minesunny@icloud.com> writes:
>     I find the time type accuracy of the database. Using PreparedStatement, the accuracy found out for the sixth time
isdifferent from the first five times. This number is exactly the same as the threshold of the PreparedStatement. I can
understandthat the database can optimize PreparedStatements and reduce repeated parsing and other unnecessary
operations.but I don’t quite understand how such processing will affect the execution results(Or maybe I don’t have a
deepunderstanding of PreparedStatement.). 

If you're using JDBC, this is probably the same effect discussed at

https://www.postgresql.org/message-id/flat/CAKyg5Sj%3D85niw8%3DZhX-quHaCQTPhG40REi1s%2BHYF6Snz4Dfi7Q%40mail.gmail.com

It's got something to do with retrieving the query results in binary
mode instead of text.  The query result at the server is the same,
but the JDBC driver is rendering it differently.

            regards, tom lane



Re: the same time value return different values,is it a problem

From
Dave Cramer
Date:


On Wed, 13 Sept 2023 at 10:17, Tom Lane <tgl@sss.pgh.pa.us> wrote:
姜梦洋 <minesunny@icloud.com> writes:
>       I find the time type accuracy of the database. Using PreparedStatement, the accuracy found out for the sixth time is different from the first five times. This number is exactly the same as the threshold of the PreparedStatement. I can understand that the database can optimize PreparedStatements and reduce repeated parsing and other unnecessary operations. but I don’t quite understand how such processing will affect the execution results(Or maybe I don’t have a deep understanding of PreparedStatement.).

What is the difference and the type of the column? I'm not about to open a zip file.

 

If you're using JDBC, this is probably the same effect discussed at

https://www.postgresql.org/message-id/flat/CAKyg5Sj%3D85niw8%3DZhX-quHaCQTPhG40REi1s%2BHYF6Snz4Dfi7Q%40mail.gmail.com

It's got something to do with retrieving the query results in binary
mode instead of text.  The query result at the server is the same,
but the JDBC driver is rendering it differently.


rendering is not quite right. The parsing tends to be slightly different in text vs binary. 


Dave Cramer
www.postgres.rocks

                        regards, tom lane


Re: the same time value return different values,is it a problem

From
Dave Cramer
Date:


On Fri, 15 Sept 2023 at 12:58, Dave Cramer <davecramer@postgres.rocks> wrote:


On Wed, 13 Sept 2023 at 10:17, Tom Lane <tgl@sss.pgh.pa.us> wrote:
姜梦洋 <minesunny@icloud.com> writes:
>       I find the time type accuracy of the database. Using PreparedStatement, the accuracy found out for the sixth time is different from the first five times. This number is exactly the same as the threshold of the PreparedStatement. I can understand that the database can optimize PreparedStatements and reduce repeated parsing and other unnecessary operations. but I don’t quite understand how such processing will affect the execution results(Or maybe I don’t have a deep understanding of PreparedStatement.).

What is the difference and the type of the column? I'm not about to open a zip file.

 

If you're using JDBC, this is probably the same effect discussed at

https://www.postgresql.org/message-id/flat/CAKyg5Sj%3D85niw8%3DZhX-quHaCQTPhG40REi1s%2BHYF6Snz4Dfi7Q%40mail.gmail.com

It's got something to do with retrieving the query results in binary
mode instead of text.  The query result at the server is the same,
but the JDBC driver is rendering it differently.


rendering is not quite right. The parsing tends to be slightly different in text vs binary. 

So it is interesting that we drop the precision of time when we receive the data in binary. I'll have a look when I have time. 

Dave