Gather statistics with advanced options (histograms, 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 controls histograms and degree controls parallelism. Use LOCK_TABLE_STATS to lock statistics.
PostgreSQL
ALTER TABLE customer ALTER COLUMN city SET STATISTICS 500;
ANALYZE customer;Per-column sampling target; default_statistics_target sets the global default.
MySQL
ANALYZE TABLE customer UPDATE HISTOGRAM ON city WITH 32 BUCKETS;Histogram support in MySQL 8.0; useful on columns that are filtered on but not selective.
SQL Server
UPDATE STATISTICS dbo.customer WITH FULLSCAN;
-- Filtered statistics: CREATE STATISTICS ... WHERE ...FULLSCAN is the most accurate; use SAMPLE on large tables. AUTO_UPDATE_STATISTICS for automatic updates.
MongoDB
// There are no manual statistics; the planner measures at runtime.
db.customer.getPlanCache().clear()Apart from clearing a stale plan cache, no manual statistics are needed.
Redis
# Not applicable.There are no statistics/optimizer.
Elasticsearch
# There is no statistics gathering; refresh searchability:
POST <index>/_refreshField data and doc values are used at query time; force merge reduces segments.