X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id DC64553798 for ; Fri, 25 Mar 2005 16:29:14 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 19196-05 for ; Fri, 25 Mar 2005 16:29:10 +0000 (GMT) Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.199]) by svr1.postgresql.org (Postfix) with ESMTP id B94CC53783 for ; Fri, 25 Mar 2005 16:29:10 +0000 (GMT) Received: by rproxy.gmail.com with SMTP id j1so791482rnf for ; Fri, 25 Mar 2005 08:29:09 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=k5QBVA6HWKRoMuInRb+ZVNxV/hmK6FUyRVYbxdS5PlpxPoaCoOLE3sywRy5f9Hyx5mbjk0hWDacSodzZcR2zyPsmDSQe4chhVeyCCsZ4g9Q7nrm4C3rk79PBNmezx7ZeNQkrNDv/KOqD9gXgUiaVoMtUj9rYAPSjiRr9uOdSVCU= Received: by 10.38.65.57 with SMTP id n57mr361005rna; Fri, 25 Mar 2005 08:29:09 -0800 (PST) Received: by 10.38.101.75 with HTTP; Fri, 25 Mar 2005 08:29:09 -0800 (PST) Message-ID: <758d5e7f05032508294c881604@mail.gmail.com> Date: Fri, 25 Mar 2005 17:29:09 +0100 From: Dawid Kuroczko Reply-To: Dawid Kuroczko To: pgsql-general@postgresql.org Subject: Re: Delay INSERT In-Reply-To: <8115.1111599180@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.748 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, FROM_ENDS_IN_NUMS, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200503/1259 X-Sequence-Number: 75574 On Wed, 23 Mar 2005 12:33:00 -0500, Tom Lane wrote: > Dawid Kuroczko 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