pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Marinos Yannikos <mjy@geizhals.at>
To: pgsql-performance@postgresql.org, "Svetlin Manavski" <svetlin.manavski@gmail.com>
Subject: Re: is parallel union all possible over dblink?
Date: Wed, 29 Jun 2011 20:37:18 +0200
Message-ID: <op.vxuoogblkhmbxg@klump-pc.ghoffice> (raw)
In-Reply-To: <BANLkTimwCWg6LGavaNU3YMJNcBiWppX9UQ@mail.gmail.com>
References: <BANLkTimwCWg6LGavaNU3YMJNcBiWppX9UQ@mail.gmail.com>

On Wed, 29 Jun 2011 13:55:58 +0200, Svetlin Manavski  
<svetlin.manavski@gmail.com> wrote:

> 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)

Have you tried dblink_send_query() + dblink_get_results() yet?

http://www.postgresql.org/docs/current/static/contrib-dblink-send-query.html

You'd have to do something like this to your queries [untested]:

select dblink_send_query('remote1','select * from
appqosfe.F_total_utilization(1306918800000000000::INT8, NULL,
60000000000::INT8, NULL)');
(select * from appqosfe.F_total_utilization(1306918800000000000::INT8,  
NULL,
60000000000::INT8, NULL))
UNION ALL
(SELECT * from dblink_get_result('remote1') as T1(detectroid numeric,  
timegroup numeric,
numbytes numeric, numpackets numeric))
order by timegroup asc;

i.e. start your remote query/-ies asynchronously, then collect the results  
in the UNION query. At least in theory it should work...

Regards,
  Marinos




view thread (6+ messages)  latest in thread

Message-ID: <op.vxuoogblkhmbxg@klump-pc.ghoffice>
Permalink:  ../op.vxuoogblkhmbxg@klump-pc.ghoffice/
Also on:    postgresql.org/message-id/op.vxuoogblkhmbxg@klump-pc.ghoffice

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: mjy@geizhals.at, svetlin.manavski@gmail.com
  Subject: Re: is parallel union all possible over dblink?
  In-Reply-To: <op.vxuoogblkhmbxg@klump-pc.ghoffice>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox