옵티마이저 / 병렬 처리 설정 조회·변경
Oracle
SHOW PARAMETER optimizer;
-- Session: ALTER SESSION SET optimizer_mode = FIRST_ROWS_10;
-- Parallelism: ALTER SESSION FORCE PARALLEL QUERY PARALLEL 4;optimizer_index_cost_adj, parallel_degree_policy 같은 설정은 실행 계획 선택에 영향을 주므로 신중하게 변경한다.
PostgreSQL
SHOW random_page_cost;
SHOW max_parallel_workers_per_gather;
-- Session: SET enable_seqscan = off;SSD에서는 random_page_cost ~1.1이 권장된다. enable_* 플래그는 진단용이며 영구적인 해결책이 아니다.
MySQL
SELECT @@optimizer_switch;
SET SESSION optimizer_switch='index_merge=off';optimizer_switch는 개별 최적화를 켜고 끈다. 세션 수준에서 테스트한다.
SQL Server
-- Instance-level MAXDOP and cost threshold:
EXEC sp_configure 'max degree of parallelism', 8; RECONFIGURE;
-- Database level: ALTER DATABASE SCOPED CONFIGURATION SET MAXDOP = 8;MAXDOP=0은 무제한이다. OLTP에서는 보통 4-8. 'cost threshold for parallelism'의 기본값 5는 대부분의 경우 너무 낮다.
MongoDB
# There are no optimizer parameters; indexes and query shape are decisive.
db.customer.find({...}).explain('allPlansExecution')allPlansExecution은 플래너가 평가한 모든 실행 계획을 보여 준다.
Redis
# Not applicable.플래너가 없다. io-threads와 데이터 구조 선택이 성능을 결정한다.
Elasticsearch
GET <index>/_settings?include_defaults=true
# search limits such as search.max_buckets, index.max_result_window옵티마이저가 없다. 샤드 수, routing, 쿼리 구조가 성능을 결정한다.