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 1jb5hU-0007Ai-UG for pgsql-general@arkaria.postgresql.org; Tue, 19 May 2020 17:06:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jb5hT-0000eM-Lo for pgsql-general@arkaria.postgresql.org; Tue, 19 May 2020 17:06:43 +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 1jb5hT-0000dM-DA for pgsql-general@lists.postgresql.org; Tue, 19 May 2020 17:06:43 +0000 Received: from mail-ot1-x335.google.com ([2607:f8b0:4864:20::335]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jb5hR-0000pF-9N for pgsql-general@lists.postgresql.org; Tue, 19 May 2020 17:06:42 +0000 Received: by mail-ot1-x335.google.com with SMTP id z3so68110otp.9 for ; Tue, 19 May 2020 10:06:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=qqW/WB9J3MD/D7cWNYNNbpkrIVzTXYgw257fmud8P2I=; b=atuoy7Q+2tD0ouLIB/mHdznmKS1zeSPgjN97UkZ/zy1OJzYMojko/6J+TBrtzmH6Zh t+qywly0QWrH7LpOnzlaAMnUUrb7gerancYLSyBaGqZCg7og02DFA8IhjhuzzRmlMGor MO4nOWq6V8CSJugRPd/rfllLoo7vb516/q+hKfJB3pQDyGCw7XNuR1t+kYHqUr/WU6Zd zfzAeWga/SIWGPozH6bA9RCG+lmI8tcZqK1Z0/k7paFFZ99SctfDfYu9Y13velNawmPj C1qnPdemeAiP9GuDcHn7KCjbJ99BuNOf+Um57IadkBzjc2rL+zbrLFBhWqeOsZ6IgcYL ex8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=qqW/WB9J3MD/D7cWNYNNbpkrIVzTXYgw257fmud8P2I=; b=LmoA4ysGUiY/+kBSF+7Ogwvd94PBmVoHO1ordflJq2A3s7F7OZ/L8kGWm+gtMImZAo aVeZk4/1vvqkpsV6/ero3ODo74ktqWjvit0YhTzx6AvPQSquxRdy4v+9y23W0bzss4J/ 1OOX3A3z2paED0WnePk9hJvD5Q/XFSNGpUFx/qn2neaa2lFg6Kji/9Xuj+w7eQ1jVtg4 aJfkGCfCoKQ6WEXH9pD8dMInNcUHcMN1tS/skBHuDhaupuQUD3rxaasgMfIqIEzvnJFo ugVELdElAUzU8C+HXu9pKNRD8kecgDXfeVrFSjXqUV1R2HbMlOq49+N4QyXwihkW9lsE fIKg== X-Gm-Message-State: AOAM532uRtIyRQwIBZB6UXH94Zzrc/047ePw9+MstyqQc12hNc4hSeVN +ndsT+Po75KpSTlLy1TB6/UCgor1KDk= X-Google-Smtp-Source: ABdhPJzGpM5EoKdDdP07BoSQKJLbGgn7ogLp9tce4FUh04gYwjqSN2us/V/4/9SPkkM1B8EuVx2pig== X-Received: by 2002:a9d:6b05:: with SMTP id g5mr17688otp.103.1589907999968; Tue, 19 May 2020 10:06:39 -0700 (PDT) Received: from [192.168.1.10] (ip70-186-126-197.no.no.cox.net. [70.186.126.197]) by smtp.googlemail.com with ESMTPSA id z14sm47328oth.17.2020.05.19.10.06.38 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 19 May 2020 10:06:39 -0700 (PDT) Subject: Re: Huge tables, trying to delete OID's taking 6+hours per table To: pgsql-general@lists.postgresql.org References: <27067.1589895643@sss.pgh.pa.us> From: Ron Message-ID: <0c0d572a-95ad-42ec-6977-8cd744ad0065@gmail.com> Date: Tue, 19 May 2020 12:06:38 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------3BD3910B8591B7A66E2F3646" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------3BD3910B8591B7A66E2F3646 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 5/19/20 11:51 AM, Tory M Blue wrote: > > > On Tue, May 19, 2020 at 6:40 AM Tom Lane > wrote: > > Tory M Blue > writes: > > The command i'm using is > > ALTER TABLE tablename SET WITHOUT OIDS; > > Would a drop column oid be better? > > Unfortunately, you're kind of stuck.  OIDs are not like regular columns > (at least before v12) --- they are integrated into the tuple header in > a hackish way, and so there's no way to get rid of them without a table > rewrite. > >                         regards, tom lane > > > Poop :) kind of figured that, so it's just painful. > > But  I guess if it's doing a table rewrite, is there any configuration > params I could boost to help it? Shared_buffers, give it more, work mem, > maintenance mem, temp buffers anything you can think of? There's an alternative if this is a "transaction table" (named, in this example, FOO) which never gets updated (only inserted into and selected from). Create a new, partitioned, oid-free copy of the table (named NEW_FOO) that's populated with *most* of the records (all except the most recent).  When ready to cut over, you'd stop the applications, copy over the most current records from FOO to NEW_FOO and then rename FOO to OLD_FOO and FOO to OLD_FOO. Then you can drop OLD_FOO. -- Angular momentum makes the world go 'round. --------------3BD3910B8591B7A66E2F3646 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit On 5/19/20 11:51 AM, Tory M Blue wrote:


On Tue, May 19, 2020 at 6:40 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
Tory M Blue <tmblue@gmail.com> writes:
> The command i'm using is
> ALTER TABLE tablename SET WITHOUT OIDS;
> Would a drop column oid be better?

Unfortunately, you're kind of stuck.  OIDs are not like regular columns
(at least before v12) --- they are integrated into the tuple header in
a hackish way, and so there's no way to get rid of them without a table
rewrite.

                        regards, tom lane

Poop :) kind of figured that, so it's just painful.

But  I guess if it's doing a table rewrite, is there any configuration params I could boost to help it? Shared_buffers, give it more, work mem, maintenance mem, temp buffers anything you can think of?

There's an alternative if this is a "transaction table" (named, in this example, FOO) which never gets updated (only inserted into and selected from).

Create a new, partitioned, oid-free copy of the table (named NEW_FOO) that's populated with most of the records (all except the most recent).  When ready to cut over, you'd stop the applications, copy over the most current records from FOO to NEW_FOO and then rename FOO to OLD_FOO and FOO to OLD_FOO.

Then you can drop OLD_FOO.

--
Angular momentum makes the world go 'round.
--------------3BD3910B8591B7A66E2F3646--