X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A178AD1B3C5 for ; Wed, 21 Jul 2004 04:07:37 -0300 (ADT) 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 54565-05 for ; Wed, 21 Jul 2004 07:07:14 +0000 (GMT) Received: from rock.spider.ru (rock.spider.ru [62.183.34.226]) by svr1.postgresql.org (Postfix) with ESMTP id 7761FD1B295 for ; Wed, 21 Jul 2004 04:07:10 -0300 (ADT) Received: from rock (localhost [127.0.0.1]) by rock (Postfix) with SMTP id 557DE273A1; Wed, 21 Jul 2004 11:07:10 +0400 (MSD) Received: from sad.localnet.ru (sad.localnet.ru [10.0.0.72]) by rock.spider.ru (Postfix) with ESMTP id 7F4432739F; Wed, 21 Jul 2004 11:07:07 +0400 (MSD) Content-Type: text/plain; charset="iso-8859-1" From: sad Organization: IT To: Steve Crawford , pgsql-sql@postgresql.org Subject: Re: locks and triggers. give me an advice please Date: Wed, 21 Jul 2004 09:01:13 +0400 User-Agent: KMail/1.4.3 References: <000001c46ddd$491501d0$c201a8c0@borderveygqj37> <200407200936.44292.sad@bankir.ru> <200407201130.19676.scrawford@pinpointresearch.com> In-Reply-To: <200407201130.19676.scrawford@pinpointresearch.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200407210901.13421.sad@bankir.ru> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/140 X-Sequence-Number: 18392 thnx. i try to sound the idea to ensure myself that you are right. > begin transaction; > lock t1 in access exclusive mode; > > Turn off triggers and do your updates. > (Note, "truncate t1" is faster than "delete from t1" followed by a > "vacuum full" and you might consider running "reindex table t1" after > your mass update or if appropriate drop your indexes, load the data, > then recreate them.) > > Re-establish triggers. > > commit; --end of transaction unlocks the table in case another user inserts a record into an adjuscent table with the valu= e=20 of reference field NOT IN t1. the constraint causes reading of t1 to look up FK value IN t1. so my EXCLUSIVE lock prevents even reading and this user operation will be= =20 queued.