DBAtlas · Atlas für Datenbankbetrieb

Index neu aufbauen / reorganisieren

Oracle

ALTER INDEX customer_city_idx REBUILD ONLINE;

ONLINE baut ohne Sperren der Tabelle neu auf (Enterprise Edition). Zum Verschieben in einen anderen Tablespace: ... REBUILD TABLESPACE new_ts.

PostgreSQL

REINDEX INDEX CONCURRENTLY customer_city_idx;
-- Whole table: REINDEX TABLE CONCURRENTLY customer;

CONCURRENTLY (PG 12+) baut neu auf, ohne Schreibzugriffe auf die Tabelle zu blockieren; langsamer, aber sicher.

MySQL

-- Rebuild InnoDB indexes + table:
ALTER TABLE customer ENGINE=InnoDB, ALGORITHM=INPLACE, LOCK=NONE;
-- Alternative: OPTIMIZE TABLE customer;

LOCK=NONE erlaubt gleichzeitige Schreibzugriffe; INPLACE ist nicht bei jedem ALTER möglich.

SQL Server

-- Rebuild for high fragmentation:
ALTER INDEX ALL ON dbo.customer REBUILD WITH (ONLINE = ON);
-- Lighter option for low fragmentation:
-- ALTER INDEX ALL ON dbo.customer REORGANIZE;

Übliche Schwelle: 5-30% Fragmentierung REORGANIZE, >30% REBUILD. ONLINE ist ein Enterprise-Feature.

MongoDB

db.customer.reIndex()

Baut alle Indizes im Vordergrund neu auf und sperrt die Collection. Ab 6.0 läuft es nur auf einem Standalone (auf Replica-Set-Mitgliedern nicht erlaubt); im Replica Set einen einzelnen Index mit dropIndex + createIndex Knoten für Knoten (rolling) neu aufbauen.

Redis

# Not applicable (core). If RediSearch is used:
# FT.ALTER / rebuilding is done per the module documentation.

Das Key-Value-Modell kennt keine klassische Indexwartung.

In DBAtlas öffnen →