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 1q6vP4-0007hw-GL for pgsql-hackers@arkaria.postgresql.org; Wed, 07 Jun 2023 15:48:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1q6vP3-0005eS-3L for pgsql-hackers@arkaria.postgresql.org; Wed, 07 Jun 2023 15:48:53 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q6vP2-0005eI-Pq for pgsql-hackers@lists.postgresql.org; Wed, 07 Jun 2023 15:48:52 +0000 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1q6vOv-000oYD-U2 for pgsql-hackers@postgresql.org; Wed, 07 Jun 2023 15:48:52 +0000 Received: by mail-pj1-x102a.google.com with SMTP id 98e67ed59e1d1-256c8bed212so2851753a91.3 for ; Wed, 07 Jun 2023 08:48:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686152923; x=1688744923; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=aYdtEtVN+pc1/5F+hDyvJNRZ9cwS9wiCJGAjZRXhxNA=; b=WVOMDC8WZs70fzW94LKAfnfzIoCF+G4445cUGBa9BXalXRjaTx9i2YKoWlbFsGzgpa SJ4st0/N5pU20g91nMyutfro4AkSGvRFWHUEBRq+mE7SvlUpowzlvlVWDEUeFR14R6Xa n3vSp44pBQ3geZlfJzxPqhsEWtkngUJrCLekEW8XCEo6IbqfsI9UuqiY+rc9gPZZiHp0 PxZvHK+z7v0fjve8UczD1dB77gDN7vLV9bMhlMc5iRR+plx3j/B/A5WUpQbJfbHEjl0K aopYg6MJvaBYABhN4aUFwxesoABPdOuKGRwe3fdvZX97A82XA+MKYWUpubGi8i/veG8D c6vA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686152923; x=1688744923; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=aYdtEtVN+pc1/5F+hDyvJNRZ9cwS9wiCJGAjZRXhxNA=; b=iPQh4joAjAHYK4lBuxfRPo0mCVW8gdN3FZzwYM58b15JTsCf/nV+eV0TIRkmbSWg7j /z1/5gXYoPEtqvLaH/8KaiPj9/H3io1uO0vVyrgVg4VWxsh8ptt0Yqh78tW/BvKLQDh1 aFPYlJpTflnZuEJLRKwcAXPXBKe0JEoF6/S8EG/ziDXu5ijQYzuhQAGwcbRJ23JD42CC 6qq75TchIhGlWZGrVAgg6VM3hJlHTtO3CS26x9ipgFONNQv2z4uaOpt6G1drPIy31o/c cumhQcYKvlEotR27//VpMAOTGFobnatZ8aiB3zRWsSMT/qwJR0uzj0ZyRqpR6dnZBWgD g38g== X-Gm-Message-State: AC+VfDxC+QugX0RTtvV/7jr+PDOmyHdj9qKWVuUd8GEjeUlV6moqeu1I BGG7nw9UTyWWqH4npMtsQxoSQd3cWS7kXgimHANfSfat06Drwg== X-Google-Smtp-Source: ACHHUZ4EllJbDDXPVBZ32KYmoA0NkDVDd/E9LFoYVvs9DpnpBjafPnChnjtjQsiomQEGrC+XWcuyKKIlLy34hduSDfs= X-Received: by 2002:a17:90b:23ca:b0:256:2c8e:3008 with SMTP id md10-20020a17090b23ca00b002562c8e3008mr1547633pjb.48.1686152923412; Wed, 07 Jun 2023 08:48:43 -0700 (PDT) MIME-Version: 1.0 From: Isaac Morland Date: Wed, 7 Jun 2023 11:48:32 -0400 Message-ID: Subject: Disk space not released after schema deletion To: PostgreSQL Hackers Content-Type: multipart/alternative; boundary="000000000000097f4805fd8c126c" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000097f4805fd8c126c Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable The usual question is =E2=80=9Cwhy did DELETE not release disk space?=E2=80= =9D, and I understand why that is and something about how to get the space back (VACUUM). I have a database which hosts multiple applications in various schemas and I=E2=80=99m trying to make test/sample data files by starting with a restor= ed copy of production and then dropping all schemas except for the ones I need for a particular application. The total size of all relations after the drop operations is just a few MB: odyssey=3D# select sum (pg_total_relation_size (oid)) from pg_class; sum ---------- 13877248 (1 row) Yet the database size is still large (although much smaller than in the original database): odyssey=3D# select datname, pg_database_size (oid) from pg_database; datname | pg_database_size -----------+------------------ postgres | 8930083 _repmgr | 654934531 template0 | 8643075 template1 | 8864547 odyssey | 14375453475 (5 rows) The only change made after starting from a basebackup of production was to set all the passwords to NULL in pg_authid, and to delete most of the schemas. In particular, I wouldn=E2=80=99t expect VACUUM to do anything. Does anybody know what could be holding all that space? --000000000000097f4805fd8c126c Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
The usual question is =E2=80=9Cwhy did DELETE not release = disk space?=E2=80=9D, and I understand why that is and something about how = to get the space back (VACUUM).

I have a database which = hosts multiple applications in various schemas and I=E2=80=99m trying to ma= ke test/sample data files by starting with a restored copy of production an= d then dropping all schemas except for the ones I need for a particular app= lication.

The total size of all relations after th= e drop operations is just a few MB:

odyssey=3D# se= lect sum (pg_total_relation_size (oid)) from pg_class;
=C2=A0 =C2=A0sum = =C2=A0 =C2=A0
----------
=C2=A013877248
(1 row)

=
Yet the database size is still large (although much smaller than= in the original database):

odyssey=3D# select dat= name, pg_database_size (oid) from pg_database;
=C2=A0 datname =C2=A0| pg= _database_size
-----------+------------------
=C2=A0postgres =C2=A0|= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A08930083
=C2=A0_repmgr =C2=A0 | =C2=A0= =C2=A0 =C2=A0 =C2=A0654934531
=C2=A0template0 | =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A08643075
=C2=A0template1 | =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A08864547
=C2=A0odyssey =C2=A0 | =C2=A0 =C2=A0 =C2=A014375453475
(5 = rows)

The only change made after starting from= a basebackup of production was to set all the passwords to NULL in pg_auth= id, and to delete most of the schemas. In particular, I wouldn=E2=80=99t ex= pect VACUUM to do anything.

Does anybody know what= could be holding all that space?
--000000000000097f4805fd8c126c--