Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1jCAF6-0004LQ-HN for pgsql-performance@arkaria.postgresql.org; Wed, 11 Mar 2020 22:54:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jCAF4-0002pH-B8 for pgsql-performance@arkaria.postgresql.org; Wed, 11 Mar 2020 22:54:22 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1jCAF4-0002lN-1n for pgsql-performance@lists.postgresql.org; Wed, 11 Mar 2020 22:54:22 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jCAF1-0008Eb-86 for pgsql-performance@postgresql.org; Wed, 11 Mar 2020 22:54:21 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id 02BMsGkR006263; Wed, 11 Mar 2020 18:54:16 -0400 From: Tom Lane To: Richard Michael cc: pgsql-performance@postgresql.org Subject: Re: Slow ext'd query via client native implementation vs. libpq & simple psql In-reply-to: References: Comments: In-reply-to Richard Michael message dated "Wed, 11 Mar 2020 15:31:48 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <6261.1583967256.1@sss.pgh.pa.us> Date: Wed, 11 Mar 2020 18:54:16 -0400 Message-ID: <6262.1583967256@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Richard Michael writes: > On PG 12.2, I am analyzing a performance problem when using a client > (Elixir/postgrex) querying via the extended query protocol. I am comparing > with > psql and a C program. Logs for all three follow this short explanation. Hmm, your auto-explain log entries show all three queries having server-side execution times of a couple dozen msec. It seems like the excess time must be involved in transmitting the data to the client. So I guess I'd be looking at whether the client is really slow at absorbing data for some reason. IIRC, auto-explain's 'actual time' for the top-level query node does not count the time to format data or transmit it to the client. Still, we have an upper bound of ~80 msec for that to happen with the libpq client, and there's no obvious reason why it'd be different for the other client. [ thinks for a bit... ] You might double check that those two clients are using the same client_encoding setting. 400ms doing encoding conversion seems excessive, but there aren't that many other possibilities for the I/O time to be different. regards, tom lane