X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 81717D1C50B for ; Thu, 7 Aug 2003 17:03:36 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 99791-04 for ; Thu, 7 Aug 2003 14:02:11 -0300 (ADT) Received: from spirit.aldeiadigital.com.br (iplus-fac-225-213-137.xdsl-fixo.ctbcnetsuper.com.br [200.225.213.137]) by svr1.postgresql.org (Postfix) with ESMTP id 1C0E6D1C509 for ; Thu, 7 Aug 2003 14:03:24 -0300 (ADT) Received: from webmail.ad2.com.br (localhost.localdomain [127.0.0.1]) by spirit.aldeiadigital.com.br (8.11.6/8.11.6) with SMTP id h77H4Tq11208 for ; Thu, 7 Aug 2003 14:04:30 -0300 Received: from 200.170.156.137 (SquirrelMail authenticated user alepaes) by webmail.ad2.com.br with HTTP; Thu, 7 Aug 2003 14:04:30 -0300 (BRT) Message-ID: <1108.200.170.156.137.1060275870.squirrel@webmail.ad2.com.br> Date: Thu, 7 Aug 2003 14:04:30 -0300 (BRT) Subject: Abort Transaction DP PK (again) From: "alexandre :: aldeia digital" To: pgsql-sql@postgresql.org User-Agent: SquirrelMail/1.4.0 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 X-Priority: 3 Importance: Normal X-Virus-Scanned: by amavisd-milter (http://amavis.org/) X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/67 X-Sequence-Number: 14683 Hi, I know that this topic was discuted before but I like an alternative for my high load INSERT query. Why Postgres abort a transaction when find a duplicate PK ?!?! A simple Fuction test: (...) SELECT a,b from foo where a=1 and b=1 IF NOT FOUND INSERT INTO foo VALUES(1,1) ELSE UPDATE (...) Is, obviously, very very much slower than this (hipotetic) function: (...) INSERT INTO foo IF "ERROR DP PK" UPDATE (...) In both cases, INSERT will test if values violate the PK... but in first example the extra SELECT cause an unnecessary extreame work... Thanks, Alexandre