DBAtlas · Atlas für Datenbankbetrieb

Ausführungsplan fixieren / erzwingen (Plan Baseline / Hint)

Oracle

-- Load the good plan from the cursor cache as a baseline:
DECLARE n NUMBER; BEGIN
  n := DBMS_SPM.LOAD_PLANS_FROM_CURSOR_CACHE(sql_id => '&sql_id');
END;
/

SQL Plan Management fixiert den Plan; der stärkste Schutz gegen Regressionen. Auch /*+ ... */-Hints sind möglich.

PostgreSQL

-- There is no built-in plan pinning; the pg_hint_plan extension:
/*+ IndexScan(customer customer_city_idx) */ SELECT ... ;

Alternative: auf Session-Ebene mit Einstellungen wie enable_seqscan steuern; für dauerhaftes Fixieren pg_hint_plan nutzen.

MySQL

SELECT /*+ INDEX(customer customer_city_idx) */ * FROM customer WHERE city='Ankara';

Optimizer-Hints werden in die Abfrage eingebettet. Für dauerhaftes Umschreiben das Query-Rewrite-Plugin nutzen.

SQL Server

-- Force the good plan in Query Store:
EXEC sp_query_store_force_plan @query_id = 42, @plan_id = 17;

Query Store muss aktiviert sein. Alternativ OPTION (USE PLAN N'...') oder ein Plan Guide.

MongoDB

// Force an index for the query:
db.customer.find({ city: "Ankara" }).hint({ city: 1 })
// Persistent: db.customer.getPlanCache() / index filter

hint erzwingt einen bestimmten Index; einen veralteten Plan mit planCacheClear löschen.

Redis

# Not applicable: there is no query planner.

Die Performance ergibt sich aus Datenstruktur und Befehlskomplexität.

Elasticsearch

# There is no plan pinning; optimize the query/index and routing.
GET <index>/_search { "profile": true, "query": {...} }

Mit profile siehst du, welche Abfrage teuer ist; Steuerung über Shards/Routing.

In DBAtlas öffnen →