Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1a1elc-0001iV-A3 for pgsql-jdbc@arkaria.postgresql.org; Wed, 25 Nov 2015 18:26:08 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1a1ela-0000ij-It for pgsql-jdbc@arkaria.postgresql.org; Wed, 25 Nov 2015 18:26:06 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1a1elZ-0000gP-NH for pgsql-jdbc@postgresql.org; Wed, 25 Nov 2015 18:26:05 +0000 Received: from plane.gmane.org ([80.91.229.3]) by makus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1a1elW-0004WN-Px for pgsql-jdbc@postgresql.org; Wed, 25 Nov 2015 18:26:04 +0000 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1a1elO-00010b-O8 for pgsql-jdbc@postgresql.org; Wed, 25 Nov 2015 19:25:54 +0100 Received: from ppp-46-244-208-138.dynamic.mnet-online.de ([46.244.208.138]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 25 Nov 2015 19:25:54 +0100 Received: from spam_eater by ppp-46-244-208-138.dynamic.mnet-online.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 25 Nov 2015 19:25:54 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-jdbc@postgresql.org From: Thomas Kellerer Subject: Re: How to avoid SET application_name = '' Date: Wed, 25 Nov 2015 19:25:40 +0100 Lines: 45 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: ppp-46-244-208-138.dynamic.mnet-online.de User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.1.21) Gecko/20090302 Thunderbird/2.0.0.21 Mnenhy/0.7.5.666 In-Reply-To: X-Pg-Spam-Score: -3.0 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org Fabio Caiut schrieb am 25.11.2015 um 16:20: > I'm trying to understand the "SET application_name" command sent by the driver. > > We have a database server with high concurrency, ~25K TPS, and looking the top queries (with pg_stat_statements view) > I get it's the query taking more time. > > The command is very fast but the number of calls is huge. > > > TOP 10 Queries (only ~2 hours collecting) > > > calls | total_time | avg_time | rows | avg_rows | hit_percent | > ----------+------------+----------+----------+----------+-------------+------------------------------ > 55782793 | 8212550.69 | 0.15 | 0 | 0.00 | | SET application_name = '' > 4425751 | 322475.14 | 0.07 | 138606 | 0.00 | 98.98 | /* load one-to-many ... > 4097384 | 963780.17 | 0.24 | 84514 | 0.00 | 99.77 | /* load ... > 3908144 | 366598.92 | 0.09 | 3834578 | 0.00 | 100.00 | /* load ... > 2596097 | 480030.01 | 0.18 | 2596097 | 1.00 | 100.00 | /* SELECT count(*) FROM ... > 2365353 | 290965.73 | 0.12 | 2365335 | 0.00 | 99.99 | /* load ... > 2081011 | 127373.91 | 0.06 | 379289 | 0.00 | 99.59 | /* load collection ... > 1303931 | 145544.50 | 0.11 | 1303925 | 0.00 | 95.94 | /* load ... > 1274982 | 577683.73 | 0.45 | 1274982 | 1.00 | 100.00 | /* Select count(*) from ... > 1203475 | 1522327.87 | 1.26 | 4405775 | 3.00 | 89.44 | /* load ... > > > It takes ~8K seconds, more than 2 hours, it means that this command can use more than one core all the time! (if I'm understanding right) > > I'm thinking as the application name is empty maybe this command could be avoid. > I have asked our Glassfish people to "unmark" this option if possible but they told me they don't know how to do it, where to do it. > > I'm not sure if the quantity of calls is a problem in application, in glassfish or in driver. >But, if it's possible tune to avoid it, I would like that. Is it possible that this is configured as a "connection test" statement with your connection pool in Glassfish? Including something like "test-on-borrow" (or test-on-return) so that this would send each time a connection is taken out of the pool (or returned). I don't think the driver sends this "on its own" without any trigger from the application. The statement is sent if Connection.setClientInfo() is called, so maybe that called from somewhere in your application or the connection pool. -- Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc