Grafana Cloud

Explore table schemas

The Table Schema Details tab shows the structure of tables used by your queries, including columns, data types, indexes, and constraints. Use this information to identify optimization opportunities and understand how queries interact with your data model.

What schema details reveal

Schema exploration helps you answer questions like:

  • Which columns does this query access?
  • Are there indexes that could speed up this query?
  • What data types are used in the table?
  • What constraints exist on the table?
  • How is the table structured (CREATE statement)?

Access table schema details

To view schema details for a query:

  1. Navigate to Database Observability in Grafana Cloud.
  2. In the Queries Overview, click a query to open its details.
  3. Select the Table Schema Details tab.

Table picker

The top of the tab shows a Tables Involved in Query Execution heading that identifies the tables the query accesses. When a query touches multiple tables, a dropdown lets you select which table to inspect and a badge shows the total table count. When only one table is involved, it is selected automatically.

Schema detail sections

Below the table picker, three detail sections are stacked vertically for the selected table:

  • Column details
  • Index details
  • Foreign key details

MySQL queries also display a Table Definition section with the full CREATE TABLE statement.

Schema information

Database Observability shows the same schema detail sections for both PostgreSQL and MySQL.

Column details

For each column, Database Observability shows:

FieldDescription
ColumnsColumn name. Displays an Indexed badge when the column is covered by any index.
Data TypeColumn data type
Default ValueDefault value, if defined
ConstraintsApplicable constraints: NOT NULL, AUTO INCREMENT, PRIMARY KEY

Index details

For each index on the table. Primary key indexes appear first.

FieldDescription
Index NameIdentifier for the index
Columns involved / ExpressionsColumns or expressions the index covers
NullableWhether the index allows null values (Yes or No)
UniqueWhether the index enforces uniqueness (Yes or No)
Index TypeIndex type (for example, BTREE, HASH). PostgreSQL index types are uppercased for consistency.

Foreign key details

For each foreign key constraint on the table:

FieldDescription
Foreign Key NameName of the foreign key constraint
ColumnLocal column involved in the relationship
Referenced TableTarget table the foreign key points to
Referenced ColumnColumn in the referenced table

MySQL: Table Definition

For MySQL tables, an additional Table Definition section displays the full CREATE TABLE statement in a SQL editor. This shows the complete schema structure to help evaluate query compatibility and optimization, including:

  • Complete column definitions
  • All indexes and keys
  • Table options (engine, charset, collation)
  • Partitioning configuration (if used)

Note

The Table Definition section is available for MySQL only. PostgreSQL does not display the CREATE TABLE statement.

Use schemas for optimization

Use the schema detail sections to spot indexing gaps and understand table relationships before making changes.

Spot missing index coverage

Columns in the Column details table display an Indexed badge when they are covered by at least one index. If a column used in a WHERE or ORDER BY clause has no badge, it may benefit from an index.

  1. Open the Table Schema Details tab.
  2. In the Column details table, look for filter or sort columns that lack the Indexed badge.
  3. Check the Index details table to confirm no existing index covers the column.
  4. If the column is unindexed, consider adding an index. For detailed guidance, refer to Improve slow queries.

Review existing indexes

The Index details table lists every index on the table with its type, covered columns or expressions, and whether it is unique or nullable. Primary key indexes appear first.

Use this information to:

  • Confirm that composite indexes match your query’s filter and sort order.
  • Check whether an index is unique when you expect uniqueness enforcement.
  • Compare index coverage across tables involved in a join by switching tables in the dropdown.

Understand join relationships

The Foreign key details table shows how tables relate to each other. Use it to:

  • Identify which columns participate in joins so you can verify they are indexed.
  • Understand referential integrity constraints before modifying table structure.
  • Trace data flow across tables when investigating unfamiliar queries.

For a complete optimization workflow including index creation examples, query rewrites, and verification steps, refer to Improve slow queries.

Configure schema collection

You can adjust collection intervals, caching behavior, database or schema exclusions, and disable the schema_details collector entirely. For all configuration options, refer to Tune Alloy collection.

Troubleshooting

Use these checks if schema details are missing or outdated.

Schema details not appearing

If the Table Schema Details tab is empty:

  1. Check permissions: Verify monitoring user has SELECT access
  2. Check collector: Ensure schema_details collector is enabled
  3. Check exclusions: Verify the database or schema isn’t in exclude_databases (PostgreSQL) or exclude_schemas (MySQL)
  4. Check logs: Look for schema collection errors in Alloy logs

Schema details outdated

If schema changes aren’t reflected:

  1. Cache expiration: Wait for cache TTL to expire (default 10 minutes)
  2. Force refresh: Restart Alloy to clear cache
  3. Reduce TTL: Configure shorter cache_ttl for frequently changing schemas

Tables don’t appear

If some tables don’t appear:

  1. Check query association: Tables appear only if queries use them
  2. Verify permissions: Check SELECT grant on specific tables
  3. Check schema scope: Ensure the table’s schema is monitored