Livestream: Getting Started with MotherDuck and DuckLake - June 26Register Now

Skip to main content

Database Size

Database size can be fetched with PRAGMA database_size;. It contains attributes to allow insights into the sizes of MotherDuck databases.

Alternative invocations

This Pragma can also be invoked as a tabular function with:

  • FROM pragma_database_size();

Schema

PRAGMA database_size has the following schema:

Column NameData TypeValue
database_nameVARCHARname of the database
database_sizeVARCHARdatabase size in 1024 byte increments (i.e. Kibibytes)
block_sizeBIGINTnot currently returned
used_blocksBIGINTnot currently returned
total_blocksBIGINTnot currently returned
free_blocksBIGINTnot currently returned
wal_sizeVARCHARnot currently returned
memory_usageVARCHARnot currently returned
memory_limitVARCHARnot currently returned

Example Usage

PRAGMA database_size;

Example result:

database_namedatabase_sizeblock_sizeused_blockstotal_blocksfree_blockswal_sizememory_usagememory_limit
my_db153.9 GiBNULLNULLNULLNULLNULLNULLNULL
another_database3.1 TiBNULLNULLNULLNULLNULLNULLNULL

In some cases, you may want to filter the dataset, in which case you can use a tabular function in your FROM clause. An example is shown below:

SELECT * 
FROM pragma_database_size()
WHERE database_name = 'my_db'