# object: database objects, tables, indexes and sequences

> Inventory database objects by schema and inspect tables, indexes, and sequences.

---

LLMS index: [llms.txt](/kbdiag-docs/llms.txt)

---

Survey the current database with `object` (`summary`), then inspect `object table [name]`, `object index [name]`, or `object seq [name]`. Repeat `--schema` to target specific schemas, or `--all-schemas` to include system schemas. Read-only: never executes `VACUUM` or `DROP INDEX`.

## Usage

```bash
kbdiag object                                     # schema & type est. summary
kbdiag object summary --schema app --exact        # bounded exact sizing
kbdiag object table --schema app --by=dead        # size | rows | dead | seq_scan
kbdiag object table app.orders                    # 6-clue single-table inspect
kbdiag object index --schema app --unused         # zero-scan index review list
kbdiag object seq --schema app                    # sequences ordered by range
```

## Subcommands & Options

| Command / Option | Effect |
|---|---|
| `object` / `object summary` | Inventory object counts and estimated size by schema and relation kind |
| `object table [name]` | Rank tables (`--by=size\|rows\|dead\|seq_scan`, `--partitioned`) or inspect one table in 6 clues |
| `object index [name]` | Rank indexes (`--by=size\|scans`, `--unused`, `--invalid`) or inspect one index |
| `object seq [name]` | Check integer/range exhaustion risk across sequences |
| `--schema`, `--all-schemas`, `--exact` | Filter schema scope; opt in to locked/exact `pg_table_size` within `--exact-budget` (default `20`) |

## Verdict & Reading Output

- **`FAIL` (`exit=2`)**: Exhausted non-cycling sequence (`seq.exhausted`) with `0` remaining values; for cached sequences (`cache_size > 1`), existing backends may continue briefly until their local cache depletes while new allocations already fail.
- **`WARN` (`exit=1`)**: Invalid/unready indexes or autovacuum disabled past dead-tuple threshold (sequences with remaining capacity remain informational until exhausted).
- **`UNKNOWN` (`exit=3`)**: `--exact` exceeded `--exact-budget` (marked in `[COVERAGE]` instead of silent truncation), `--unused` run on a standby (node-local scan counters), `object seq` missing privilege on restricted sequences, or incomplete single-table size/index probes.

## Example (KES V9 Primary, excerpt, `COLUMNS=80`)

```text
obj.tables  OK  (primary, system@local, endpoint=/tmp/.s.KINGBASE.54321,
    db=test, 2026-12-02T15:34:53Z)

[SCOPE]
  scope=current database, schemas=kb_obj_day3

[TABLES]  4 rows  by=dead
  +- kb_obj_day3.orders [none]
     > size: self=64 kB subtree=64 kB exact=-
     > tuples: est=500 live=500 dead=250 seq_scans=3
  +- kb_obj_day3.events [parent]
     > size: self=0 bytes subtree=16 kB exact=-
     > tuples: est=150 live=0 dead=0 seq_scans=0
  +- kb_obj_day3.events_p1 [leaf]
     > size: self=8192 bytes subtree=8192 bytes exact=-
     > tuples: est=99 live=99 dead=0 seq_scans=0

[NEXT]
  kbdiag object table '"kb_obj_day3"."orders"' # drill one table
  kbdiag object index --schema 'kb_obj_day3' # inspect indexes
```

## Related Commands

- [`kbdiag vacuum`](/kbdiag-docs/docs/reference/vacuum/) — current-database dead tuples and autovacuum blockers
- [`kbdiag freeze`](/kbdiag-docs/docs/reference/freeze/) — oldest XID/MXID relation ages and wraparound headroom
- [`kbdiag space`](/kbdiag-docs/docs/reference/space/) — total database, WAL, and filesystem capacity
