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 1idOqj-0001X5-Tz for pgsql-performance@arkaria.postgresql.org; Sat, 07 Dec 2019 01:25:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1idOqh-0000rX-Jf for pgsql-performance@arkaria.postgresql.org; Sat, 07 Dec 2019 01:25:31 +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 1idOqh-0000rP-7K for pgsql-performance@lists.postgresql.org; Sat, 07 Dec 2019 01:25:31 +0000 Received: from mail-yw1-xc43.google.com ([2607:f8b0:4864:20::c43]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1idOqd-0007MJ-7c for pgsql-performance@lists.postgresql.org; Sat, 07 Dec 2019 01:25:30 +0000 Received: by mail-yw1-xc43.google.com with SMTP id h126so3490943ywc.6 for ; Fri, 06 Dec 2019 17:25:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=YxtWEDja+3QcurH1lKx683SBnJ6fQEeSTJu77MZicJI=; b=DoR0Ege42M3T/QEh5Sv+lUJQw40YEqUAtUyQv1os3ALEilt63iaBfNY/2xbfuELRiV bT9X1HUhjJfGn8gwSPJtLN578eo2Lf7HQ3Nnpmq1282lvS96iGOw7Kw+sAWJkJwiRPJf 4QFRwtn5KwU3zBzpRjR4KDENUfl9wFh7o32TlHOL/WGcD30hUZeUE4Z7mW0+RacRmcWc I5Ua0uRoenJky+lKsgT6rVMiJOfPNx+LJsJ3BMY14MfdXWxkzRLIYx00N2bu6R03W+t1 lKUnjkzj1RHcXvKfxoSChTFqxR26WNmt4ObrEq5aIfXmYSKmhch7Iok+N92zyxW0bjo5 GhCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=YxtWEDja+3QcurH1lKx683SBnJ6fQEeSTJu77MZicJI=; b=HYnA10tFQCa3EMxeRrhlYlSlHw+zdV9H4oPMFJY+9q1DwwiAcmLICe57MRbCQNlHn6 ED8c4Ral/VT2tfQQwIsSvOnUPWfbqgnGN3TKaKqpnoSFO+2wYKz49G8P2PyxLMfU+M9s s5Ro9kd9vt1fgq1oPZzX9yrhLOfkjoEipegmswwjEjkQYQOVMlXdDtqscKQsEMYcgGzp icC/6ujzrJPQvWhAAAlg7k0Wu+nBzpNuqxUmeRW4b0xlWnaI5Daz2UpRGnexanSLcZBz jgYLx0t6E2Mp+ii+TnD+Wk0612bctUdJLiitXKeqq6adNGToaZpFZzvQLYtaJjgc6KTS +7bQ== X-Gm-Message-State: APjAAAUaQrUU24sLg7XiONlnPcToZGxJqwnrl9i2PNtiR1ZySV8hdVat I6ulsndbu3UjDWY6uHhk1uR3uUS0+xg= X-Google-Smtp-Source: APXvYqyBKTLa1f8Gz0tKcbtm5P8g/G6BKj/pfLCiWQW6qkCb6mSrdgPBgjkv5xbRDDJrB1N9MWXO4A== X-Received: by 2002:a81:a617:: with SMTP id d23mr12413061ywh.51.1575681923998; Fri, 06 Dec 2019 17:25:23 -0800 (PST) Received: from pryzbyj (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id c188sm7046834ywb.56.2019.12.06.17.25.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Dec 2019 17:25:23 -0800 (PST) Received: by pryzbyj (Postfix, from userid 1000) id 0F580800A81; Fri, 6 Dec 2019 19:25:21 -0600 (CST) Date: Fri, 6 Dec 2019 19:25:21 -0600 From: Justin Pryzby To: Lars Aksel Opsahl Cc: pgsql-performance@lists.postgresql.org Subject: Re: How to run in parallel in Postgres Message-ID: <20191207012521.GU2082@telsasoft.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Thu, Dec 05, 2019 at 12:10:42PM +0000, Lars Aksel Opsahl wrote: > I have a function that prepares data, so the big job can be run it in parallel. > > Since Postgres now supports parallel I was wondering if it's easy to trigger parallel dynamically created SQL calls. > > If you look at https://github.com/larsop/find-overlap-and-gap/blob/master/src/test/sql/regress/find_overlap_and_gap.sql you see that > > find_overlap_gap_make_run_cmd generates as set of 28 sql calls. > > So is it in a simple way possible to use Postgres parallel functionality to call this 28 functions i parallel so I don't have dependent on externally install programs ? SELECT find_overlap_gap_single_cell('test_data.overlap_gap_input_t1','geom',4258,'test_data.overlap_gap_input_t1_res',1,28); SELECT find_overlap_gap_single_cell('test_data.overlap_gap_input_t1','geom',4258,'test_data.overlap_gap_input_t1_res',2,28); SELECT find_overlap_gap_single_cell('test_data.overlap_gap_input_t1','geom',4258,'test_data.overlap_gap_input_t1_res',3,28); ... I see that find_overlap_gap_single_cell creates tables, so cannot be run in parallel. Maybe you could consider rewriting it to return data to its caller instead. You'd also need to mark it as PARALLEL SAFE, of course. Your other functions involved should be PARALLEL SAFE too. Justin