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.89) (envelope-from ) id 1iCOqD-0007P9-JR for pgsql-general@arkaria.postgresql.org; Mon, 23 Sep 2019 13:57:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iCOqB-00042t-Pq for pgsql-general@arkaria.postgresql.org; Mon, 23 Sep 2019 13:57:23 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iCOqB-00042m-Db for pgsql-general@lists.postgresql.org; Mon, 23 Sep 2019 13:57:23 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iCOq9-0002QD-2v for pgsql-general@lists.postgresql.org; Mon, 23 Sep 2019 13:57:22 +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 x8NDvHUO026982; Mon, 23 Sep 2019 09:57:17 -0400 From: Tom Lane To: Corey Taylor cc: pgsql-general@lists.postgresql.org Subject: Re: postgres 9.6: insert into select finishes only in pgadmin not psql In-reply-to: References: <11667.1568842347@sss.pgh.pa.us> Comments: In-reply-to Corey Taylor message dated "Mon, 23 Sep 2019 02:07:55 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <26980.1569247037.1@sss.pgh.pa.us> Date: Mon, 23 Sep 2019 09:57:17 -0400 Message-ID: <26981.1569247037@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Corey Taylor writes: > I found after testing other situations, that the psql command would always > finish as expected after canceling the first query that ran too long. I > was able to reproduce this scenario with psql and pgadmin4 with various > combinations. Well, that's just weird. It's well known that the second run of a query can be much faster due to having fully-populated caches to draw on, but you seem to have a case that may go beyond that. Maybe check for waiting on a lock? It'd be useful to look in pg_stat_activity and/or top(1) while the initial query is running, to see if it seems to be eating CPU or is blocked on some condition. (I forget how thorough the wait_event coverage is in 9.6, but it does at least have those columns.) Can you create a self-contained test case that acts like this? regards, tom lane