pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedPerformance of ByteA: ascii vs binary
9+ messages / 5 participants
[nested] [flat]
* Performance of ByteA: ascii vs binary
@ 2019-03-18 14:33 Thomas Güttler <guettliml@thomas-guettler.de>
2019-03-18 14:39 ` Re: Performance of ByteA: ascii vs binary Adrian Klaver <adrian.klaver@aklaver.com>
2019-03-19 19:37 ` Re: Performance of ByteA: ascii vs binary Peter J. Holzer <hjp-pgsql@hjp.at>
2019-04-10 14:16 ` Re: Performance of ByteA: ascii vs binary Олег Самойлов <splarv@ya.ru>
0 siblings, 3 replies; 9+ messages in thread
From: Thomas Güttler @ 2019-03-18 14:33 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
I did some benchmarking and in my setup there was major
performance difference.
I tested a ByteA column.
If I used ascii data the tests took 52 seconds.
If I used random binary data the test took 250 seconds.
binary data is (roughly) five times slower than ascii data?
Is this a know fact, or is there something wrong with my benchmark?
I used Python and psycopg2.
Regards,
Thomas Güttler
--
Thomas Guettler http://www.thomas-guettler.de/
I am looking for feedback: https://github.com/guettli/programming-guidelines
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Performance of ByteA: ascii vs binary
2019-03-18 14:33 Performance of ByteA: ascii vs binary Thomas Güttler <guettliml@thomas-guettler.de>
@ 2019-03-18 14:39 ` Adrian Klaver <adrian.klaver@aklaver.com>
2019-03-18 14:49 ` Re: Performance of ByteA: ascii vs binary Tom Lane <tgl@sss.pgh.pa.us>
2 siblings, 1 reply; 9+ messages in thread
From: Adrian Klaver @ 2019-03-18 14:39 UTC (permalink / raw)
To: Thomas Güttler <guettliml@thomas-guettler.de>; pgsql-general@lists.postgresql.org
On 3/18/19 7:33 AM, Thomas Güttler wrote:
> I did some benchmarking and in my setup there was major
> performance difference.
>
> I tested a ByteA column.
What was the test?
>
> If I used ascii data the tests took 52 seconds.
> If I used random binary data the test took 250 seconds.
>
> binary data is (roughly) five times slower than ascii data?
>
> Is this a know fact, or is there something wrong with my benchmark?
>
> I used Python and psycopg2.
>
> Regards,
> Thomas Güttler
>
>
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Performance of ByteA: ascii vs binary
2019-03-18 14:33 Performance of ByteA: ascii vs binary Thomas Güttler <guettliml@thomas-guettler.de>
2019-03-18 14:39 ` Re: Performance of ByteA: ascii vs binary Adrian Klaver <adrian.klaver@aklaver.com>
@ 2019-03-18 14:49 ` Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 9+ messages in thread
From: Tom Lane @ 2019-03-18 14:49 UTC (permalink / raw)
To: Adrian Klaver <adrian.klaver@aklaver.com>; +Cc: Thomas Güttler <guettliml@thomas-guettler.de>; pgsql-general@lists.postgresql.org
Adrian Klaver <adrian.klaver@aklaver.com> writes:
> On 3/18/19 7:33 AM, Thomas Güttler wrote:
>> If I used ascii data the tests took 52 seconds.
>> If I used random binary data the test took 250 seconds.
This doesn't seem terribly surprising in bytea_output = escape
mode. Probably with bytea_output = hex the performance would
be less data-dependent.
regards, tom lane
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Performance of ByteA: ascii vs binary
2019-03-18 14:33 Performance of ByteA: ascii vs binary Thomas Güttler <guettliml@thomas-guettler.de>
@ 2019-03-19 19:37 ` Peter J. Holzer <hjp-pgsql@hjp.at>
2019-03-20 12:20 ` Re: Performance of ByteA: ascii vs binary Thomas Güttler <guettliml@thomas-guettler.de>
2 siblings, 1 reply; 9+ messages in thread
From: Peter J. Holzer @ 2019-03-19 19:37 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On 2019-03-18 15:33:17 +0100, Thomas Güttler wrote:
> I did some benchmarking and in my setup there was major
> performance difference.
>
> I tested a ByteA column.
>
> If I used ascii data the tests took 52 seconds.
> If I used random binary data the test took 250 seconds.
>
> binary data is (roughly) five times slower than ascii data?
>
> Is this a know fact, or is there something wrong with my benchmark?
>
> I used Python and psycopg2.
I don't see this here (Debian 9, Python 3,5, psycopg2 2.7.6, PostgreSQL
9.5).
I modified my bench-bytea script (https://github.com/hjp/blob-bench) to
restrict the byte values to printable ASCII (32 .. 126). There was
absolutely no difference, as the attached graph shows.
hp
--
_ | Peter J. Holzer | we build much bigger, better disasters now
|_|_) | | because we have much more sophisticated
| | | hjp@hjp.at | management tools.
__/ | http://www.hjp.at/ | -- Ross Anderson <https://www.edge.org/;
Attachments:
ascii-binary.png (image/png, 9.3K) download
view image
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Performance of ByteA: ascii vs binary
2019-03-18 14:33 Performance of ByteA: ascii vs binary Thomas Güttler <guettliml@thomas-guettler.de>
2019-03-19 19:37 ` Re: Performance of ByteA: ascii vs binary Peter J. Holzer <hjp-pgsql@hjp.at>
@ 2019-03-20 12:20 ` Thomas Güttler <guettliml@thomas-guettler.de>
2019-03-21 12:35 ` Re: Performance of ByteA: ascii vs binary Peter J. Holzer <hjp-pgsql@hjp.at>
0 siblings, 1 reply; 9+ messages in thread
From: Thomas Güttler @ 2019-03-20 12:20 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
Am 19.03.19 um 20:37 schrieb Peter J. Holzer:
> On 2019-03-18 15:33:17 +0100, Thomas Güttler wrote:
>> I did some benchmarking and in my setup there was major
>> performance difference.
>>
>> I tested a ByteA column.
>>
>> If I used ascii data the tests took 52 seconds.
>> If I used random binary data the test took 250 seconds.
>>
>> binary data is (roughly) five times slower than ascii data?
>>
>> Is this a know fact, or is there something wrong with my benchmark?
>>
>> I used Python and psycopg2.
>
> I don't see this here (Debian 9, Python 3,5, psycopg2 2.7.6, PostgreSQL
> 9.5).
>
> I modified my bench-bytea script (https://github.com/hjp/blob-bench) to
> restrict the byte values to printable ASCII (32 .. 126). There was
> absolutely no difference, as the attached graph shows.
Strange. I saw a big difference.
What did you test?
I tested inserts.
Regards,
Thomas Güttler
--
Thomas Guettler http://www.thomas-guettler.de/
I am looking for feedback: https://github.com/guettli/programming-guidelines
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Performance of ByteA: ascii vs binary
2019-03-18 14:33 Performance of ByteA: ascii vs binary Thomas Güttler <guettliml@thomas-guettler.de>
2019-03-19 19:37 ` Re: Performance of ByteA: ascii vs binary Peter J. Holzer <hjp-pgsql@hjp.at>
2019-03-20 12:20 ` Re: Performance of ByteA: ascii vs binary Thomas Güttler <guettliml@thomas-guettler.de>
@ 2019-03-21 12:35 ` Peter J. Holzer <hjp-pgsql@hjp.at>
2019-03-21 13:49 ` Re: Performance of ByteA: ascii vs binary Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 9+ messages in thread
From: Peter J. Holzer @ 2019-03-21 12:35 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On 2019-03-20 13:20:57 +0100, Thomas Güttler wrote:
>
>
> Am 19.03.19 um 20:37 schrieb Peter J. Holzer:
> > On 2019-03-18 15:33:17 +0100, Thomas Güttler wrote:
> > > I did some benchmarking and in my setup there was major
> > > performance difference.
> > >
> > > I tested a ByteA column.
> > >
> > > If I used ascii data the tests took 52 seconds.
> > > If I used random binary data the test took 250 seconds.
> > >
> > > binary data is (roughly) five times slower than ascii data?
> > >
> > > Is this a know fact, or is there something wrong with my benchmark?
> > >
> > > I used Python and psycopg2.
> >
> > I don't see this here (Debian 9, Python 3,5, psycopg2 2.7.6, PostgreSQL
> > 9.5).
> >
> > I modified my bench-bytea script (https://github.com/hjp/blob-bench) to
> > restrict the byte values to printable ASCII (32 .. 126). There was
> > absolutely no difference, as the attached graph shows.
>
> Strange. I saw a big difference.
> What did you test?
> I tested inserts.
The graph with the quantiles was for selects. For inserts I made only a
scatterplot and there didn't seem to be any difference either. I'll
check the quantiles, too, but I expect to see at most a small
difference. A large difference as the one you saw would show up clearly
in a scatterplot, too.
My test ist in github (see URL above). Do see the same difference with
my test on your system?
hp
--
_ | Peter J. Holzer | we build much bigger, better disasters now
|_|_) | | because we have much more sophisticated
| | | hjp@hjp.at | management tools.
__/ | http://www.hjp.at/ | -- Ross Anderson <https://www.edge.org/;
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Performance of ByteA: ascii vs binary
2019-03-18 14:33 Performance of ByteA: ascii vs binary Thomas Güttler <guettliml@thomas-guettler.de>
2019-03-19 19:37 ` Re: Performance of ByteA: ascii vs binary Peter J. Holzer <hjp-pgsql@hjp.at>
2019-03-20 12:20 ` Re: Performance of ByteA: ascii vs binary Thomas Güttler <guettliml@thomas-guettler.de>
2019-03-21 12:35 ` Re: Performance of ByteA: ascii vs binary Peter J. Holzer <hjp-pgsql@hjp.at>
@ 2019-03-21 13:49 ` Tom Lane <tgl@sss.pgh.pa.us>
2019-03-21 14:12 ` Re: Performance of ByteA: ascii vs binary Adrian Klaver <adrian.klaver@aklaver.com>
0 siblings, 1 reply; 9+ messages in thread
From: Tom Lane @ 2019-03-21 13:49 UTC (permalink / raw)
To: Peter J. Holzer <hjp-pgsql@hjp.at>; +Cc: pgsql-general@lists.postgresql.org
"Peter J. Holzer" <hjp-pgsql@hjp.at> writes:
> On 2019-03-20 13:20:57 +0100, Thomas Güttler wrote:
>> Strange. I saw a big difference.
>> What did you test?
>> I tested inserts.
> The graph with the quantiles was for selects.
Hmm, so there are two different code paths being considered here
-- the OP is apparently talking about the speed of bytea_in,
while the rest of us have been thinking about bytea_out.
The question about whether the text representation is hex or
"escape" style still applies, though.
regards, tom lane
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Performance of ByteA: ascii vs binary
2019-03-18 14:33 Performance of ByteA: ascii vs binary Thomas Güttler <guettliml@thomas-guettler.de>
2019-03-19 19:37 ` Re: Performance of ByteA: ascii vs binary Peter J. Holzer <hjp-pgsql@hjp.at>
2019-03-20 12:20 ` Re: Performance of ByteA: ascii vs binary Thomas Güttler <guettliml@thomas-guettler.de>
2019-03-21 12:35 ` Re: Performance of ByteA: ascii vs binary Peter J. Holzer <hjp-pgsql@hjp.at>
2019-03-21 13:49 ` Re: Performance of ByteA: ascii vs binary Tom Lane <tgl@sss.pgh.pa.us>
@ 2019-03-21 14:12 ` Adrian Klaver <adrian.klaver@aklaver.com>
0 siblings, 0 replies; 9+ messages in thread
From: Adrian Klaver @ 2019-03-21 14:12 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; Peter J. Holzer <hjp-pgsql@hjp.at>; +Cc: pgsql-general@lists.postgresql.org
On 3/21/19 6:49 AM, Tom Lane wrote:
> "Peter J. Holzer" <hjp-pgsql@hjp.at> writes:
>> On 2019-03-20 13:20:57 +0100, Thomas Güttler wrote:
>>> Strange. I saw a big difference.
>>> What did you test?
>>> I tested inserts.
>
>> The graph with the quantiles was for selects.
>
> Hmm, so there are two different code paths being considered here
> -- the OP is apparently talking about the speed of bytea_in,
> while the rest of us have been thinking about bytea_out.
>
> The question about whether the text representation is hex or
> "escape" style still applies, though.
Yes, it would be nice to see the test code.
>
> regards, tom lane
>
>
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Performance of ByteA: ascii vs binary
2019-03-18 14:33 Performance of ByteA: ascii vs binary Thomas Güttler <guettliml@thomas-guettler.de>
@ 2019-04-10 14:16 ` Олег Самойлов <splarv@ya.ru>
2 siblings, 0 replies; 9+ messages in thread
From: Олег Самойлов @ 2019-04-10 14:16 UTC (permalink / raw)
To: Thomas Güttler <guettliml@thomas-guettler.de>; +Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Just theoretically assumption. PostgreSQL sometimes may optimise internal format of data and can sometimes zip data. ASCII data can be zipped better, then binary random data. Also PostgreSQL sometimes take decision to keep a column in an external file, if the column is still too big after zip. I don’t know what exactly happens in your case, but here can be a reason.
> 18 марта 2019 г., в 17:33, Thomas Güttler <guettliml@thomas-guettler.de> написал(а):
>
> I did some benchmarking and in my setup there was major
> performance difference.
>
> I tested a ByteA column.
>
> If I used ascii data the tests took 52 seconds.
> If I used random binary data the test took 250 seconds.
>
> binary data is (roughly) five times slower than ascii data?
>
> Is this a know fact, or is there something wrong with my benchmark?
>
> I used Python and psycopg2.
>
> Regards,
> Thomas Güttler
>
>
> --
> Thomas Guettler http://www.thomas-guettler.de/
> I am looking for feedback: https://github.com/guettli/programming-guidelines
>
^ permalink raw reply [nested|flat] 9+ messages in thread
end of thread, other threads:[~2019-04-10 14:16 UTC | newest]
Thread overview: 9+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-03-18 14:33 Performance of ByteA: ascii vs binary Thomas Güttler <guettliml@thomas-guettler.de>
2019-03-18 14:39 ` Adrian Klaver <adrian.klaver@aklaver.com>
2019-03-18 14:49 ` Tom Lane <tgl@sss.pgh.pa.us>
2019-03-19 19:37 ` Peter J. Holzer <hjp-pgsql@hjp.at>
2019-03-20 12:20 ` Thomas Güttler <guettliml@thomas-guettler.de>
2019-03-21 12:35 ` Peter J. Holzer <hjp-pgsql@hjp.at>
2019-03-21 13:49 ` Tom Lane <tgl@sss.pgh.pa.us>
2019-03-21 14:12 ` Adrian Klaver <adrian.klaver@aklaver.com>
2019-04-10 14:16 ` Олег Самойлов <splarv@ya.ru>
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