documentation/query/sql/alter-mat-view-alter-column-add-index.md
Adds an index to a
SYMBOL column in a materialized view, improving
query performance for filtered lookups.
ALTER MATERIALIZED VIEW viewName ALTER COLUMN columnName ADD INDEX [ CAPACITY n ]
| Parameter | Description |
|---|---|
viewName | Name of the materialized view |
columnName | Name of the SYMBOL column to index |
CAPACITY | Optional index capacity (advanced; use default unless you understand implications) |
Add an index when:
SYMBOL column (e.g., WHERE symbol = 'BTC-USD')ALTER MATERIALIZED VIEW trades_hourly
ALTER COLUMN symbol ADD INDEX;
| Aspect | Description |
|---|---|
| Operation type | Atomic, non-blocking, non-waiting |
| Immediate effect | SQL optimizer starts using the index once created |
| Column requirement | Column must be of type SYMBOL |
:::note Index capacity and symbol capacity are different settings. Only change index capacity if you understand the implications. :::
Adding an index requires the ALTER MATERIALIZED VIEW permission:
GRANT ALTER MATERIALIZED VIEW ON trades_hourly TO user1;
| Error | Cause |
|---|---|
materialized view does not exist | View with specified name doesn't exist |
column does not exist | Column not found in the view |
column is not a symbol | Index can only be added to SYMBOL columns |
index already exists | Column is already indexed |
permission denied | Missing ALTER MATERIALIZED VIEW permission (Enterprise) |