pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedUsing compression on TCP transfer
10+ messages / 3 participants
[nested] [flat]
* Using compression on TCP transfer
@ 2020-03-31 08:29 Andrus <kobruleht2@hot.ee>
0 siblings, 2 replies; 10+ messages in thread
From: Andrus @ 2020-03-31 08:29 UTC (permalink / raw)
To: pgsql-general
Hi!
Databases contain lot of char(n) type fields containing ascii characters.
Most of fields contain less characters than field width.
Changing them to varchar is not easy.
Database is accessed from Debian Postgres 12.2 over internet using psqlodbc
with
TLS v1.3.
Mostly results seelct commands are sent and results are retrieved.
Clients have 10-20Mbit download speeds, and 5-20 Mbit upload speeds.
Will data compression increase speed ?
If yes, how to implement this ?
Andrus.
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: Using compression on TCP transfer
@ 2020-03-31 09:38 Andrus <kobruleht2@hot.ee>
parent: Andrus <kobruleht2@hot.ee>
1 sibling, 1 reply; 10+ messages in thread
From: Andrus @ 2020-03-31 09:38 UTC (permalink / raw)
To: Olivier Gautherot <ogautherot@gautherot.net>; +Cc: pgsql-general
Hi,
>See the section about sslcompression in https://www.postgresql.org/docs/9.2/libpq-connect.html. It should be your answer.
I added
sslcompression=1
to psqlodbc connection string but log file shows that connection is still uncompressed:
LOG: connection authorized: user=me database=mydb SSL enabled (protocol=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384, bits=256, compression=off)
Maybe because according to TLSv1.3 standard, compression is no more allowed or psqlodbc does not pass it to pglib.
How to compress ?
Andrus.
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: Using compression on TCP transfer
@ 2020-03-31 10:28 Olivier Gautherot <ogautherot@gautherot.net>
parent: Andrus <kobruleht2@hot.ee>
0 siblings, 1 reply; 10+ messages in thread
From: Olivier Gautherot @ 2020-03-31 10:28 UTC (permalink / raw)
To: Andrus <kobruleht2@hot.ee>; +Cc: pgsql-general
Sorry, forgot the reply all :-)
On Tue, Mar 31, 2020 at 11:39 AM Andrus <kobruleht2@hot.ee> wrote:
> Hi,
>
> >See the section about sslcompression in
> https://www.postgresql.org/docs/9.2/libpq-connect.html. It should be your
> answer.
>
> I added
>
> sslcompression=1
>
> to psqlodbc connection string but log file shows that connection is still
> uncompressed:
>
> LOG: connection authorized: user=me database=mydb SSL enabled
> (protocol=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384, bits=256, compression=off)
>
> Maybe because according to TLSv1.3 standard, compression is no more
> allowed or psqlodbc does not pass it to pglib.
>
> How to compress ?
>
> Andrus.
>
Updated doc reference:
https://www.postgresql.org/docs/12/libpq-connect.html
They mention that compression is insecure and disabled by default. Taking
this into account, compression will require that both ODBC and PostgreSQL
are set up with compression enabled. I could not figure out quickly whether
this requires also recompiling the code...
--
Olivier Gautherot
Tel: +33 6 02 71 92 23
https://www.linkedin.com/in/ogautherot/
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: Using compression on TCP transfer
@ 2020-03-31 11:35 Andrus <kobruleht2@hot.ee>
parent: Olivier Gautherot <ogautherot@gautherot.net>
0 siblings, 0 replies; 10+ messages in thread
From: Andrus @ 2020-03-31 11:35 UTC (permalink / raw)
To: Olivier Gautherot <ogautherot@gautherot.net>; +Cc: pgsql-general
Hi!
>Updated doc reference:
>https://www.postgresql.org/docs/12/libpq-connect.html
>They mention that compression is insecure and disabled by default. Taking this into account, compression will require that both ODBC and PostgreSQL are set >up with compression enabled. I could not figure out quickly whether this requires also recompiling the code...
I added
Pqopt={sslcompression=1};
to psqlodbc connection string but log file shows that it still not compressed.
I’m using Debian 10 and Postgres 12 installed from postgres repository.
How to check is will it support compression or not.
Andrus.
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: Using compression on TCP transfer
@ 2020-03-31 11:59 Laurenz Albe <laurenz.albe@cybertec.at>
parent: Andrus <kobruleht2@hot.ee>
1 sibling, 1 reply; 10+ messages in thread
From: Laurenz Albe @ 2020-03-31 11:59 UTC (permalink / raw)
To: Andrus <kobruleht2@hot.ee>; pgsql-general
On Tue, 2020-03-31 at 11:29 +0300, Andrus wrote:
> Databases contain lot of char(n) type fields containing ascii characters.
> Most of fields contain less characters than field width.
> Changing them to varchar is not easy.
It is a simple ALTER TABLE.
> Database is accessed from Debian Postgres 12.2 over internet using psqlodbc
> with
> TLS v1.3.
> Mostly results seelct commands are sent and results are retrieved.
> Clients have 10-20Mbit download speeds, and 5-20 Mbit upload speeds.
>
> Will data compression increase speed ?
> If yes, how to implement this ?
You'd have to use an OpenSSL library with compression support enabled.
But that will improve speed only if your workload is network bound,
not CPU bound (in which case performance will suffer).
Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.com
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: Using compression on TCP transfer
@ 2020-03-31 12:13 Andrus <kobruleht2@hot.ee>
parent: Laurenz Albe <laurenz.albe@cybertec.at>
0 siblings, 1 reply; 10+ messages in thread
From: Andrus @ 2020-03-31 12:13 UTC (permalink / raw)
To: Laurenz Albe <laurenz.albe@cybertec.at>; pgsql-general
Hi!
>It is a simple ALTER TABLE.
Client is Visual FoxPro application. It sends data with trailing spaces
sometimes and sometimes not.
In case of varchar field values will appear in database sometimes with
trailing spaces and sometimes without.
This requires major application re-design which much is more expensive than
continuing using char fields.
>You'd have to use an OpenSSL library with compression support enabled.
Should I change OpenSSL installed from standard repository in Debian server
or can it changed only for PostgreSql.
How ?
>But that will improve speed only if your workload is network bound,
>not CPU bound (in which case performance will suffer).
Server has lot of cores. Top shows that CPU usage is small.
Brausers and web servers use compression widely. Apache and IIS enable
static content compression by default.
Compression should be built in in Postgres.
Andrus.
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: Using compression on TCP transfer
@ 2020-03-31 12:33 Laurenz Albe <laurenz.albe@cybertec.at>
parent: Andrus <kobruleht2@hot.ee>
0 siblings, 1 reply; 10+ messages in thread
From: Laurenz Albe @ 2020-03-31 12:33 UTC (permalink / raw)
To: Andrus <kobruleht2@hot.ee>; pgsql-general
On Tue, 2020-03-31 at 15:13 +0300, Andrus wrote:
> > It is a simple ALTER TABLE.
>
> Client is Visual FoxPro application. It sends data with trailing spaces
> sometimes and sometimes not.
> In case of varchar field values will appear in database sometimes with
> trailing spaces and sometimes without.
> This requires major application re-design which much is more expensive than
> continuing using char fields.
A simple BEFORE INSERT OR UPDATE trigger would take care of that.
> > You'd have to use an OpenSSL library with compression support enabled.
>
> Should I change OpenSSL installed from standard repository in Debian server
> or can it changed only for PostgreSql.
> How ?
I don't know if Debian's binaries are built with compression support,
probably not. You can build OpenSSL yourself and make PostgreSQL
use these binaries.
Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.com
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: Using compression on TCP transfer
@ 2020-04-04 08:08 Andrus <kobruleht2@hot.ee>
parent: Laurenz Albe <laurenz.albe@cybertec.at>
0 siblings, 1 reply; 10+ messages in thread
From: Andrus @ 2020-04-04 08:08 UTC (permalink / raw)
To: Laurenz Albe <laurenz.albe@cybertec.at>; pgsql-general
Hi!
>> In case of varchar field values will appear in database sometimes with
>> trailing spaces and sometimes without.
>> This requires major application re-design which much is more expensive than
>> continuing using char fields.
>A simple BEFORE INSERT OR UPDATE trigger would take care of that.
Changing char to varchar will break commands where trailing space is used in comparison.
For example query
create table test ( test char(10) );
insert into test values ('test');
select * from test where test ='test '; -- note trailing space
does not return data anymore if your recommendation is used:
create table test ( test varchar );
insert into test values ('test');
select * from test where test ='test '; -- note trailing space
In production 'test ' is query parameter coming from application with possible trailing space(s).
Adding trigger does not fix this.
How to fix this without re-writing huge number of sql commands?
Andrus.
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: Using compression on TCP transfer
@ 2020-04-05 08:59 Olivier Gautherot <ogautherot@gautherot.net>
parent: Andrus <kobruleht2@hot.ee>
0 siblings, 1 reply; 10+ messages in thread
From: Olivier Gautherot @ 2020-04-05 08:59 UTC (permalink / raw)
To: Andrus <kobruleht2@hot.ee>; +Cc: Laurenz Albe <laurenz.albe@cybertec.at>; pgsql-general
Hi Andrus,
Le sam. 4 avr. 2020 à 10:09, Andrus <kobruleht2@hot.ee> a écrit :
> Hi!
>
> >> In case of varchar field values will appear in database sometimes with
> >> trailing spaces and sometimes without.
> >> This requires major application re-design which much is more expensive
> than
> >> continuing using char fields.
> >A simple BEFORE INSERT OR UPDATE trigger would take care of that.
>
> Changing char to varchar will break commands where trailing space is used
> in comparison.
>
> For example query
>
> create table test ( test char(10) );
> insert into test values ('test');
> select * from test where test ='test '; -- note trailing space
>
> does not return data anymore if your recommendation is used:
>
> create table test ( test varchar );
> insert into test values ('test');
> select * from test where test ='test '; -- note trailing space
>
> In production 'test ' is query parameter coming from application with
> possible trailing space(s).
>
> Adding trigger does not fix this.
> How to fix this without re-writing huge number of sql commands?
>
In the end, your question is more at application level than database
itself. The real question is: which one is correct? With or without
trailing space?
If you decide that it's without, you could apply a TRIM in a trigger on
each INSERT and UPDATE. Then, you could replace the table by a view of the
same name and implement the TRIM on SELECT there. This way, you don't have
to touch anything in the application.
Hope it helps
Olivier
>
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: Using compression on TCP transfer
@ 2020-04-05 15:57 Andrus <kobruleht2@hot.ee>
parent: Olivier Gautherot <ogautherot@gautherot.net>
0 siblings, 0 replies; 10+ messages in thread
From: Andrus @ 2020-04-05 15:57 UTC (permalink / raw)
To: Olivier Gautherot <ogautherot@gautherot.net>; +Cc: Laurenz Albe <laurenz.albe@cybertec.at>; pgsql-general
Hi!
Thank you.
>If you decide that it's without, you could apply a TRIM in a trigger on each INSERT and UPDATE. Then, you could replace the table by a view of the same name >and implement the TRIM on SELECT there. This way, you don't have to touch anything in the application.
How you provide sample code how to create view or othe method test so that my select statement returns data.
Currently select in code
create table test ( test varchar );
insert into test values ('test');
select * from test where test ='test '; -- note trailing space
does not return data.
Andrus.
^ permalink raw reply [nested|flat] 10+ messages in thread
end of thread, other threads:[~2020-04-05 15:57 UTC | newest]
Thread overview: 10+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-03-31 08:29 Using compression on TCP transfer Andrus <kobruleht2@hot.ee>
2020-03-31 09:38 ` Andrus <kobruleht2@hot.ee>
2020-03-31 10:28 ` Olivier Gautherot <ogautherot@gautherot.net>
2020-03-31 11:35 ` Andrus <kobruleht2@hot.ee>
2020-03-31 11:59 ` Laurenz Albe <laurenz.albe@cybertec.at>
2020-03-31 12:13 ` Andrus <kobruleht2@hot.ee>
2020-03-31 12:33 ` Laurenz Albe <laurenz.albe@cybertec.at>
2020-04-04 08:08 ` Andrus <kobruleht2@hot.ee>
2020-04-05 08:59 ` Olivier Gautherot <ogautherot@gautherot.net>
2020-04-05 15:57 ` Andrus <kobruleht2@hot.ee>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox