YMatrix
Quick Start
Simulate Time Series Scenarios
Standard Cluster Deployment
Data Modeling
Connecting to The database
Data Writing
Data Migration
Data Query
Scene Application Examples
Federal Query
Maintenance and Monitoring
Global Maintenance
Partition Maintenance
Backup and Restore
Cluster Expansion
Monitoring
Performance Tuning
Troubleshooting
Reference Guide
Tool Guide
Data Type
Storage Engine
Execution Engine
Configuration Parameters
Index
Extension
SQL Reference
FAQ
Rebuild the index.
REINDEX {INDEX | TABLE | DATABASE | SYSTEM} name
REINDEX rebuilds the index using the data stored in the index table, replacing the old copy of the index. REINDEX can be used in several cases:
INDEX
TABLE
DATABASE
SYSTEM
name
REINDEX is similar to deleting indexes and recreating indexes because the index content is rebuilt from scratch. However, locking precautions are very different. REINDEX locks writes to the index's parent table but does not lock reads. It also takes an exclusive lock on the specific index being processed, which will block the read of that index. Instead, DROP INDEX immediately adds exclusive locks to the parent table, thus preventing write and read. The subsequent CREATE INDEX locks the write but does not lock the read; since the index does not exist, no read attempts are made, which means there will be no blockage, but the read operation may force a costly sequential scan.
Reindexing a single index or table requires that it be the owner of that index or table. Reindexing a database requires becoming the owner of the database (note that the owner can therefore rebuild the index of tables owned by other users).
REINDEX does not update index reltuples and relpages statistics. To update these statistics, run ANALYZE on the table after re-index.
If you suspect that the shared global system directory indexes are corrupted, you can only index them in YMatrix utility mode. A typical symptom of shared index corruption is the "index is not btree" error, otherwise the server will crash immediately due to relying on a corrupt index at startup. In this case, please contact YMatrix Customer Support: [email protected].
Reconstruct a single index:
REINDEX INDEX my_index;
Rebuild all indexes on table my_table:
REINDEX TABLE my_table;
There is no REINDEX command in the SQL standard.