Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eR0hB-0000W0-3I for pgsql-general@arkaria.postgresql.org; Mon, 18 Dec 2017 19:03:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eR0hA-00047f-7h for pgsql-general@arkaria.postgresql.org; Mon, 18 Dec 2017 19:03:24 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eR0h9-00047U-QY for pgsql-general@lists.postgresql.org; Mon, 18 Dec 2017 19:03:24 +0000 Received: from mail-qt0-x233.google.com ([2607:f8b0:400d:c0d::233]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1eR0h3-00065l-Ar for pgsql-general@postgresql.org; Mon, 18 Dec 2017 19:03:22 +0000 Received: by mail-qt0-x233.google.com with SMTP id g10so21282807qtj.12 for ; Mon, 18 Dec 2017 11:03:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:content-transfer-encoding:mime-version:subject:message-id:date :to; bh=er0vFbo6LbGbXKLb8b7z1jZlDzBSC1jKU7RtWKcCwt4=; b=lSD15hgSTymA19NnjtXwoSCgAaV4ytGtc2B1l9BhNkhJKlfztidnGsCvz9GOS7lS45 aa1vhfBFuxD62/Rvw+gDHOmIzMRNRQa8e8bN8c/GuCombThmbbey2ReengUc60XMFTSy STNtxstUXnlUrIEpQmVT7uqPW0QkCyI70G71hi+oXiqd7Ue3I4fdqI3vnKonhWyld/MT oORaV65xx47ET4GZ4Ksq5T6dVRjqRFcvvd3HVpoyBrBmi55sTYZyKMnixv+CWNWeHNOV w081NbupV39kS6E78xFheRrNwfcYwuTFZYtIKSSo/ht13ZT9FBhbZwMntjxN/6R8XHyH EJow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:content-transfer-encoding:mime-version :subject:message-id:date:to; bh=er0vFbo6LbGbXKLb8b7z1jZlDzBSC1jKU7RtWKcCwt4=; b=SyhoEYJpYbtPEOsAFmUW+6Xj+spncs5DSuqS0R5BgGT9/Df+sE2rsmEM0JezCCMlYb 73bLheTPu+7src7XTJJJOS+VJMuwcW4YlP17PCE8YDsUVfNj3JG8uk6h4iujWOPGhTgx aVzSzPoMII8UHLkQFNDbo4+SztOIoZ0Jhy2LyT676/7bQ7WvDXmW3BSh7cyb0hgdsn7i u5I2oCyeQinD+XgArpyHZhKadpAAia4fzeOG9Mz+w481y+oYlLKi6Xgk306rXD/sNCVd BxHMmPZTFLtDuAxyJKWYSIc3Wh+/PNtR5x5ZkgmiYIrteZzcrjVrhkneYTGpr0//EaAZ BYdA== X-Gm-Message-State: AKGB3mL0RlaAeHYgODN1YOPYf0yAKppjt+xT/uxNX2E1mXxurUPhVLp7 2Y4MMCHukKf8hr/27hgPkale9v3I X-Google-Smtp-Source: ACJfBou/sWFkriWwqbG9zCsllG+AJumz27k7evrbblstZftIKgBkaYK05pSRTDROtXnG9c2EDNf/WQ== X-Received: by 10.200.50.206 with SMTP id a14mr1046190qtb.59.1513623796023; Mon, 18 Dec 2017 11:03:16 -0800 (PST) Received: from roberts-mbp.lan (pool-108-26-156-13.bstnma.fios.verizon.net. [108.26.156.13]) by smtp.gmail.com with ESMTPSA id k21sm8677389qta.27.2017.12.18.11.03.15 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Dec 2017 11:03:15 -0800 (PST) From: Rob Nikander Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 11.2 \(3445.5.20\)) Subject: reclaiming space from heavily used tables? Message-Id: <8034843E-CB75-4272-B89D-B9462161275B@gmail.com> Date: Mon, 18 Dec 2017 14:03:14 -0500 To: Postgres General X-Mailer: Apple Mail (2.3445.5.20) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, I've got a large table from which I'd like to completely reclaim space. = I read the docs and it sounds like I can=E2=80=99t run `vacuum full`, = because this table is accessed constantly and can=E2=80=99t have = downtime. Assuming that=E2=80=99s true, what do you think of the = following idea? Is there a better alternative? 1. Replace the table T with two tables T1 and T2 and a view T that is = `select * from T1 union T2`. 2. Write only to T1, and slowly move records from T2 to T1.=20 3. When T2 is empty, redefine the view T to be simply `select * from = T1`. 4. Recreate or vacuum full T2, so space is fully reclaimed. 5. Redefine view as the union select and repeat process going other = direction from T1 to T2, as needed. I guess one question is whether I can do 1 and 3 (renaming tables, = redefining views) atomically without disturbing concurrent select = queries. Rob