Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f3xxu-0001bC-Ag for pgsql-general@arkaria.postgresql.org; Thu, 05 Apr 2018 06:01:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f3xxt-000375-Bj for pgsql-general@arkaria.postgresql.org; Thu, 05 Apr 2018 06:01:41 +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.89) (envelope-from ) id 1f3xxt-000347-0I for pgsql-general@lists.postgresql.org; Thu, 05 Apr 2018 06:01:41 +0000 Received: from mail-wm0-x22d.google.com ([2a00:1450:400c:c09::22d]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1f3xxo-0004yq-DB for pgsql-general@lists.postgresql.org; Thu, 05 Apr 2018 06:01:40 +0000 Received: by mail-wm0-x22d.google.com with SMTP id u189so2599938wmd.1 for ; Wed, 04 Apr 2018 23:01:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:references:in-reply-to:subject:date:message-id:mime-version :content-transfer-encoding:thread-index:content-language; bh=TAHz5xHWyLaJ3NFZBOR3kU3iagUQXZt/f3kxGc+nxQc=; b=n1xdxwBS1t7s8gV3IWAxOdJVwUiZHyGbaPY2JL0BExiMbsp0X3aenRaFCYV+nrvPLE FeOq+Z7Zf2YSzXL8bHXcdbw6Wh83OuMw2T3eqIgqRZ1b8Uxu/R6UKdZFMn/tfFSie4Nw bEE1wGKHs5opOkDWngISMzMzj9CC3ukSBV2X8cxHwyUwlvlZopYSkwNf9aA3FvKD+lg5 MHFGoI+Y0TRIyCWKU07DQnNQiuek2KdkxB8AEFNNJLoankhvAksZe6sjE7eVooKV4cFU ECjsTLlurPkREIMEezdj5CxFczwUNh3T3BB4T27zvDyJUy6ton7whmy+lCN+k+XQSMxm 70Hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:references:in-reply-to:subject:date :message-id:mime-version:content-transfer-encoding:thread-index :content-language; bh=TAHz5xHWyLaJ3NFZBOR3kU3iagUQXZt/f3kxGc+nxQc=; b=i+3in3L/+BRqM9HQkFzpeELFKd3GEZ11rhV6G9IQnRielgktW2uC4QJzhkgOM47IJF CIAMCo+7a73eBWG5FZ+Q2EcVu865Keg+ijLKbXnSa6eNEYkVyxs1W5aDwrYRhJB/ewCI OMcx0oBQdnx2YHM03ZNIYE48yZfor8xlF4Pk44mOes6JuRGkAeVa98eIGaA5QazE8orB xDJ4aaTebiECmmgxw3Riv2bh8RBp+Lflkyck72R0x4dSMag9KFwNkue9kA9xAobnc8d0 eTU5xCm1PZ2SoGDRbh+8cQ9GPIErJ2ebl3I18v3RzUU4dmI3btzoehaYKzHooGJ0/hDZ F05A== X-Gm-Message-State: ALQs6tDx5+yJsKjp8Vhwb5RpbP2gD7VEWgWHuBidVQvW+FtuLaK0EBEZ KGuaAMuHG4Noh6Ju48XZGOM04g== X-Google-Smtp-Source: AIpwx4+gRWoPsRJljG2LupZFsFSOTdjZPFwQKKpz+pbl1FUn3dFcW8SzbwtyJwZZ59G8kxdUp/t2dg== X-Received: by 10.28.124.8 with SMTP id x8mr9068536wmc.36.1522908093869; Wed, 04 Apr 2018 23:01:33 -0700 (PDT) Received: from PC016 (mail.ibeq.com. [212.100.42.241]) by smtp.gmail.com with ESMTPSA id e8sm13589870wmf.15.2018.04.04.23.01.32 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Apr 2018 23:01:33 -0700 (PDT) From: To: References: In-Reply-To: Subject: AW: Concurrent CTE Date: Thu, 5 Apr 2018 08:01:32 +0200 Message-ID: <003201d3cca3$8c573f60$a505be20$@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQDe6tLRpIvPKQfPGqdyfNkWZ3/eCKXbcM+Q Content-Language: de List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Did you look at this approach using dblink already?=20 https://gist.github.com/mjgleaso/8031067 In your situation, you will have to modify the example but it may give = an idea where to start.=20 Klaus > -----Urspr=C3=BCngliche Nachricht----- > Von: Artur Formella > Gesendet: Dienstag, 3. April 2018 22:01 > An: pgsql-general@lists.postgresql.org > Betreff: Concurrent CTE >=20 > Hello! > We have a lot of big CTE (~40 statements, ~1000 lines) for very = dynamic OLTP > content and avg response time 50-300ms. Our setup has 96 threads = (Intel > Xeon Gold 6128), 256 GB RAM and 12 SSD (3 tablespaces). DB size < RAM. > Simplifying the problem: >=20 > WITH aa as ( > SELECT * FROM table1 > ), bb ( > SELECT * FROM table2 > ), cc ( > SELECT * FROM table3 > ), dd ( > SELECT * FROM aa,bb > ), ee ( > SELECT * FROM aa,bb,cc > ), ff ( > SELECT * FROM ee,dd > ), gg ( > SELECT * FROM table4 > ), hh ( > SELECT * FROM aa > ) > SELECT * FROM gg,hh,ff /* primary statement */ >=20 > Execution now: > time--> > Thread1: aa | bb | cc | dd | ee | ff | gg | hh | primary >=20 > And the question: is it possible to achieve more concurrent execution = plan to > reduce the response time? For example: > Thread1: aa | dd | ff | primary > Thread2: bb | ee | gg > Thread3: cc | -- | hh >=20 > Table1, table2 and table3 are located on separate tablespaces and are > independent. > Partial results (aa,bb,cc,dd,ee) are quite big and slow (full text = search, arrays, > custom collations, function scans...). >=20 > We consider resigning from the CTE and rewrite to RX Java but we are = afraid > of downloading partial results and sending it back with WHERE IN(...). >=20 > Thanks! >=20 > Artur Formella >=20 >=20