Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1btwg1-0007GY-7Y for pgsql-bugs@arkaria.postgresql.org; Tue, 11 Oct 2016 13:01:01 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1btwg0-0004BO-Qc for pgsql-bugs@arkaria.postgresql.org; Tue, 11 Oct 2016 13:01:00 +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_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1btwfz-00048h-Vd for pgsql-bugs@postgresql.org; Tue, 11 Oct 2016 13:01:00 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1btwfw-00018I-Ft for pgsql-bugs@postgresql.org; Tue, 11 Oct 2016 13:00:59 +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 u9BD0qsS021110; Tue, 11 Oct 2016 09:00:52 -0400 From: Tom Lane To: Grigory Smolkin cc: pgsql-bugs@postgresql.org Subject: Re: parallel plan in insert query In-reply-to: References: <2950428a-2b07-03cb-4ec0-7454853fe244@postgrespro.ru> Comments: In-reply-to Grigory Smolkin message dated "Tue, 11 Oct 2016 14:48:19 +0300" Date: Tue, 11 Oct 2016 09:00:52 -0400 Message-ID: <21109.1476190852@sss.pgh.pa.us> X-Pg-Spam-Score: -2.2 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org Grigory Smolkin writes: > It`s INSERT: > 2016-10-07 19:41:41 MSK [11404]: [78416-1] > user=gis,db=gis,app=psql,client=[local] STATEMENT: > explain analyze insert into edges_snapped_speeds select gid, speed*3600, > ts from (select * from traffic_snapped_tracks limit 2) a join lateral > snaptopgr(geom) on true; No, it isn't: 2016-10-07 19:41:41 MSK [11404]: [78414-1] user=gis,db=gis,app=psql,client=[local] ERROR: cannot start commands during a parallel operation 2016-10-07 19:41:41 MSK [11404]: [78415-1] user=gis,db=gis,app=psql,client=[local] CONTEXT: SQL statement "SELECT proj4text FROM spatial_ref_sys WHERE srid = 4326 LIMIT 1" 2016-10-07 19:41:41 MSK [11404]: [78416-1] user=gis,db=gis,app=psql,client=[local] STATEMENT: explain analyze insert into edges_snapped_speeds select gid, speed*3600, ts from (select * from traffic_snapped_tracks limit 2) a join lateral snaptopgr(geom) on true; This is somewhere down inside a SELECT issued by a called function. Apparently you've got multiple levels of nested SQL operations there. The outer INSERT wouldn't get parallelized, but a query planned and executed inside a called function could be. I concur with Greg's conclusion that somewhere in the stack there's a function marked PARALLEL SAFE that shouldn't be marked that way. But we don't have nearly enough details to identify it. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs