PQresultMemorySize of ResultSet larger than expected
PQresultMemorySize of ResultSet larger than expected
От:
Dominique Devienne <ddevienne@gmail.com>
Дата:
Hi, I've instrumented by libpq code, to show the byte size of the result-set. And I'm suprised that it's never smaller than 2,264 bytes, then the next size I see is 3,288, etc... Even when receiving no rows at all, in fact. I've trimmed-out the SQL, but these are all SELECT statements. The output below is from Windows, if that matters. The two larger ones at the bottom are fetching bytea blobs. So, is this expected? I'm surprised 2KB+ is used to return no rows basically. Where's the space going? Is the reported space the same or similar to the actual bytes returned on the wire? Or they somehow add up local allocations client-side? Any way to actually know how many bytes were returned on the wire? I'm basically curious, and would appreciate pointers to better understand this. Thanks, --DD Running 1 test case... ... `-> got 1 rows x 16 cols, 3,288 bytes (2.7 MB/s) in 1.159ms ... `-> got 1 rows x 18 cols, 3,288 bytes (2.2 MB/s) in 1.417ms ... `-> got 1 rows x 18 cols, 3,288 bytes (4.1 MB/s) in 0.771ms ... `-> got 0 rows x 15 cols, 2,264 bytes (2.1 MB/s) in 1.041ms ... `-> got 0 rows x 3 cols, 2,264 bytes (2.2 MB/s) in 0.991ms ... `-> got 0 rows x 15 cols, 2,264 bytes (3.3 MB/s) in 0.662ms ... `-> got 0 rows x 3 cols, 2,264 bytes (4.3 MB/s) in 0.503ms ... `-> got 1 rows x 14 cols, 3,288 bytes (3.6 MB/s) in 0.863ms ... `-> got 1 rows x 16 cols, 3,288 bytes (5.0 MB/s) in 0.623ms ... `-> got 0 rows x 15 cols, 2,264 bytes (3.6 MB/s) in 0.602ms ... `-> got 0 rows x 3 cols, 2,264 bytes (4.4 MB/s) in 0.494ms ... `-> got 0 rows x 15 cols, 2,264 bytes (3.7 MB/s) in 0.591ms ... `-> got 0 rows x 3 cols, 2,264 bytes (3.9 MB/s) in 0.548ms ... `-> got 1 rows x 1 cols, 818,441 bytes (78.1 MB/s) in 9.996ms ... `-> got 1 rows x 1 cols, 3,288 bytes (7.9 MB/s) in 0.396ms ... `-> got 1 rows x 1 cols, 36,345 bytes (33.4 MB/s) in 1.038ms *** No errors detected *** tests_acme_foo in 2.926s (user: 0.219s) 38 MB Press any key to continue . . .
Re: PQresultMemorySize of ResultSet larger than expected
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Dominique Devienne writes: > I've instrumented by libpq code, to show the byte size of the result-set. > And I'm suprised that it's never smaller than 2,264 bytes, then the next > size I see is 3,288, etc... Even when receiving no rows at all, in fact. See PGRESULT_DATA_BLOCKSIZE and associated comments, starting about line 90 in fe-exec.c. I don't recall whether there was any specific motivation for PGRESULT_DATA_BLOCKSIZE to be 2K rather than some other value; but it wouldn't do for it to be very small. regards, tom lane