Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TKCil-0000qw-Tg for pgsql-performance@postgresql.org; Fri, 05 Oct 2012 18:33:59 +0000 Received: from mail-gg0-f174.google.com ([209.85.161.174]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TKCii-0002Bi-6K for pgsql-performance@postgresql.org; Fri, 05 Oct 2012 18:33:59 +0000 Received: by mail-gg0-f174.google.com with SMTP id r5so575762ggn.19 for ; Fri, 05 Oct 2012 11:33:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:references:in-reply-to:subject:date:message-id :mime-version:content-type:content-transfer-encoding:x-mailer :thread-index:content-language:x-gm-message-state; bh=7H9fb27pLYHBhcuO2/FJV32lWo3NFGTEWvVtpux4k+o=; b=esS1jHWGPFbMHdPyBgnWl/KaCdg1fjSkxCx/w8HjOBRCnA1KK0cYfip42uPzCSk7HF z8sMWKJ/Bvn/0bnEEq50InjD4d7mVnq/dpTyqfMg4tWgd5sv7JQHFTNz/7CiTplOtZjG /++OGskufrqHcy49JJgeX4/gpJyiQqBKMprNbHythwgxCNlDyGm9Y3SmUK7gSqIHA0lL dYsXtsozwXNkYD7D+07PHrfXvLWh81BABfoJlxawPLMr34Fy/0UhYwTttLf7KKLRP9tX gnAHBLhRfpZHXairDAHiFzLXlC3CRI3XG9nZHaE8XRfWPqSMTWzRn7bCbAPo8Ekstq65 J/iw== Received: by 10.236.161.233 with SMTP id w69mr9183934yhk.74.1349462034559; Fri, 05 Oct 2012 11:33:54 -0700 (PDT) Received: from AnibalVAIO ([190.128.222.90]) by mx.google.com with ESMTPS id p1sm3717277anj.13.2012.10.05.11.33.51 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 05 Oct 2012 11:33:53 -0700 (PDT) From: "Anibal David Acosta" To: "'Claudio Freire'" , "'Jeff Janes'" Cc: References: <005701cda238$ba4d0350$2ee709f0$@devshock.com> In-Reply-To: Subject: Re: how to avoid deadlock on masive update with multiples delete Date: Fri, 5 Oct 2012 14:33:49 -0400 Message-ID: <011201cda327$f99d73b0$ecd85b10$@devshock.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQHzC99ysmZx4K05UeiKZt/Jz1ndJAFwPJ/CAjL01aGXQx14wA== Content-Language: es-py X-Gm-Message-State: ALoCoQkiIzzqQ90P0VtrxXa7lIKvrVnQZCNtjaCVkKKgSzSrsJkGdm6JazZ7NT7DuqJtk0eLlcGr X-Pg-Spam-Score: -2.6 (--) X-Archive-Number: 201210/36 X-Sequence-Number: 47995 Process 1 (massive update): update table A set column1=0, column2=0 Process 2 (multiple delete): perform delete_row(user_name, column1, column2) from table A where user_name=YYY The pgsql function delete_row delete the row and do other business logic not related to table A. -----Mensaje original----- De: Claudio Freire [mailto:klaussfreire@gmail.com] Enviado el: viernes, 05 de octubre de 2012 10:27 a.m. Para: Jeff Janes CC: Anibal David Acosta; pgsql-performance@postgresql.org Asunto: Re: [PERFORM] how to avoid deadlock on masive update with multiples delete On Thu, Oct 4, 2012 at 1:10 PM, Jeff Janes wrote: > The bulk update could take an Exclusive (not Access Exclusive) lock. > Or the delete could perhaps be arranged to delete the records in ctid > order (although that might still deadlock). Or you could just repeat > the failed transaction. How do you make pg update/delete records, in bulk, in some particular order? (ie, without issuing separate queries for each record)