---
sidebar_position: 5
title: PRAGMA database_size
description: Get storage size information for MotherDuck databases using PRAGMA database_size.
---

# 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 Name           | Data Type   | Value                             |
|-----------------------|-------------|-----------------------------------|
| database_name | VARCHAR | name of the database  |
| database_size | VARCHAR | database size in 1000 byte increments (i.e. Kilobytes) |
| block_size | BIGINT | _not currently returned_ |
| used_blocks | BIGINT | _not currently returned_ |
| total_blocks | BIGINT | _not currently returned_ |
| free_blocks | BIGINT | _not currently returned_ |
| wal_size | VARCHAR | _not currently returned_ |
| memory_usage | VARCHAR | _not currently returned_ |
| memory_limit | VARCHAR | _not currently returned_ |

## Example Usage

```sql
PRAGMA database_size;
```

Example result:

| database_name | database_size | block_size | used_blocks | total_blocks | free_blocks | wal_size | memory_usage | memory_limit |
|---------------|---------------|------------|-------------|--------------|-------------|----------|--------------|--------------|
| my_db   | 153.9 GiB         | NULL       | NULL        | NULL         | NULL        | NULL     | NULL         | NULL         |
| another_database  | 3.1 TiB         | NULL       | NULL        | NULL         | NULL        | NULL     | NULL         | NULL         |

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:

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