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 1jbRik-0002Ph-Lm for pgsql-general@arkaria.postgresql.org; Wed, 20 May 2020 16:37:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jbRij-0004aN-I5 for pgsql-general@arkaria.postgresql.org; Wed, 20 May 2020 16:37:29 +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 1jbRij-0004XN-5j for pgsql-general@lists.postgresql.org; Wed, 20 May 2020 16:37:29 +0000 Received: from mail-oi1-x242.google.com ([2607:f8b0:4864:20::242]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jbRih-0005Jp-45 for pgsql-general@lists.postgresql.org; Wed, 20 May 2020 16:37:28 +0000 Received: by mail-oi1-x242.google.com with SMTP id i22so3481371oik.10 for ; Wed, 20 May 2020 09:37:26 -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=0Q2N/2EGIJYsyrc/MeZfZya7paxcDCyZXzI76q8CP7s=; b=khF0p4mVmRAATUVakthRo3z3okNj1otYSIAYpsVpeJqkzSJdoTAWBjPQ/TPzwlNubT CpjH9fYbXmZkxLwC4A0RoThMi0f1iLgLLZVRk37MKeTnS+wGUbwlPT9Vtt3E0VVXxHSG YHXSbbM9QNzT8Yc4XqiFny5icIJwWjQkbcWw7N+Dq4JHEMsQacmik9wVp5CquuUyfok6 Nca9GBnMKpcxwwUmry55O7YuJQ2+sIedNaoyUrVkr9Je3J3UH91Fnzu9T/l1Eo9hMidk 5XT2pNcNk90jWEq1GajRzKabOdKjq8UUp24QoUwHkKR0qMD9YP83ed83jjGld7bNvnR3 Xggw== 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=0Q2N/2EGIJYsyrc/MeZfZya7paxcDCyZXzI76q8CP7s=; b=izk9ocNyfqk4pXeiANU/XRpKHW6v6vxZuh4PTJQ+mNn+oWO9XxBkiBrjewrJllmFYv spz770H/fVdoNwsNT0rPVPuhos1biVC4EIaPgjqsOcM+yhnv/hEKAR++vU+z8ieTOwdu ZEiygDJm5pU2JDV8RVlWEPDlJZvAQO7kjYiUfpiBL8+aNdDOqGdgD/0nfcraNtgpfobT 9A/FGY/8aqXiob+36fTf5eGQ3fAi0WGws/DV7fthgGPieoTWa9i0N9CHU7BIMKiDp39f doKrn3VFrZ5GghYjaEs9bmbS/+rJqD7NVRKDEcBsbuc+ZCttrFwcpEh08Ze1uyQjYaLt RwGw== X-Gm-Message-State: AOAM530/lwcGdginALqyd/vUZTozhYpTlWnwZwMnQZzoH0EuAMvqiUZW dQNYm8sQbirKLMhnbLyvSvT80lP4jkU= X-Google-Smtp-Source: ABdhPJzpMfHkSkuuAsF4VjzdlFJ0atTLIxbrh8fpg7BCRpEUCuCAhawOQ1s7VoZ129zHEzjv1b2b8Q== X-Received: by 2002:a05:6808:7de:: with SMTP id f30mr3905025oij.86.1589992645636; Wed, 20 May 2020 09:37:25 -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 d64sm891132oig.53.2020.05.20.09.37.24 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 20 May 2020 09:37:24 -0700 (PDT) Subject: Re: Huge tables, trying to delete OID's taking 6+hours per table To: "pgsql-generallists.postgresql.org" References: <27067.1589895643@sss.pgh.pa.us> <0c0d572a-95ad-42ec-6977-8cd744ad0065@gmail.com> From: Ron Message-ID: <36724f6a-4d02-4083-b602-72f4701e5973@gmail.com> Date: Wed, 20 May 2020 11:37:23 -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="------------E482D8125BB25162E9947938" 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. --------------E482D8125BB25162E9947938 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 5/20/20 11:22 AM, Tory M Blue wrote: > > > On Tue, May 19, 2020 at 10:06 AM Ron > wrote: > > 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. > > > Thanks Ron, > > Looked into this but we have large indexes that take 8-12 hours to create. > So my gut says this would not buy us anytime. Since the index creation would be separate from your application's access, it doesn't actually matter. > Also this has been running for 16 hours now and still not done. I think > it's forcing index creation regardless. > If it's rewriting the table's pages, then the indexes must be rewritten, too, When removing OIDs, is the priority to minimize absolute time, or to minimize downtime/degradation as sen by the application? -- Angular momentum makes the world go 'round. --------------E482D8125BB25162E9947938 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit On 5/20/20 11:22 AM, Tory M Blue wrote:


On Tue, May 19, 2020 at 10:06 AM Ron <ronljohnsonjr@gmail.com> wrote:
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.

Thanks Ron,

Looked into this but we have large indexes that take 8-12 hours to create. So my gut says this would not buy us anytime.

Since the index creation would be separate from your application's access, it doesn't actually matter.

Also this has been running for 16 hours now and still not done. I think it's forcing index creation regardless.


If it's rewriting the table's pages, then the indexes must be rewritten, too,

When removing OIDs, is the priority to minimize absolute time, or to minimize downtime/degradation as sen by the application?

--
Angular momentum makes the world go 'round.
--------------E482D8125BB25162E9947938--