Hologres provides a set of system tables for querying metadata, statistics, lock information, and access permissions. This topic covers each system table's columns and common SQL queries you can run against them.
Overview
Hologres exposes two categories of system tables:
Hologres-native tables (prefixed with
hg): purpose-built for Hologres, covering Hologres-specific properties and statistics shared across all nodes.PostgreSQL-compatible tables (prefixed with
pgor underinformation_schema): inherited from PostgreSQL. Some columns in these tables are not applicable in Hologres because Hologres is a distributed system, not a standalone PostgreSQL instance.
| Table | Source | Description |
|---|---|---|
hologres.hg_table_properties | Hologres-native | Properties and indexes of all tables in the current database. |
hologres_statistic.hg_table_statistic | Hologres-native | Table statistics shared across all nodes. |
pg_catalog.pg_tables | PostgreSQL-compatible | Table metadata, including schema, owner, and index information. |
pg_catalog.pg_locks | PostgreSQL-compatible | Runtime lock information. Use this table to diagnose blocked DDL statements or queries. |
pg_catalog.pg_class | PostgreSQL-compatible | PostgreSQL catalog table containing relation metadata. Typically used with other pg_catalog tables. |
pg_catalog.pg_stats | PostgreSQL-compatible | Column-level statistics used by the PostgreSQL planner on a single node. |
pg_catalog.pg_roles | PostgreSQL-compatible | Roles and their permissions in a Hologres instance. |
information_schema.role_table_grants | PostgreSQL-compatible | Permissions granted to roles on tables and views. |
Limitations
Tables prefixed with
hgare Hologres system tables. Tables prefixed withpgare PostgreSQL system tables. In Hologres versions earlier than V1.3.22, you cannot join PostgreSQL system tables with Hologres internal tables, and you cannot import data from PostgreSQL system tables into Hologres internal tables. Upgrade to V1.3.22 or later to remove this restriction.In Hologres, the object identifier (OID) field in a system table uniquely identifies relations such as tables, indexes, and views. Because Hologres is a distributed system with multiple frontend (FE) nodes, OID values can differ between nodes. Query results that include OID values may be inconsistent across nodes.
hologres.hg_table_properties
This table contains information and properties for all tables in the current database.
| Column | Description |
|---|---|
table_namespace | The schema that contains the table. Hologres provides three system schemas: hologres (Hologres system tables), hologres_statistic (statistics tables), and pg_catalog (PostgreSQL metadata tables). |
table_name | The table name. System tables include: hologres.hg_insert_progress_stats, hologres.hg_table_properties, hologres.hg_table_group_properties, hologres_statistic.hg_table_statistic, and pg_catalog.pg_stat_activity. |
property_key | The property name. Valid values: table_id, clustering_index_id, clustering_index_name, lifecycle_in_days (TTL; -1 means permanently valid), storage_format (sst for row-oriented tables; orc by default for column-oriented tables in V0.10 or later), table_group, schema_version, primary_key, orientation (row, column, or row,column for hybrid row-column storage supported in V1.1 and later), distribution_key, dictionary_encoding_columns, bitmap_columns, clustering_key, create_time, last_ddl_time, storage_mode (hot for standard storage; cold for Infrequent Access (IA) storage). |
property_value | The value of the property. |
pg_catalog.pg_tables
This table contains metadata for all tables, including user-created tables and system tables.
| Column | Description |
|---|---|
schemaname | The schema that contains the table. Hologres provides three system schemas: hologres, pg_catalog, and information_schema. |
tablename | The table name. |
tableowner | The table owner. holo_admin owns system tables and this value cannot be changed. Accounts with the simple permission model (SPM) or schema-level permission model (SLPM) enabled show as developer. |
tablespace | Not applicable in Hologres. |
hasindexes | true if the table has or had an index. |
hasrules | true if the table has or had a rewrite rule. |
hastriggers | true if the table has or had a trigger. |
rowsecurity | Not applicable in Hologres. |
pg_catalog.pg_locks
This table shows runtime lock information. Query this table to determine whether a lock is blocking a DDL statement or query.
| Column | Description |
|---|---|
locktype | The type of the lockable object. Valid values: relation (table lock) and advisory (DDL lock). PostgreSQL lock types extend, page, tuple, transactionid, virtualxid, object, and userlock are not applicable in Hologres. |
database | The OID of the database containing the locked object. |
relation | The OID of the locked table. Null if the object is not a table or part of a table. |
virtualxid | The virtual transaction ID of the lock. Null if the object is not a virtual transaction ID. |
transactionid | The transaction ID. Null if the object is not a transaction ID. |
pid | The process ID (PID) of the server process holding or waiting for the lock. Use this PID to look up the process in pg_catalog.pg_stat_activity. |
mode | The lock mode: shared lock or exclusive lock. |
granted | true if the lock is held; false if the lock is being waited on. |
Columns not applicable in Hologres: page, tuple, classid, objid, objsubid, virtualtransaction, fastpath.
pg_catalog.pg_class
This table contains PostgreSQL catalog information for all relations (tables, indexes, views, and more). It is typically queried together with other pg_catalog tables.
Because Hologres is a distributed system with multiple FE nodes, OID values are usually different across nodes. Query results containing OIDs may be inconsistent.
| Column | Description |
|---|---|
oid | The unique OID of the relation. |
relname | The name of the relation. |
relnamespace | The OID of the schema containing the relation. |
relowner | The owner of the relation. |
reltuples | The estimated row count used by the planner. Updated by VACUUM, ANALYZE, or DDL statements. In Hologres, this column specifies the statistics row count. |
relallvisible | The estimated number of all-visible pages used by the planner. Updated by VACUUM, ANALYZE, or DDL statements. In Hologres, this column specifies the statistics version. |
relhasindex | true if the relation has or had an index. |
relisshared | true if the table is shared across all databases in the cluster (for example, pg_catalog.pg_database). Not applicable in Hologres. |
relpersistence | Table persistence: p (permanent), u (unlogged), or t (temporary). |
relkind | Relation type: r (table), i (index), S (sequence), v (view), m (materialized view), c (composite type), t (TOAST table), f (foreign table). |
relnatts | The number of user columns, excluding system columns. |
relhaspkey | true if the relation has or had a primary key. |
relhassubclass | true if the relation has or had an inherited child table. |
relacl | Access permissions for the relation. |
reloptions | Table properties. For example, autovacuum_enabled=false indicates that auto-vacuum and auto-analyze are disabled for the table. |
Columns not applicable in Hologres: reltype, reloftype, relam, relfilenode, reltablespace, relpages, reltoastrelid, relchecks, relhasoids, relhasrules, relhastriggers, relispopulated, relreplident, relfrozenxid, relminmxid.
hologres_statistic.hg_table_statistic
This table contains Hologres-native statistics shared across all nodes. It is updated when you run ANALYZE or when the auto-analyze feature runs.
| Column | Description |
|---|---|
unique_name | The unique identifier of the table. |
schema_version | The schema version of the table. |
statistic_version | The statistics version. |
statistics | The statistics content, encoded in Base64. |
schema_name | The schema that contains the table. |
table_name | The table name. |
total_rows | The total number of rows in the table. |
sample_rows | The number of rows sampled for statistics collection. |
nattr | The number of columns in the table. |
used_attrs | The columns analyzed by the ANALYZE statement. |
histogram_attrs | The columns for which histogram statistics are collected. |
ndv_attrs | The columns for which distinct-value (NDV) statistics are collected. |
user_name | The user who ran ANALYZE or triggered auto-analyze. |
analyze_timestamp | The time ANALYZE ran or auto-analyze was triggered. |
analyze_cost | The time taken by ANALYZE or auto-analyze to complete. |
analyze_count | The number of times ANALYZE has run or auto-analyze has been triggered. |
pg_catalog.pg_stats
This table contains PostgreSQL column-level statistics used by the single-node PostgreSQL planner.
| Column | Description |
|---|---|
schemaname | The schema name. |
tablename | The table name. |
attname | The column name. |
inherited | true if the statistics include inherited subcolumns. |
null_frac | The fraction of rows with null values in this column. |
avg_width | The average width (in bytes) of column entries. |
n_distinct | The estimated number of distinct values if positive. If negative, the absolute value is the ratio of distinct values to total rows (used when the number of distinct values is expected to grow with the table). For example, -1 indicates a unique column. |
most_common_vals | A list of the most common values in the column. Null if no values are common enough. |
most_common_freqs | The frequencies of the most common values, calculated as occurrences divided by total rows. Null if most_common_vals is null. |
histogram_bounds | Values that divide the column's value range into approximately equal-sized groups. Values in most_common_vals are excluded from this histogram. |
most_common_elems | The most common non-null element values within array-type column values. |
most_common_elem_freqs | The frequencies of the most common element values: the fraction of rows containing at least one instance of each value. Null if most_common_elems is null. |
Columns not applicable in Hologres: correlation, elem_count_histogram.
pg_catalog.pg_roles
This table lists all roles in a Hologres instance and their permissions.
| Column | Description |
|---|---|
rolname | The role name. |
rolsuper | t if the role has superuser privileges; f otherwise. |
rolinherit | t if the role inherits permissions from any role it is a member of; f otherwise. |
rolcreaterole | t if the role can create other roles; f otherwise. |
rolcreatedb | t if the role can create databases; f otherwise. |
rolcanlogin | t if the role can connect to instances; f otherwise. |
rolconnlimit | The maximum number of concurrent connections the role can establish. If the value is -1, the maximum number of concurrent connections is not configured in Hologres. |
oid | The unique OID of the role. |
Columns not applicable in Hologres: rolreplication, rolpassword, rolvaliduntil, rolbypassrls, rolconfig.
information_schema.role_table_grants
This table lists the permissions granted to roles on tables and views in a Hologres instance.
| Column | Description |
|---|---|
grantor | The role that granted the permission. |
grantee | The role that received the permission. |
table_catalog | The database name. |
table_schema | The schema name. |
table_name | The table name. |
privilege_type | The type of permission granted. Valid values: SELECT, INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES, TRIGGER. |
is_grantable | YES if the permission can be granted to others; NO otherwise. |
with_hierarchy | YES if the permission type is SELECT; NO otherwise. |
Common SQL queries
All queries in this section can be run using psql or any PostgreSQL-compatible client.
Query table properties and indexes
SELECT * FROM hologres.hg_table_properties WHERE table_name = '<table_name>';Retrieve the DDL for a table or view
-- Retrieve the DDL for a table
SELECT hg_dump_script('<table_name>');
-- Retrieve the DDL for a view
SELECT hg_dump_script('<view_name>');If the query fails, install the hg_toolkit extension first:CREATE EXTENSION hg_toolkit;Query the instance endpoint
SHOW hg_frontend_endpoints;List all databases in the current instance
SELECT
d.datname AS "Name",
pg_catalog.pg_get_userbyid(d.datdba) AS "Owner",
pg_catalog.pg_encoding_to_char(d.encoding) AS "Encoding",
d.datcollate AS "Collate",
d.datctype AS "Ctype",
pg_catalog.array_to_string(d.datacl, E'\n') AS "Access privileges"
FROM pg_catalog.pg_database d
WHERE d.datname != 'postgres'
AND d.datname != 'template0'
AND d.datname != 'template1'
ORDER BY 1;List all user mappings in the current database
SELECT
um.srvname AS "Server",
um.usename AS "User name"
FROM pg_catalog.pg_user_mappings um
WHERE um.srvname != 'query_log_store_server'
ORDER BY 1, 2;List all schemas in the current database
SELECT
n.nspname AS "Name",
pg_catalog.pg_get_userbyid(n.nspowner) AS "Owner"
FROM pg_catalog.pg_namespace n
WHERE n.nspname !~ '^pg_'
AND n.nspname <> 'information_schema'
AND n.nspname != 'hologres'
AND n.nspname != 'hologres_sample'
AND n.nspname != 'hologres_statistic'
AND n.nspname !~ '^hg_'
AND n.nspname !~ '^holo_'
ORDER BY 1;List all tables, foreign tables, and views in the current database
SELECT
n.nspname AS "Schema",
c.relname AS "Name",
CASE c.relkind
WHEN 'r' THEN 'table'
WHEN 'v' THEN 'view'
WHEN 'm' THEN 'materialized view'
WHEN 'i' THEN 'index'
WHEN 'S' THEN 'sequence'
WHEN 's' THEN 'special'
WHEN 'f' THEN 'foreign table'
WHEN 'p' THEN 'partitioned table'
WHEN 'I' THEN 'partitioned index'
END AS "Type",
pg_catalog.pg_get_userbyid(c.relowner) AS "Owner"
FROM pg_catalog.pg_class c
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
WHERE c.relkind IN ('r', 'p', 'v', 'm', 'S', 'f', '')
AND n.nspname <> 'pg_catalog'
AND n.nspname <> 'information_schema'
AND n.nspname !~ '^pg_toast'
AND pg_catalog.pg_table_is_visible(c.oid)
ORDER BY 1, 2;List all tables and owners in the current schema (excluding system tables)
-- Include system tables
SELECT * FROM pg_tables;
-- Exclude system tables
SELECT
n.nspname AS "Schema",
c.relname AS "Name",
CASE c.relkind
WHEN 'r' THEN 'table'
WHEN 'v' THEN 'view'
WHEN 'm' THEN 'materialized view'
WHEN 'i' THEN 'index'
WHEN 'S' THEN 'sequence'
WHEN 's' THEN 'special'
WHEN 'f' THEN 'foreign table'
WHEN 'p' THEN 'partitioned table'
WHEN 'I' THEN 'partitioned index'
END AS "Type",
pg_catalog.pg_get_userbyid(c.relowner) AS "Owner"
FROM pg_catalog.pg_class c
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
WHERE c.relkind IN ('r', 'p', 'v', 'm', 'S', 'f', '')
AND n.nspname <> 'pg_catalog'
AND n.nspname <> 'information_schema'
AND n.nspname !~ '^pg_toast'
AND pg_catalog.pg_table_is_visible(c.oid)
ORDER BY 1, 2;List child tables of a parent table
-- With partition key values
SELECT
c.oid::pg_catalog.regclass,
c.relkind,
pg_catalog.pg_get_expr(c.relpartbound, c.oid)
FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i
WHERE c.oid = i.inhrelid
AND i.inhparent::pg_catalog.regclass = '<parent_table_name>'::pg_catalog.regclass
ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT';
-- Without partition key values
SELECT
nmsp_parent.nspname AS parent_schema,
parent.relname AS parent,
nmsp_child.nspname AS child_schema,
child.relname AS child
FROM pg_inherits
JOIN pg_class parent ON pg_inherits.inhparent = parent.oid
JOIN pg_class child ON pg_inherits.inhrelid = child.oid
JOIN pg_namespace nmsp_parent ON nmsp_parent.oid = parent.relnamespace
JOIN pg_namespace nmsp_child ON nmsp_child.oid = child.relnamespace
WHERE parent.relname = '<parent_table_name>';List child tables with creation time and parent table
SELECT
cn.nspname AS child_schema_name,
c.relname AS child_table_name,
pn.nspname AS parent_schema_name,
p.relname AS parent_table_name,
to_timestamp(cp.property_value::bigint) AS create_time
FROM pg_inherits i
LEFT JOIN pg_class p ON p.oid = i.inhparent
LEFT JOIN pg_namespace pn ON pn.oid = p.relnamespace
LEFT JOIN pg_class c ON c.oid = i.inhrelid
LEFT JOIN pg_namespace cn ON cn.oid = c.relnamespace
LEFT JOIN hologres.hg_table_properties cp
ON cp.property_key = 'create_time'
AND cp.table_namespace = pn.nspname
AND cp.table_name = c.relname;List all foreign tables and their corresponding MaxCompute tables
SELECT
n.nspname,
c.relname,
s.srvname,
pg_catalog.array_to_string(
ARRAY(
SELECT pg_catalog.quote_ident(option_name) || ' ' || pg_catalog.quote_literal(option_value)
FROM pg_catalog.pg_options_to_table(ftoptions)
),
', '
)
FROM pg_catalog.pg_foreign_table f,
pg_catalog.pg_foreign_server s,
pg_catalog.pg_class c,
pg_catalog.pg_namespace n
WHERE s.oid = f.ftserver
AND c.oid = f.ftrelid
AND c.relnamespace = n.oid
AND n.nspname NOT IN ('hologres', 'hologres_statistic', 'pg_catalog', 'pg_toast');List all views in the current database
SELECT
n.nspname AS "Schema",
c.relname AS "Name",
CASE c.relkind
WHEN 'r' THEN 'table'
WHEN 'v' THEN 'view'
WHEN 'm' THEN 'materialized view'
WHEN 'i' THEN 'index'
WHEN 'S' THEN 'sequence'
WHEN 's' THEN 'special'
WHEN 'f' THEN 'foreign table'
WHEN 'p' THEN 'partitioned table'
WHEN 'I' THEN 'partitioned index'
END AS "Type",
pg_catalog.pg_get_userbyid(c.relowner) AS "Owner"
FROM pg_catalog.pg_class c
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
WHERE c.relkind IN ('v', '')
AND n.nspname <> 'pg_catalog'
AND n.nspname <> 'information_schema'
AND n.nspname !~ '^pg_toast'
AND pg_catalog.pg_table_is_visible(c.oid)
ORDER BY 1, 2;Find views that depend on a table
SELECT * FROM information_schema.view_table_usage WHERE table_name = '<table_name>';Query column comments and table comments
-- Query column comments for a table
SELECT
a.attname AS "Column",
pg_catalog.format_type(a.atttypid, a.atttypmod) AS "Type",
a.attnotnull AS "Nullable",
pg_catalog.col_description(a.attrelid, a.attnum) AS "Description"
FROM pg_catalog.pg_attribute a
WHERE a.attnum > 0
AND NOT a.attisdropped
AND a.attrelid = '<schema_name>.<table_name>'::regclass::oid
ORDER BY a.attnum;Replace <schema_name>.<table_name> with the actual schema and table name.
-- Query table comments and related metadata (owner, size)
SELECT
n.nspname AS "Schema",
c.relname AS "Name",
CASE c.relkind
WHEN 'r' THEN 'table'
WHEN 'v' THEN 'view'
WHEN 'm' THEN 'materialized view'
WHEN 'i' THEN 'index'
WHEN 'S' THEN 'sequence'
WHEN 's' THEN 'special'
WHEN 'f' THEN 'foreign table'
WHEN 'p' THEN 'table'
WHEN 'I' THEN 'index'
END AS "Type",
pg_catalog.pg_get_userbyid(c.relowner) AS "Owner",
pg_catalog.pg_size_pretty(pg_catalog.pg_table_size(c.oid)) AS "Size",
pg_catalog.obj_description(c.oid, 'pg_class') AS "Description"
FROM pg_catalog.pg_class c
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
WHERE c.relkind IN ('r', 'p', 'v', 'm', 'S', 'f', '')
AND n.nspname <> 'pg_catalog'
AND n.nspname <> 'information_schema'
AND n.nspname !~ '^pg_toast'
AND pg_catalog.pg_table_is_visible(c.oid)
ORDER BY 1, 2;-- Query the comment on a specific table
SELECT pg_catalog.obj_description('<table_name>'::regclass::oid, 'pg_class') AS "Description";List all users and roles in a database
SELECT
r.rolname,
r.rolsuper,
r.rolinherit,
r.rolcreaterole,
r.rolcreatedb,
r.rolcanlogin,
r.rolconnlimit,
r.rolvaliduntil,
ARRAY(
SELECT b.rolname
FROM pg_catalog.pg_auth_members m
JOIN pg_catalog.pg_roles b ON (m.roleid = b.oid)
WHERE m.member = r.oid
) AS memberof,
r.rolreplication,
r.rolbypassrls
FROM pg_catalog.pg_roles r
WHERE r.rolname !~ '^pg_'
AND r.rolname != 'holo_admin'
ORDER BY 1;List all extensions in a database
SELECT
e.extname AS "Name",
e.extversion AS "Version",
n.nspname AS "Schema",
c.description AS "Description"
FROM pg_catalog.pg_extension e
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = e.extnamespace
LEFT JOIN pg_catalog.pg_description c ON c.objoid = e.oid
AND c.classoid = 'pg_catalog.pg_extension'::pg_catalog.regclass
WHERE e.extname != 'hg_admin_cmd'
AND e.extname != 'holo_dump_stat'
AND e.extname != 'holo_funcs'
AND e.extname != 'holo_link'
AND e.extname != 'holo_system_admin'
AND e.extname != 'query_log'
AND e.extname != 'plpgsql'
ORDER BY 1;Check the permissions of an account
SELECT * FROM pg_roles WHERE rolname = '<uid>';List all users of an instance and their permissions
SELECT
r.rolname,
r.rolsuper,
r.rolinherit,
r.rolcreaterole,
r.rolcreatedb,
r.rolcanlogin,
r.rolconnlimit,
r.rolvaliduntil,
ARRAY(
SELECT b.rolname
FROM pg_catalog.pg_auth_members m
JOIN pg_catalog.pg_roles b ON (m.roleid = b.oid)
WHERE m.member = r.oid
) AS memberof,
r.rolreplication,
r.rolbypassrls
FROM pg_catalog.pg_roles r
WHERE r.rolname !~ '^pg_'
ORDER BY 1;List all tables on which a user has permissions
SELECT
current_database()::information_schema.sql_identifier AS table_catalog,
nc.nspname::information_schema.sql_identifier AS table_schema,
c.relname::information_schema.sql_identifier AS table_name,
CASE
WHEN nc.oid = pg_my_temp_schema() THEN 'LOCAL TEMPORARY'::text
WHEN c.relkind = ANY (ARRAY['r'::"char", 'p'::"char"]) THEN 'BASE TABLE'::text
WHEN c.relkind = 'v'::"char" THEN 'VIEW'::text
WHEN c.relkind = 'f'::"char" THEN 'FOREIGN'::text
ELSE NULL::text
END::information_schema.character_data AS table_type,
CASE
WHEN (c.relkind = ANY (ARRAY['r'::"char", 'p'::"char"]))
OR (c.relkind = ANY (ARRAY['v'::"char", 'f'::"char"])
AND (pg_relation_is_updatable(c.oid::regclass, false) & 8) = 8)
THEN 'YES'::text
ELSE 'NO'::text
END::information_schema.yes_or_no AS is_insertable_into,
CASE
WHEN t.typname IS NOT NULL THEN 'YES'::text
ELSE 'NO'::text
END::information_schema.yes_or_no AS is_typed,
NULL::character varying::information_schema.character_data AS commit_action
FROM pg_namespace nc
JOIN pg_class c ON nc.oid = c.relnamespace
LEFT JOIN (pg_type t JOIN pg_namespace nt ON t.typnamespace = nt.oid) ON c.reloftype = t.oid
WHERE (c.relkind = ANY (ARRAY['r'::"char", 'v'::"char", 'f'::"char", 'p'::"char"]))
AND NOT pg_is_other_temp_schema(nc.oid)
AND (
pg_has_role('<user_id>', c.relowner, 'USAGE'::text)
OR has_table_privilege('<user_id>', c.oid, 'SELECT, INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES, TRIGGER'::text)
OR has_any_column_privilege('<user_id>', c.oid, 'SELECT, INSERT, UPDATE, REFERENCES'::text)
);Replace <user_id> with the actual user ID.
List all users who have permissions on a table
SELECT rolname
FROM pg_roles
WHERE has_table_privilege(rolname, '<schema_name>.<table_name>',
'SELECT, INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES, TRIGGER');Replace <schema_name>.<table_name> with the actual schema and table name.