pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andres Freund <andres@2ndquadrant.com>
To: pgsql-performance@postgresql.org
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Maciek Sakrejda <m.sakrejda@gmail.com>
Cc: Claudio Freire <klaussfreire@gmail.com>
Cc: Jeff Janes <jeff.janes@gmail.com>
Cc: Anibal David Acosta <aa@devshock.com>
Subject: Re: how to avoid deadlock on masive update with multiples delete
Date: Fri, 5 Oct 2012 17:36:14 +0200
Message-ID: <201210051736.16460.andres@2ndquadrant.com> (raw)
In-Reply-To: <9895.1349451103@sss.pgh.pa.us>
References: <005701cda238$ba4d0350$2ee709f0$@devshock.com>
	<CAOtHd0A0UNJYTeVDsn6uY2d-6f2+=s5EkQFwNV0ASa4PqAk8yw@mail.gmail.com>
	<9895.1349451103@sss.pgh.pa.us>

On Friday, October 05, 2012 05:31:43 PM Tom Lane wrote:
> Maciek Sakrejda <m.sakrejda@gmail.com> writes:
> > Presumably something like this?:
> > maciek=# CREATE TABLE test AS SELECT g, random() FROM
> > generate_series(1,1000) g;
> > CREATE
> > maciek=# EXPLAIN DELETE FROM test USING (SELECT g FROM test ORDER BY
> > ctid) x where x.g = test.g;
> 
> 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.

We really need ORDER BY for DML.

Andres
-- 
Andres Freund		http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services




view thread (13+ messages)  latest in thread

Message-ID: <201210051736.16460.andres@2ndquadrant.com>
Permalink:  ../201210051736.16460.andres@2ndquadrant.com/
Also on:    postgresql.org/message-id/201210051736.16460.andres@2ndquadrant.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 using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: andres@2ndquadrant.com, tgl@sss.pgh.pa.us, m.sakrejda@gmail.com, klaussfreire@gmail.com, jeff.janes@gmail.com, aa@devshock.com
  Subject: Re: how to avoid deadlock on masive update with multiples delete
  In-Reply-To: <201210051736.16460.andres@2ndquadrant.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