Description
Complete analysis of a single table including: columns with types, nullability, defaults, and comments; column-level statistics frompg_stats (cardinality classification, null rates, enum-like values with frequencies, value ranges for dates/numbers); primary keys; foreign keys with referenced tables; indexes; check constraints; row estimate; table size; statistics freshness; sample rows (up to 5); and index usage statistics.
Use this to understand a table before writing queries. Pay attention to: foreign keys for JOIN paths; cardinality to know what to GROUP BY vs filter; enum-like columns show the allowed values; value ranges show date spans and numeric scales; null rates help you handle NULLs correctly in filters and JOINs; sample rows to see actual data patterns; and index usage to understand query performance.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
table_name | string | Yes | Name of the table to describe |
schema | string | No | Schema name (resolves automatically if omitted) |
Response schema
| Field | Type | Description |
|---|---|---|
schema | string | Schema name |
name | string | Table name |
comment | string | Table comment (omitted if empty) |
row_estimate | integer | Estimated row count |
total_bytes | integer | Total disk size in bytes (omitted if zero) |
size_human | string | Human-readable size (omitted if empty) |
columns | array | Column details (see below) |
foreign_keys | array | Foreign key constraints (see below) |
indexes | array | Index definitions (see below) |
check_constraints | array | Check constraints (see below) |
stats_age | string | Timestamp of last ANALYZE run (omitted if unknown) |
stats_age_warning | string | Warning if statistics are stale or missing (omitted if fresh) |
sample_rows | array | Up to 5 sample rows as key-value objects (omitted if unavailable) |
index_usage | array | Per-index usage statistics (see below) |
Column object
| Field | Type | Description |
|---|---|---|
name | string | Column name |
data_type | string | PostgreSQL data type |
is_nullable | boolean | Whether the column allows NULL |
default_value | string | Default expression (omitted if none) |
is_primary_key | boolean | Whether this column is part of the primary key |
comment | string | Column comment (omitted if empty) |
stats | object | Column statistics from pg_stats (omitted if unavailable) |
Column stats object
| Field | Type | Description |
|---|---|---|
null_fraction | float | Fraction of rows that are NULL (0.0–1.0) |
cardinality | string | Classification: unique, near_unique, high_cardinality, low_cardinality, enum_like |
distinct_count | integer | Estimated number of distinct values |
most_common_vals | array | Most frequent values (for enum_like / low_cardinality columns) |
most_common_freqs | array | Frequencies of most common values |
min_value | string | Minimum value (for date/numeric columns) |
max_value | string | Maximum value (for date/numeric columns) |
Foreign key object
| Field | Type | Description |
|---|---|---|
constraint_name | string | Constraint name |
column_name | string | Column in this table |
referenced_table | string | Referenced table (schema-qualified) |
referenced_column | string | Referenced column |
Index object
| Field | Type | Description |
|---|---|---|
name | string | Index name |
definition | string | Full CREATE INDEX statement |
is_unique | boolean | Whether the index enforces uniqueness |
Check constraint object
| Field | Type | Description |
|---|---|---|
name | string | Constraint name |
expression | string | Check expression |
Index usage object
| Field | Type | Description |
|---|---|---|
name | string | Index name |
scans | integer | Number of index scans since last stats reset |
size_bytes | integer | Index size in bytes |
size_human | string | Human-readable index size |
Example response
Column masking
If a policy file defines column masks, sample rows are automatically masked using the same rules asquery results. For example, with email: redact and phone: partial:
Notes
- If
schemais omitted, Isthmus resolves the table name across all allowed schemas. If the table name is ambiguous (exists in multiple schemas), provide theschemaparameter. - Column statistics come from
pg_statsand requireANALYZEto have run. If stats are unavailable, thestatsfield is omitted. - Cardinality classification thresholds:
unique(100% distinct),near_unique(over 90%),high_cardinality(over 200 distinct),low_cardinality(21–200),enum_like(20 or fewer). - Sample rows are fetched with
LIMIT 5using aTABLESAMPLEclause when available for performance. - Index usage stats come from
pg_stat_user_indexes. An index withscans: 0may be unused and a candidate for removal. - The
stats_age_warningfield appears when the lastANALYZEis older than 7 days or has never been run.