Meta functions
These functions provide table, column and partition information including metadata. They are particularly useful for checking the table settings for:
- Designated timestamp column
- Attached, detached, or attachable partitions
- Partition storage size on disk
tables#
tables() returns all tables in the database including table metadata.
Arguments:
tables()does not require arguments.
Return value:
Returns a table.
Examples:
| id | name | designatedTimestamp | partitionBy | maxUncommittedRows | o3MaxLag | walEnabled | directoryName |
|---|---|---|---|---|---|---|---|
| 1 | my_table | ts | DAY | 500000 | 30000000 0 | false | my_table |
| 2 | device_data | null | NONE | 10000 | 30000000 | false | device_data |
| 3 | short_lived | null | HOUR | 10000 | 30000000 | false | short_lived (->) |
| id | name | designatedTimestamp | partitionBy | maxUncommittedRows | o3MaxLag | walEnabled | directoryName |
|---|---|---|---|---|---|---|---|
| 2 | device_data | null | NONE | 10000 | 30000000 | false | device_data |
| 1 | my_table | ts | DAY | 500000 | 300000000 | false | my_table |
| 3 | short_lived | ts | HOUR | 10000 | 30000000 | false | short_lived (->) |
note
(->) means the table was created using the
IN VOLUME clause.
| id | name | designatedTimestamp | partitionBy | maxUncommittedRows | walEnabled | directoryName |
|---|---|---|---|---|---|---|
| 1 | my_table | ts | DAY | 500000 | true | my_table |
wal_tables#
wal_tables() returns the WAL status for all
WAL tables in the database.
Arguments:
wal_tables()does not require arguments.
Return value:
Returns a table including the following information:
name- table namesuspended- suspended status flagwriterTxn- the last committed transaction in TableWritersequencerTxn- the last committed transaction in the sequencer
Examples:
| name | suspended | writerTxn | sequencerTxn |
|---|---|---|---|
| sensor_wal | false | 2 | 4 |
| weather_wal | false | 3 | 3 |
| test_wal | true | 7 | 9 |
table_columns#
table_columns('tableName') returns the schema of a table.
Arguments:
tableNameis the name of an existing table as a string.
Return value:
Returns a table with the following columns:
column- name of the available columns in the tabletype- type of the columnindexed- if indexing is applied to this columnindexBlockCapacity- how many row IDs to store in a single storage block on disksymbolCached- whether thissymbolcolumn is cachedsymbolCapacity- how many distinct values this column ofsymboltype is expected to havedesignated- if this is set as the designated timestamp column for this table
For more details on the meaning and use of these values, see the CREATE TABLE documentation.
Examples:
| column | type | indexed | indexBlockCapacity | symbolCached | symbolCapacity | designated |
|---|---|---|---|---|---|---|
| symb | SYMBOL | true | 1048576 | false | 256 | false |
| price | DOUBLE | false | 0 | false | 0 | false |
| ts | TIMESTAMP | false | 0 | false | 0 | true |
| s | STRING | false | 0 | false | 0 | false |
| column | type | designated |
|---|---|---|
| ts | TIMESTAMP | true |
| type | count |
|---|---|
| SYMBOL | 1 |
| DOUBLE | 1 |
| TIMESTAMP | 1 |
| STRING | 1 |
table_partitions#
table_partitions('tableName') returns information for the partitions of a
table with the option to filter the partitions.
Arguments:
tableNameis the name of an existing table as a string.
Return value:
Returns a table with the following columns:
index- INTEGER, index of the partition (NaN when the partition is not attached)partitionBy- STRING, one of NONE, HOUR, DAY, WEEK, MONTH and YEARname- STRING, name of the partition, e.g.2023-03-14,2023-03-14.detached,2023-03-14.attachableminTimestamp- LONG, min timestamp of the partition (NaN when the table is not partitioned)maxTimestamp- LONG, max timestamp of the partition (NaN when the table is not partitioned)numRows- LONG, number of rows in the partitiondiskSize- LONG, size of the partition in bytesdiskSizeHuman- STRING, size of the partition meant for humans to read (same output as function size_pretty)readOnly- BOOLEAN, true if the partition is attached via soft linkactive- BOOLEAN, true if the partition is the last partition, and whether we are writing to it (at least one record)attached- BOOLEAN, true if the partition is attacheddetached- BOOLEAN, true if the partition is detached (nameof the partition will contain the.detachedextension)attachable- BOOLEAN, true if the partition is detached and can be attached (nameof the partition will contain the.attachableextension)
Examples:
| index | partitionBy | name | minTimestamp | maxTimestamp | numRows | diskSize | diskSizeHuman | readOnly | active | attached | detached | attachable |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | WEEK | 2022-W52 | 2023-01-01 00:36:00.0 | 2023-01-01 23:24:00.0 | 39 | 98304 | 96.0 KiB | false | false | true | false | false |
| 1 | WEEK | 2023-W01 | 2023-01-02 00:00:00.0 | 2023-01-08 23:24:00.0 | 280 | 98304 | 96.0 KiB | false | false | true | false | false |
| 2 | WEEK | 2023-W02 | 2023-01-09 00:00:00.0 | 2023-01-15 23:24:00.0 | 280 | 98304 | 96.0 KiB | false | false | true | false | false |
| 3 | WEEK | 2023-W03 | 2023-01-16 00:00:00.0 | 2023-01-18 12:00:00.0 | 101 | 83902464 | 80.0 MiB | false | true | true | false | false |
| size_pretty |
|---|
| 80.3 MB |
| index | partitionBy | name | minTimestamp | maxTimestamp | numRows | diskSize | diskSizeHuman | readOnly | active | attached | detached | attachable |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 3 | WEEK | 2023-W03 | 2023-01-16 00:00:00.0 | 2023-01-18 12:00:00.0 | 101 | 83902464 | 80.0 MiB | false | true | true | false | false |
version/pg_catalog.version#
version() or pg_catalog.version() returns the supported version of the PostgreSQL Wire Protocol.
Arguments:
version()orpg_catalog.version()does not require arguments.
Return value:
Returns string.
Examples:
| version |
|---|
| PostgreSQL 12.3, compiled by Visual C++ build 1914, 64-bit, QuestDB |