Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ts7Ne-00FVNs-O4 for pgsql-admin@arkaria.postgresql.org; Tue, 11 Mar 2025 21:43:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1ts7Nd-007b9h-Eh for pgsql-admin@arkaria.postgresql.org; Tue, 11 Mar 2025 21:43:17 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ts7Nd-007b9Y-1u for pgsql-admin@lists.postgresql.org; Tue, 11 Mar 2025 21:43:17 +0000 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1ts7NZ-002JQp-25 for pgsql-admin@lists.postgresql.org; Tue, 11 Mar 2025 21:43:16 +0000 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-4394345e4d5so35914175e9.0 for ; Tue, 11 Mar 2025 14:43:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1741729394; x=1742334194; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=uYwyn10G+EfdYM6+UgLxZQxK4wlQprI/X6awBEpBbHU=; b=KxwejSjtug6+NO3X4/1MQ5TE1ke4P7J+W6Ws1qQN5ln+tfPLHp8qxvldhmfqY5OnUA MnEx1OdDuFoD/fRUmzQMX8Sxqqnn01e4ofhCv/WtULBuEphKyoLJ2rEUuhjSKyyJeVAR 4vBr+SSGJ1FgV7l/gprIf9lz5JR0Xzz6OajYxjESsY8JUZTsROC0zDxn59ESnXYn3IHM 7DSQc3mYFnrM9dNBxFe8wcTh2ZgGaWYRoh+ga/jv1qmAkXue+Q7aCguRBP1ZfkxS+WyE ByrFqeIFfAq3kc4tRw9FG41U9BvRuK2fZXSFiPtrzdbxdKOkZuC8A+OAo+FFP6nJHFvo BQgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741729394; x=1742334194; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=uYwyn10G+EfdYM6+UgLxZQxK4wlQprI/X6awBEpBbHU=; b=pyM08uCnO0kJR4lUqiG/kEsIuTcp7yetBNmedkjp/eAT7lacb87wla4CWW3gXQAldQ 6VXR0pZvZIlMZDlG0RPMyjmi7Ldxi+FIiYZMlPcpRtrtF+RinNDcEKF6X5uEi3XdGUvX d8CwpW8oVoFLG9KGZV8tho2EhdX+lApXZizPjArIvyAiQIFeYab0N4APVIK+d8qUB/qh ZNprJ2xbRVkTvbZzG32FhTTgw57kigqy/VypVcYLVLlLoRbQ/xX4s8E/20WwDQgA75cT 45BoCmVDFcYV45Wu5NqFJ1dFsXuYPbkPQvim8x+KMMh678uQynhbcTVAwIUnVmQhIzRV hUWg== X-Forwarded-Encrypted: i=1; AJvYcCX2+U1NliK1ihbPd9I83lSoSbiBKjlMpUN1283rFIXbOBte/P2BS+wRr/DfIeIl1UQKvn2N7T3EWL+5tg==@lists.postgresql.org X-Gm-Message-State: AOJu0Yyh0GwpFUZ/Ysb+w/B1/bejkunBj8uT5I+EdRazCK0jffrh6csK PtZElpKiTN+LWZ1enWc14jhG4l765nXsi3HZvGixGgYpq/Y8++OdijLqa1dljyd4ztYoeGS9FC1 z X-Gm-Gg: ASbGnctvJxJ5y5pyW7Qh3FqgiT05iE9mIa/12+6/TsvyNUZBMu7BESJo+jEQ8mIncFt /WdFxF9HbmUABs8bLpgykdawing5DzZDPLeQjZolNDt59uowYA74dzyTyPYc26ZRDjMjqiJph9P duMIsrageb3ZGeQht/530bei03zAx71IAQbnJkDN85cYaoZnLFgyeP9RXJaRlFGhzl/Y4z9aPtH 1heHFVq95WA/asrRsn9krAmRav4HXhRZyzdtxgw7wyG3lG8gulKLsv/1FnwATVCwRbm7qyTFwnR Op7xDL963LCZDLc+lrB3zzT/vDxiE3wArDqSgIfk1RZwzJ7IYBM/TK28Kv7EWrNc0RHSXh0rG7h t X-Google-Smtp-Source: AGHT+IFvKWUC1EfTW+oMTuBykq6Mun3A3sWKy4dhlfWDz0ALvrpjkH41NJvi4jxauOvqfLSGchqbJg== X-Received: by 2002:a05:6000:1f8e:b0:391:4b8e:a200 with SMTP id ffacd0b85a97d-3914b8ea307mr9344132f8f.32.1741729393719; Tue, 11 Mar 2025 14:43:13 -0700 (PDT) Received: from localhost.localdomain ([2001:871:255:52d3:3ac8:61ab:b634:342]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43d0a8d0e01sm1508435e9.39.2025.03.11.14.43.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Mar 2025 14:43:13 -0700 (PDT) Message-ID: Subject: Re: On-disk postgres database size too large From: Laurenz Albe To: Maxwell Dreytser , "pgsql-admin@lists.postgresql.org" Date: Tue, 11 Mar 2025 22:43:12 +0100 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.54.3 (3.54.3-1.fc41) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, 2025-03-11 at 17:01 +0000, Maxwell Dreytser wrote: > I recently noticed that my PostgreSQL data directory has grown oddly larg= e. >=20 > Strangely the database that seems to take the most disk space is the syst= em > postgres database. Not the one that data is actually stored in. >=20 > Here are the sizes of all the folders inside the `/data/base` folder. >=20 > # du --max-depth=3D1 -x -h > 28G ./5 > 7.3M ./1 > 7.2M ./4 > 4.0K ./pgsql_tmp > 28G . >=20 > From what I understand, these folders should correspond to database OIDs,= so > I ran the following statement to investigate the database responsible: >=20 > SELECT oid, datname, pg_size_pretty(pg_database_size(datname)) db_size > FROM pg_database > ORDER BY pg_database_size(datname); >=20 > oid | datname | db_size > -------+-----------+--------- > 5 | postgres | 6612 kB > 1 | template1 | 6612 kB > 4 | template0 | 7329 kB > 16384 | data | 92 MB >=20 > OID 5 seems to be the postgres database, not the "data" database that is > actually being used and one of the databases even scratch 100MB.=20 >=20 > So, I decided to try to do a full vacuum in case something was broken in > the autovacuum config. So, I ran `vacuumdb --full --analyze --all --verbo= se -U postgres`. > Judging from the output nothing really got cleaned up and there are > `0 dead row versions cannot be removed yet.` for all tables.=20 >=20 > No change in data size on disk. >=20 > Here are the top few files in the `/data/base/5` folder: >=20 > /data/base/5# ls -lahS > total 28G > -rw------- 1 1001 aad_admins 324M Mar 3 05:07 423445 > -rw------- 1 1001 aad_admins 323M Feb 27 05:05 421330 > -rw------- 1 1001 aad_admins 323M Feb 21 05:07 409693 > -rw------- 1 1001 aad_admins 323M Feb 23 05:12 410429 > -rw------- 1 1001 aad_admins 322M Mar 4 05:03 423919 > -rw------- 1 1001 aad_admins 322M Mar 3 05:02 423128 > -rw------- 1 1001 aad_admins 322M Mar 11 05:35 427725 >=20 > I tried grabbing the latest one to try to pin down what exactly is in tha= t > file, but no luck there: >=20 > SELECT relname, relnamespace::regnamespace, relkind > FROM pg_class WHERE relfilenode =3D 427725; >=20 > relname | relnamespace | relkind > ---------+--------------+--------- > (0 rows) >=20 > At this point I am quite stumped. What else can I look at to clean up som= e > space. I am running PostgreSQL 16.3. One very odd thing is that there is no directory named "16384" in the "base= " directory. Unless you are using tablespaces (check pg_tablespace), that ca= n mean only one thing: you are looking at the data directory of a different cluster. You can examine the value of the "data_directory" parameter to be certain. Yours, Laurenz Albe