pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Asynchronous query execution
5+ messages / 4 participants
[nested] [flat]

* Asynchronous query execution
@ 2010-12-08 13:35  c k <shreeseva.learning@gmail.com>
  0 siblings, 2 replies; 5+ messages in thread

From: c k @ 2010-12-08 13:35 UTC (permalink / raw)
  To: pgsql-general@postgresql.org; pgsql-admin

Hello,
I would like to know how can we execute the queries asynchronously?
If we use and execute plpgsql functions they just completes the execution or
throws an error on error. In between next sql statement waits for the
previous one to complete the execution. But in few situations it is required
not to wait for getting the completion of previous sql statement. How can
this e achieved?

Waiting for you response.

CPK

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Asynchronous query execution
@ 2010-12-08 13:40  John R Pierce <pierce@hogranch.com>
  parent: c k <shreeseva.learning@gmail.com>
  1 sibling, 1 reply; 5+ messages in thread

From: John R Pierce @ 2010-12-08 13:40 UTC (permalink / raw)
  To: PostgreSQL <pgsql-general@postgresql.org>

On 12/08/10 5:35 AM, c k wrote:
> Hello,
> I would like to know how can we execute the queries asynchronously?
> If we use and execute plpgsql functions they just completes the 
> execution or throws an error on error. In between next sql statement 
> waits for the previous one to complete the execution. But in few 
> situations it is required not to wait for getting the completion of 
> previous sql statement. How can this e achieved?
>

one postgresql connection can only run one query at a time.

run your asynchronous queries from a thread with its own connection





^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: [GENERAL] Asynchronous query execution
@ 2010-12-08 14:01  Robert Gravsjö <robert@blogg.se>
  parent: c k <shreeseva.learning@gmail.com>
  1 sibling, 0 replies; 5+ messages in thread

From: Robert Gravsjö @ 2010-12-08 14:01 UTC (permalink / raw)
  To: c k <shreeseva.learning@gmail.com>; +Cc: pgsql-general@postgresql.org; pgsql-admin



On 2010-12-08 14.35, c k wrote:
> Hello,
> I would like to know how can we execute the queries asynchronously?
> If we use and execute plpgsql functions they just completes the execution or
> throws an error on error. In between next sql statement waits for the
> previous one to complete the execution. But in few situations it is required
> not to wait for getting the completion of previous sql statement. How can
> this e achieved?

Is this what you're looking for:
http://www.postgresql.org/docs/current/interactive/libpq-async.html

>
> Waiting for you response.
>
> CPK
>

-- 
Regards,
Robert "roppert" Gravsjö



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Asynchronous query execution
@ 2010-12-08 15:32  Merlin Moncure <mmoncure@gmail.com>
  parent: John R Pierce <pierce@hogranch.com>
  0 siblings, 1 reply; 5+ messages in thread

From: Merlin Moncure @ 2010-12-08 15:32 UTC (permalink / raw)
  To: John R Pierce <pierce@hogranch.com>; +Cc: PostgreSQL <pgsql-general@postgresql.org>

On Wed, Dec 8, 2010 at 8:40 AM, John R Pierce <pierce@hogranch.com> wrote:
> On 12/08/10 5:35 AM, c k wrote:
>>
>> Hello,
>> I would like to know how can we execute the queries asynchronously?
>> If we use and execute plpgsql functions they just completes the execution
>> or throws an error on error. In between next sql statement waits for the
>> previous one to complete the execution. But in few situations it is required
>> not to wait for getting the completion of previous sql statement. How can
>> this e achieved?
>>
>
> one postgresql connection can only run one query at a time.
>
> run your asynchronous queries from a thread with its own connection

This is only asynchronous from client point of view.  Meaning, while
the query is running, you can go off and do other work on the client.

There is iron clad rule of one query running per database session at a
time.  From pl/pgsql point of view, only method of working around this
is using dblink style tricks to connect to the database from within
function and run queries.   dblink supports asynchronous querying so
you can leverage that:

dblink_send_query(text connname, text sql) returns int



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Asynchronous query execution
@ 2010-12-11 09:51  c k <shreeseva.learning@gmail.com>
  parent: Merlin Moncure <mmoncure@gmail.com>
  0 siblings, 0 replies; 5+ messages in thread

From: c k @ 2010-12-11 09:51 UTC (permalink / raw)
  To: Merlin Moncure <mmoncure@gmail.com>; +Cc: John R Pierce <pierce@hogranch.com>; PostgreSQL <pgsql-general@postgresql.org>

thanks to all of you.

Regards,
CPK

On 12/8/10, Merlin Moncure <mmoncure@gmail.com> wrote:
> On Wed, Dec 8, 2010 at 8:40 AM, John R Pierce <pierce@hogranch.com> wrote:
>> On 12/08/10 5:35 AM, c k wrote:
>>>
>>> Hello,
>>> I would like to know how can we execute the queries asynchronously?
>>> If we use and execute plpgsql functions they just completes the execution
>>> or throws an error on error. In between next sql statement waits for the
>>> previous one to complete the execution. But in few situations it is
>>> required
>>> not to wait for getting the completion of previous sql statement. How can
>>> this e achieved?
>>>
>>
>> one postgresql connection can only run one query at a time.
>>
>> run your asynchronous queries from a thread with its own connection
>
> This is only asynchronous from client point of view.  Meaning, while
> the query is running, you can go off and do other work on the client.
>
> There is iron clad rule of one query running per database session at a
> time.  From pl/pgsql point of view, only method of working around this
> is using dblink style tricks to connect to the database from within
> function and run queries.   dblink supports asynchronous querying so
> you can leverage that:
>
> dblink_send_query(text connname, text sql) returns int
>
> From client point of view, you have a number of techniques.
> async_queries/threads and multiple connections would be the most
> common approaches.
>
> merlin
>
> --
> Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>



^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2010-12-11 09:51 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2010-12-08 13:35 Asynchronous query execution c k <shreeseva.learning@gmail.com>
2010-12-08 13:40 ` John R Pierce <pierce@hogranch.com>
2010-12-08 15:32   ` Merlin Moncure <mmoncure@gmail.com>
2010-12-11 09:51     ` c k <shreeseva.learning@gmail.com>
2010-12-08 14:01 ` Robert Gravsjö <robert@blogg.se>

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