Recopilar estadísticas con opciones avanzadas (histogramas, etc.)
Oracle
EXEC DBMS_STATS.GATHER_TABLE_STATS(
ownname=>'HR', tabname=>'EMPLOYEE',
estimate_percent=>DBMS_STATS.AUTO_SAMPLE_SIZE,
method_opt=>'FOR ALL COLUMNS SIZE AUTO', degree=>4);method_opt controla los histogramas y degree el paralelismo. Use LOCK_TABLE_STATS para bloquear las estadísticas.
PostgreSQL
ALTER TABLE customer ALTER COLUMN city SET STATISTICS 500;
ANALYZE customer;Objetivo de muestreo por columna; default_statistics_target establece el valor global por defecto.
MySQL
ANALYZE TABLE customer UPDATE HISTOGRAM ON city WITH 32 BUCKETS;Soporte de histogramas en MySQL 8.0; útil en columnas por las que se filtra pero que no son selectivas.
SQL Server
UPDATE STATISTICS dbo.customer WITH FULLSCAN;
-- Filtered statistics: CREATE STATISTICS ... WHERE ...FULLSCAN es el más preciso; use SAMPLE en tablas grandes. AUTO_UPDATE_STATISTICS para actualizaciones automáticas.
MongoDB
// There are no manual statistics; the planner measures at runtime.
db.customer.getPlanCache().clear()Aparte de limpiar una caché de planes obsoleta, no se necesitan estadísticas manuales.
Redis
# Not applicable.No hay estadísticas/optimizador.
Elasticsearch
# There is no statistics gathering; refresh searchability:
POST <index>/_refreshField data y doc values se usan en tiempo de consulta; force merge reduce los segmentos.