pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dawid Kuroczko <qnex42@gmail.com>
To: pgsql-general@postgresql.org
Subject: Re: Delay INSERT
Date: Fri, 25 Mar 2005 17:29:09 +0100
Message-ID: <758d5e7f05032508294c881604@mail.gmail.com> (raw)
In-Reply-To: <8115.1111599180@sss.pgh.pa.us>
References: <20050321131047.93504.qmail@web53406.mail.yahoo.com>
	<20050321161555.GA22145@winnie.fuhr.org>
	<14435275218.20050323193122@on.kg>
	<42418247.7070108@archonet.com>
	<758d5e7f05032308342828a03f@mail.gmail.com>
	<8115.1111599180@sss.pgh.pa.us>

On Wed, 23 Mar 2005 12:33:00 -0500, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Dawid Kuroczko <qnex42@gmail.com> writes:
> > PostgreSQL doesn't have such issues with blocking, so only difference
> > between INSERT and INSERT DELAYED from PostgreSQL's standpoint
> > would be waiting and not for the result...

> With the right client-side code you can transmit multiple queries before
> receiving the result from the first one.  I don't think libpq in its
> current incarnation really supports this, but in principle it's doable.

...though I think it should be called asynchronic rather than
'delayed'.  I.e. issue a statement then select(2) in a spare
time to get the result, doing other work in meantime.

> The interesting questions have to do with error handling: if the
> "delayed" insert fails, what happens and what is the impact on
> subsequent queries?  I have no idea how MySQL defines that.

Well, looking at the on-line mysql docs -- it is not documented,
I did however try to issue them (on 3.x mysql installation).
I've created a table with a single int PK column, then inserted
delayed few values, some of which broke PK contraint and these
were silently discared.  There was no point checking how it would
work with transactions since ...delayed is MyISAM only and these
don't do transactions.

And as for PostgreSQL and asynchronic statements, I think it
should allow Pipelineing -- similar to NNTP or SMTP servers -- these would
send N commands to a server and then read them as-they-come-in.
Some usage example, imagine a web page which would:
 $q1 = execute_async("SELECT foo FROM a");
 $q2 = execute_async("SELECT * FROM polls LIMIT 5"); # whatever
 $q3 = execute_async("SELECT baz FROM bazzz");
  print some html;  print $q1->fetchall, some html $q2->fetchall,
  $q3->fetchall...

There is a question of synchronization and handling errors of course,
but I think it could be done and for some usage scenarios could be
quite benefitial.

Disclaimer: I never wrote a program using libpq, and I only looked
through libpq docs some time ago.  If I am wrong, please forgive me.

   Regards,
      Dawid



view thread (12+ messages)

Message-ID: <758d5e7f05032508294c881604@mail.gmail.com>
Permalink:  ../758d5e7f05032508294c881604@mail.gmail.com/
Also on:    postgresql.org/message-id/758d5e7f05032508294c881604@mail.gmail.com

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: qnex42@gmail.com, pgsql-general@postgresql.org
  Subject: Re: Delay INSERT
  In-Reply-To: <758d5e7f05032508294c881604@mail.gmail.com>
  References: <20050321131047.93504.qmail@web53406.mail.yahoo.com> <20050321161555.GA22145@winnie.fuhr.org> <14435275218.20050323193122@on.kg> <42418247.7070108@archonet.com> <758d5e7f05032308342828a03f@mail.gmail.com> <8115.1111599180@sss.pgh.pa.us> <758d5e7f05032508294c881604@mail.gmail.com>

* 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