Re: SendRowDescriptionMessage() is slow for queries with a lot of columns

From: Andres Freund <andres(at)anarazel(dot)de>
To: Thom Brown <thom(at)linux(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: SendRowDescriptionMessage() is slow for queries with a lot of columns
Date: 2017-09-15 21:33:34
Message-ID: 20170915213334.fgjo35qxk4gqfotw@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Thom,

On 2017-09-15 22:05:35 +0100, Thom Brown wrote:
> Okay, I've retested it using a prepared statement executed 100,000
> times (which selects a single row from a table with 101 columns, each
> column is 42-43 characters long, and 2 rows in the table), and I get
> the following:
>
> master:
>
> real 1m23.485s
> user 1m2.800s
> sys 0m1.200s
>
>
> patched:
>
> real 1m22.530s
> user 1m2.860s
> sys 0m1.140s
>
>
> Not sure why I'm not seeing the gain.

I suspect a part of that is that you're testing the patch in isolation,
whereas I tested it as part of multiple speedup patches. There's some
bigger bottlenecks than this one. I've attached my whole stack.

But even that being said, here's the result for these patches in
isolation on my machine:

setup:
psql -p 5440 -f ~/tmp/create_many_cols.sql

pgbench -M prepared -f ~/tmp/pgbench-many-cols.sql -n -T 10 -P 1
master (best of three):
tps = 13347.023301 (excluding connections establishing)
patched (best of three):
tps = 14309.690741 (excluding connections establishing)

Which is a bigger win than what you're observing. I've also attached the
benchmark scripts I used. Could you detail how your benchmark works a
bit more? Any chance you looped in plpgsql or such?

Just for fun/reference, these are the results with all the patches
applied:
tps = 19069.115553 (excluding connections establishing)
and with just this patch reverted:
tps = 17342.006825 (excluding connections establishing)

Regards,

Andres

Attachment Content-Type Size
0001-Speedup-pgstat_report_activity-by-moving-mb-aware-v1.patch text/x-diff 9.0 KB
0002-Add-more-efficient-functions-to-pqformat-APIv1.patch text/x-diff 6.1 KB
0003-Improve-performance-of-SendRowDescriptionMessagev1.patch text/x-diff 6.4 KB
0004-Add-inline-murmurhash32-int32-functionv1.patch text/x-diff 2.3 KB
0005-Replace-binary-search-in-fmgr_isbuiltin-with-hashtv1.patch text/x-diff 2.9 KB
0006-Add-pg_noinline-macro-to-c.hv1.patch text/x-diff 1.4 KB
0007-Improve-sys-catcache-performancev1.patch text/x-diff 26.1 KB
0008-WIP-Improve-getBaseTypeAndTypemod-performance-for-v1.patch text/x-diff 933 bytes
pgbench-many-cols.sql application/x-sql 4.0 KB
create_many_cols.sql application/x-sql 6.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2017-09-15 21:38:15 Re: Partition-wise join for join between (declaratively) partitioned tables
Previous Message Dipesh Dangol 2017-09-15 21:32:18 Re: pgjdbc logical replication client throwing exception