Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 3F944B5DBD0 for ; Wed, 29 Jun 2011 08:56:05 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 92269-04 for ; Wed, 29 Jun 2011 11:55:59 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-fx0-f47.google.com (mail-fx0-f47.google.com [209.85.161.47]) by mail.postgresql.org (Postfix) with ESMTP id DC2D7B5DBE5 for ; Wed, 29 Jun 2011 08:55:58 -0300 (ADT) Received: by fxg11 with SMTP id 11so1272448fxg.34 for ; Wed, 29 Jun 2011 04:55:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; bh=up1gAoDAG3TzUl7BIlGL4px2XLEahTqcgYGjeJ9wFuA=; b=Gxb3N2ZNfqW1scyHEvwoqbmkII+o1jHO09nk1zn1GWLWKH9YuHy53yh76FNmlKkwfI hIHD6uVFI4YhI+eCeY5ualpncu5MJOKgevurA7aQyttaDgll6xE57yDvUdMH/qX5Sadd CVKx6PmN067XxBJNWWgOQXZAXKaFn6I5wmQzo= MIME-Version: 1.0 Received: by 10.223.5.13 with SMTP id 13mr1166500fat.1.1309348558624; Wed, 29 Jun 2011 04:55:58 -0700 (PDT) Received: by 10.223.103.141 with HTTP; Wed, 29 Jun 2011 04:55:58 -0700 (PDT) Date: Wed, 29 Jun 2011 12:55:58 +0100 Message-ID: Subject: is parallel union all possible over dblink? From: Svetlin Manavski To: pgsql-performance@postgresql.org Content-Type: multipart/alternative; boundary=001517475e62b959a704a6d877d4 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.888 tagged_above=-10 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, T_TO_NO_BRKTS_FREEMAIL=0.01 X-Spam-Level: X-Archive-Number: 201106/269 X-Sequence-Number: 44202 --001517475e62b959a704a6d877d4 Content-Type: text/plain; charset=ISO-8859-1 Hi all, I am running PostgreSQL 9.0 on a number of nodes in an application level cluster (there is different data on different machines). Currently a PL/pgSQL function generates automatically aggregation queries like the following: (select * from appqosfe.F_total_utilization(1306918800000000000::INT8, NULL, 60000000000::INT8, NULL)) UNION ALL (SELECT * from dblink('remote1','select * from appqosfe.F_total_utilization(1306918800000000000::INT8, NULL, 60000000000::INT8, NULL)') as T1(detectroid numeric, timegroup numeric, numbytes numeric, numpackets numeric)) order by timegroup asc The above example supposes that only 2 nodes are active (one local and one remote). Here I can clearly see that the remote sub-query starts only when the local one is completed so the total time grows linearly with the number of nodes. Question: Is there a way to get the same result from within a PL/pgSQL function but running all the sub-queries in parallel? In case it is not directly available, which one would be the simplest way to implement it in my application? (I am very keen to avoid the obvious solution of an additional multi-threaded layer which would do it out of the RDBMS) Thank you, Svetlin Manavski --001517475e62b959a704a6d877d4 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi all,
I am running PostgreSQL 9.0 on a number of nodes in an applicati= on level cluster (there is different data on different machines). Currently= a PL/pgSQL function generates automatically aggregation queries like the f= ollowing:=A0

(select * from appqosfe.F_total_utilization(1306918800000000000::INT8, = NULL, 60000000000::INT8, NULL))
UNION ALL
(SELECT * from dblink(= 9;remote1','select * from appqosfe.F_total_utilization(130691880000= 0000000::INT8, NULL, 60000000000::INT8, NULL)') as T1(detectroid numeri= c, timegroup numeric, numbytes numeric, numpackets numeric))
order by timegroup asc

The above example supposes that only 2 nodes= are active (one local and one remote). Here I can clearly see that the rem= ote sub-query starts only when the local one is completed so the total time= grows linearly with the number of nodes.

Question: Is there a way to get the same result from within a PL/pgSQL = function but running all the sub-queries in parallel? In case it is not dir= ectly available, which one would be the simplest way to implement it in my = application? (I am very keen to avoid the obvious solution of an additional= multi-threaded layer which would do it out of the RDBMS)

Thank you,
Svetlin Manavski

--001517475e62b959a704a6d877d4--