Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TKAqd-0000R6-3e for pgsql-performance@postgresql.org; Fri, 05 Oct 2012 16:33:59 +0000 Received: from moutng.kundenserver.de ([212.227.17.9]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TKAqb-0000BG-AX for pgsql-performance@postgresql.org; Fri, 05 Oct 2012 16:33:58 +0000 Received: from alap2.localnet (p549F1993.dip.t-dialin.net [84.159.25.147]) by mrelayeu.kundenserver.de (node=mrbap3) with ESMTP (Nemesis) id 0MAeNv-1T8N8Z23D9-00BttL; Fri, 05 Oct 2012 18:33:56 +0200 From: Andres Freund Organization: 2ndQuadrant.com To: Tom Lane Subject: Re: how to avoid deadlock on masive update with multiples delete Date: Fri, 5 Oct 2012 18:33:53 +0200 User-Agent: KMail/1.13.7 (Linux/3.5.0-rc3-andres-00231-g002b758; KDE/4.8.4; x86_64; ; ) Cc: pgsql-performance@postgresql.org, Maciek Sakrejda , Claudio Freire , Jeff Janes , Anibal David Acosta References: <005701cda238$ba4d0350$2ee709f0$@devshock.com> <201210051736.16460.andres@2ndquadrant.com> <10193.1349451965@sss.pgh.pa.us> In-Reply-To: <10193.1349451965@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: Text/Plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Message-Id: <201210051833.55615.andres@2ndquadrant.com> X-Provags-ID: V02:K0:lsrlnEmTjZ3jmYGoQq3zK5IqjPYdbrrPWNARPk1A0lK h3KuJczYyPJGiAOnik8AJARhcd0BU4hsJ+2Gmh2IbvLA1GoAoY 2BXjjGYCie7ImApsQ9kgm9lyjykIzbNSEtGoXH3UJ5Tac4vFTB IxkHgEyH0Zow1PyS11HBDUlhGhqQ5N1xEMZfcrLl3hYNg368F2 sK2CD7Iv2O6VAAI9wSdIzzt0APfM8k/D3W8Od3lzFeSfDhBIhF ov1IbZfuayIqtT+v8LqfbTDIIt643mQ+eYUeowSonQ7jt5cRNd oqjYe1ZgXY5+ALwp1VUqr7UjnPRzyUNyxAOuljf8HsWOtk5EbS BITCAPQN2EuAoLR5PtVz7G3Ha9MHMjNoUiCTPeryFHrqjilUA4 f4hSJZ7sghZ6g== X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201210/35 X-Sequence-Number: 47994 On Friday, October 05, 2012 05:46:05 PM Tom Lane wrote: > Andres Freund writes: > > On Friday, October 05, 2012 05:31:43 PM Tom Lane wrote: > >> There's no guarantee that the planner won't re-sort the rows coming from > >> the sub-select, unfortunately. > > > > More often than not you can prevent the planner from doing that by > > putting a OFFSET 0 in the query. Not 100% but better than nothing. > > No, that will accomplish exactly nothing. The ORDER BY is already an > optimization fence. Yea, sorry. I was thinking of related problem/solution. > > We really need ORDER BY for DML. > > Meh. That's outside the SQL standard (not only outside the letter of > the standard, but foreign to its very conceptual model) and I don't > think the problem really comes up that often. Back when I mostly did consulting/development on client code it came up about once a week. I might have a warped view though because thats the kind of thing you would ask a consultant about... > Having said all that, are we sure this is even a deletion-order > problem? I was wondering about deadlocks from foreign key references, > for instance. Absolutely not sure, no. Andres -- Andres Freund http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services