From: | Dave Cramer <davecramer(at)gmail(dot)com> |
---|---|
To: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Cc: | Jack Christensen <jack(at)jackchristensen(dot)com> |
Subject: | Proposal to provide the facility to set binary format output for specific OID's per session |
Date: | 2022-07-22 15:00:18 |
Message-ID: | CADK3HHJxQ8ydLj98u7M0NGFh3x=rgoG9MVx8T6AanMbor2HTzw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Greetings,
Jack Christensen the author of the go pgx driver had suggested Default
result formats should be settable per session · Discussion #5 ·
postgresql-interfaces/enhancement-ideas (github.com)
<https://github.com/postgresql-interfaces/enhancement-ideas/discussions/5>
The JDBC driver has a similar problem and defers switching to binary format
until a statement has been reused 5 times; at which point we create a named
prepared statement and incur the overhead of an extra round trip for the
DESCRIBE statement. Because the extra round trip generally negates any
performance enhancements that receiving the data in binary format may
provide, we avoid using binary and receive everything in text format until
we are sure the extra trip is worth it.
Connection pools further complicate the issue: We can't use named
statements with connection pools since there is no binding of the
connection to the client. As such in the JDBC driver we recommend turning
off the ability to create a named statement and thus binary formats.
As a proof of concept I provide the attached patch which implements the
ability to specify which oids will be returned in binary format per
session.
IE set format_binary='20,21,25' for instance.
After which the specified oids will be output in binary format if there is
no describe statement or even using simpleQuery.
Both the JDBC driver and the go driver can exploit this change with no
changes. I haven't confirmed if other drivers would work without changes.
Furthermore jackc/postgresql_simple_protocol_binary_format_bench
(github.com)
<https://github.com/jackc/postgresql_simple_protocol_binary_format_bench>
suggests
that there is a considerable performance benefit. To quote 'At 100 rows the
text format takes 48% longer than the binary format.'
Regards,
Dave Cramer
Attachment | Content-Type | Size |
---|---|---|
0001-add-format_binary.patch | application/octet-stream | 7.0 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Anthony Sotolongo | 2022-07-22 15:17:52 | Re: Expose Parallelism counters planned/execute in pg_stat_statements |
Previous Message | Tom Lane | 2022-07-22 14:55:27 | Re: Support tab completion for upper character inputs in psql |