Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nfioT-0003km-Iv for pgsql-general@arkaria.postgresql.org; Sat, 16 Apr 2022 13:50:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nfioS-0002ra-3L for pgsql-general@arkaria.postgresql.org; Sat, 16 Apr 2022 13:50:08 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nfioR-0002q4-Mb for pgsql-general@lists.postgresql.org; Sat, 16 Apr 2022 13:50:07 +0000 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nfioO-0000NQ-2r for pgsql-general@lists.postgresql.org; Sat, 16 Apr 2022 13:50:06 +0000 Received: by mail-pl1-x634.google.com with SMTP id be5so9066780plb.13 for ; Sat, 16 Apr 2022 06:50:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :references:from:in-reply-to; bh=2qLnf/aP8Lo9Tt0ZiPeY149DWnLu1NUEhazQraF8Ek4=; b=Y2YX2q+xVnuN1MxMA2P53GyfiihrXy8+xm2z0plW1hfiZRvdXnzqhL22hYm2C6p+8o LhAm8Y1Am8TDlqMu6W4ZpY2vrYCNACpdrIVboXGr4e3vc/6+UA7kx75Kbr4juZ03Ri3r 6Ot0VtJLXxUTMl+SYYyN4eX2uWeMR3CNLZzH7tk6rNFEd82fwJOA+pBD5HInpwpla+4a VopEStjGBSeNwZG6pDjDtGnJV4Szu9R2omHRdP7WghfhBPkEcu6lnYgfpYq1dkAbuA5A vzvNvqAYbrmFTQnxbngl5B9tk5Ww2pg08Pmsv8ZHv5Vs6Ia65x3X4ltVUH4NvRW/8YKa zLzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to; bh=2qLnf/aP8Lo9Tt0ZiPeY149DWnLu1NUEhazQraF8Ek4=; b=iUwXGuwY3ub+i/nh58fSqhgUjYASnbOGbLmPJzObhY5jaAugrI3GjZ/LkbOK8ErBpf eUiMrTx22tljsIBSPIdgYB7OQILGgPg1/KZjwUsqBWF3drzj6a+X3+lHf7yUu2KtaZAi LWMQbmBTKZ0HXoSD/vz0zttSnxBlAAUfn0ZqzqTYcnGrmv1PnfqMDY2dxak4U/eQ3TwT BxsNFnoy07pP3WE2tPiW/LNcHTaBn5meLoEQv6SgfdWM02gW6vbK0X5y1CXh2DeEUgMZ PrNqQaq77fF90tBsKMb0WVER1IBktyFOZgwZbY5Q31Bx7Zfh3ARLKY/un6mZz0wvV7AP fzdw== X-Gm-Message-State: AOAM5304AuIuKWODpPCBPjonDlvaJEDxBOpGMkc1FoZrRHuoW/qR9szi Mza53o/dPGiZ5QpmdmM9nr+ozXeQiSQ= X-Google-Smtp-Source: ABdhPJymuqYFO6Kw+Oeipmf0sMsTrloPjwPSkGjFb45ZagWuHIfrEdnjELLMQj4I2Bu75EhKof2Gpw== X-Received: by 2002:a17:903:11c7:b0:151:9769:3505 with SMTP id q7-20020a17090311c700b0015197693505mr3524810plh.72.1650117002294; Sat, 16 Apr 2022 06:50:02 -0700 (PDT) Received: from [10.128.71.194] ([155.98.131.2]) by smtp.gmail.com with ESMTPSA id y21-20020a631815000000b0039fcedd7bedsm7690538pgl.41.2022.04.16.06.50.01 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 16 Apr 2022 06:50:01 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------CRLpSV4nE6uCtpsIun6u3NmV" Message-ID: <70cfeae1-bf2b-09c5-3f31-b708e4bc39e9@gmail.com> Date: Sat, 16 Apr 2022 07:50:00 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: Help with large delete Content-Language: en-CA To: pgsql-general@lists.postgresql.org References: <3823FD54-2910-41E5-B908-869DA917DE82@easesoftware.com> From: Rob Sargent In-Reply-To: <3823FD54-2910-41E5-B908-869DA917DE82@easesoftware.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------CRLpSV4nE6uCtpsIun6u3NmV Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 4/16/22 07:25, Perry Smith wrote: > Currently I have one table that mimics a file system. Each entry has a parent_id and a base name where parent_id is an id in the table that must exist in the table or be null with cascade on delete. > > I’ve started a delete of a root entry with about 300,000 descendants. The table currently has about 22M entries and I’m adding about 1600 entries per minute still. Eventually there will not be massive amounts of entries being added and the table will be mostly static. > > I started the delete before from a terminal that got detached. So I killed that process and started it up again from a terminal less likely to get detached.˘ > > My question is basically how can I make life easier for Postgres? I believe (hope) the deletes will be few and far between but they will happen from time to time. In this case, Dropbox — its a long story that isn’t really pertinent. The point is that @#$% happens. > > “What can I do” includes starting completely over if necessary. I’ve only got about a week invested in this and its just machine time at zero cost. I could stop the other processes that are adding entries and let the delete finish if that would help. etc. > > Thank you for your time, > Perry > I would try 1) find any nodes with disproportionately more nodes, deal with them separately.  You my have a gut feel for where these nodes are? 2) Start at least one step down: run a transaction for each entry in root node.  Maybe go two levels down. --------------CRLpSV4nE6uCtpsIun6u3NmV Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
On 4/16/22 07:25, Perry Smith wrote:
Currently I have one table that mimics a file system.  Each entry has a parent_id and a base name where parent_id is an id in the table that must exist in the table or be null with cascade on delete.

I’ve started a delete of a root entry with about 300,000 descendants.  The table currently has about 22M entries and I’m adding about 1600 entries per minute still.  Eventually there will not be massive amounts of entries being added and the table will be mostly static.

I started the delete before from a terminal that got detached.  So I killed that process and started it up again from a terminal less likely to get detached.˘

My question is basically how can I make life easier for Postgres?  I believe (hope) the deletes will be few and far between but they will happen from time to time.  In this case, Dropbox — its a long story that isn’t really pertinent.  The point is that @#$% happens.

“What can I do” includes starting completely over if necessary.  I’ve only got about a week invested in this and its just machine time at zero cost.  I could stop the other processes that are adding entries and let the delete finish if that would help.  etc.

Thank you for your time,
Perry

I would try 1) find any nodes with disproportionately more nodes, deal with them separately.  You my have a gut feel for where these nodes are? 2) Start at least one step down: run a transaction for each entry in root node.  Maybe go two levels down.

--------------CRLpSV4nE6uCtpsIun6u3NmV--