DBAtlas · Atlas de operaciones de bases de datos

Reconstruir / reorganizar un índice

Oracle

ALTER INDEX customer_city_idx REBUILD ONLINE;

ONLINE reconstruye sin bloquear la tabla (Enterprise Edition). Para moverlo a otro tablespace: ... REBUILD TABLESPACE new_ts.

PostgreSQL

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

CONCURRENTLY (PG 12+) reconstruye sin bloquear las escrituras en la tabla; más lento pero seguro.

MySQL

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

LOCK=NONE permite escrituras concurrentes; INPLACE puede no ser posible para todos los ALTER.

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;

Umbral habitual: 5-30% de fragmentación REORGANIZE, >30% REBUILD. ONLINE es una función de Enterprise.

MongoDB

db.customer.reIndex()

Reconstruye todos los índices en primer plano y bloquea la colección. En 6.0+ solo se ejecuta en un standalone (no se permite en miembros de un replica set); en un replica set, reconstruya un índice con dropIndex + createIndex, nodo por nodo (rolling).

Redis

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

El modelo clave-valor no tiene mantenimiento de índices tradicional.

Abrir en DBAtlas →