---
id: w1/m25/t004
title: "`table-scans` endpoint: seq-scan vs index-scan stats via `pg_stat_user_tables`"
worker: worker1
status: todo
estimate: 30m
depends_on: []
---

## Objective

Expose Render's `GET /postgres/{id}/table-scans` equivalent across REST/GraphQL/MCP.

## Context

- `lego/backend/internal/postgres/` existing query path (see t001).

## Steps

1. Add a `TableScans` verb querying `pg_stat_user_tables` for `seq_scan`/`idx_scan`/`seq_tup_read` per table.
2. Wire into REST (`GET /v1/postgres/{id}/table-scans`), GraphQL, MCP.

## Files

- `lego/backend/internal/postgres/` observability verb + REST/GraphQL/MCP adapters

## Acceptance criteria

- [ ] Endpoint returns real per-table scan stats from a live CNPG cluster on all three surfaces.

## Out of scope

- Index-recommendation logic — bex surfaces raw stats only, same as Render.
