Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hypertable_(detailed_)size functions now supports CAGG name #2086

Merged
merged 6 commits into from
Mar 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions api/hypertable_detailed_size.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,24 @@ api:

# hypertable_detailed_size()

Get detailed information about disk space used by a hypertable,
returning size information for the table itself, any indexes on the
table, any toast tables, and the total size of all. All sizes are
reported in bytes. If the function is executed on a distributed
hypertable, it returns size information as a separate row per node,
including the access node.
Get detailed information about disk space used by a hypertable or
continuous aggregate, returning size information for the table
itself, any indexes on the table, any toast tables, and the total
size of all. All sizes are reported in bytes. If the function is
executed on a distributed hypertable, it returns size information
as a separate row per node, including the access node.

<Highlight type="tip">
When a continuous aggregate name is provided, the function
transparently looks up the backing hypertable and returns its statistics
instead.
</Highlight>

### Required arguments

|Name|Type|Description|
|---|---|---|
| `hypertable` | REGCLASS | Hypertable to show detailed size of. |
| `hypertable` | REGCLASS | Hypertable or continuous aggregate to show detailed size of. |

### Returns

Expand All @@ -41,7 +47,7 @@ returns `NULL`.

### Sample usage

Get size information for a hypertable.
Get the size information for a hypertable.

```sql
-- disttable is a distributed hypertable --
Expand Down
35 changes: 26 additions & 9 deletions api/hypertable_size.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,24 @@ api:

# hypertable_size()

Get the total disk space used by a hypertable, that is, the sum of the
size for the table itself (including chunks), any indexes on the
table, and any toast tables. The size is reported in bytes. This is
equivalent to computing the sum of `total_bytes` column from the
output of `hypertable_detailed_size` function.
Get the total disk space used by a hypertable or continuous aggregate,
that is, the sum of the size for the table itself including chunks,
any indexes on the table, and any toast tables. The size is reported
in bytes. This is equivalent to computing the sum of `total_bytes`
column from the output of `hypertable_detailed_size` function.

<Highlight type="tip">
When a continuous aggregate name is provided, the function
transparently looks up the backing hypertable and returns its statistics
instead.

</Highlight>

### Required arguments

|Name|Type|Description|
|---|---|---|
| `hypertable` | REGCLASS | Hypertable to show size of. |
| `hypertable` | REGCLASS | Hypertable or continuous aggregate to show size of. |

### Returns

Expand All @@ -35,19 +42,29 @@ output of `hypertable_detailed_size` function.

### Sample usage

Get size information for a hypertable.
Get the size information for a hypertable.

```sql
SELECT hypertable_size('devices') ;
SELECT hypertable_size('devices');

hypertable_size
-----------------
73728
```

Get size information for all hypertables.
Get the size information for all hypertables.

```sql
SELECT hypertable_name, hypertable_size(format('%I.%I', hypertable_schema, hypertable_name)::regclass)
FROM timescaledb_information.hypertables;
```

Get the size information for a continuous aggregate.

```sql
SELECT hypertable_size('device_stats_15m');

hypertable_size
-----------------
73728
```
8 changes: 8 additions & 0 deletions api/page-index/page-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,14 @@ module.exports = [
title: "remove_all_policies",
href: "remove_all_policies",
},
{
title: "hypertable_size",
href: "hypertable_size",
},
{
title: "hypertable_detailed_size",
href: "hypertable_detailed_size",
},
],
},
{
Expand Down