public inbox for [email protected]
help / color / mirror / Atom feedFrom: said assemlal <[email protected]>
To: Christoph Berg <[email protected]>
To: PostgreSQL Hackers <[email protected]>
Subject: Re: Available disk space per tablespace
Date: Thu, 24 Apr 2025 15:26:24 -0400
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
Hi,
I also tested the patch on Linux mint 22.1 with the btrfs and ext4
partitions. I generated some data and the outcome looks good:
postgres=# \db+
List of tablespaces
Name | Owner | Location | Access
privileges | Options | Size | Free | Description
------------------+----------+---------------------------+-------------------+---------+---------+---------+-------------
pg_default | postgres | | | | 1972 MB
| 29 GB |
pg_global | postgres | | | | 556 kB
| 29 GB |
tablespace_test2 | postgres | /media/said/queryme/pgsql
| | | 3147 MB | 1736 GB |
Numbers are the same as if I were executing the command: df -h
tablespace_test2 was the ext4 partition on usb stick.
Numbers are correct.
Said
On 2025-03-13 14 h 10, Christoph Berg wrote:
> Hi,
>
> I'm picking up a 5 year old patch again:
> https://www.postgresql.org/message-id/flat/20191108132419.GG8017%40msg.df7cb.de
>
> Users will be interested in knowing how much extra data they can load
> into a database, but PG currently does not expose that number. This
> patch introduces a new function pg_tablespace_avail() that takes a
> tablespace name or oid, and returns the number of bytes "available"
> there. This is the number without any reserved blocks (Unix, f_avail)
> or available to the current user (Windows).
>
> (This is not meant to replace a full-fledged OS monitoring system that
> has much more numbers about disks and everything, it is filling a UX
> gap.)
>
> Compared to the last patch, this just returns a single number so it's
> easier to use - total space isn't all that interesting, we just return
> the number the user wants.
>
> The free space is included in \db+ output:
>
> postgres =# \db+
> List of tablespaces
> Name │ Owner │ Location │ Access privileges │ Options │ Size │ Free │ Description
> ────────────┼───────┼──────────┼───────────────────┼─────────┼─────────┼────────┼─────────────
> pg_default │ myon │ │ ∅ │ ∅ │ 23 MB │ 538 GB │ ∅
> pg_global │ myon │ │ ∅ │ ∅ │ 556 kB │ 538 GB │ ∅
> spc │ myon │ /tmp/spc │ ∅ │ ∅ │ 0 bytes │ 31 GB │ ∅
> (3 rows)
>
> The patch has also been tested on Windows.
>
> TODO: Figure out which systems need statfs() vs statvfs()
>
> Christoph
view thread (2+ messages)
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: Available disk space per tablespace
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox