// oracle · query planner

cursor_sharing

Whether literals in SQL are replaced by bind variables so statements share cursors.

Padrão
EXACT
Range
EXACT, FORCE
Restart needed
Não
Default checked on
Oracle AI Database 26ai / 23ai

O que faz

FORCE turns WHERE id = 42 and WHERE id = 43 into one shared cursor, cutting hard parses for applications that do not use binds. SIMILAR is deprecated and no longer documented, though 23ai still accepts it.

Valor padrão

EXACT. EXACT (Oracle 23ai/26ai).

Check the current value

SHOW PARAMETER cursor_sharing

SELECT name, value, isdefault, issys_modifiable, isses_modifiable, ispdb_modifiable
FROM v$parameter
WHERE name = 'cursor_sharing';

Change it

ALTER SESSION SET cursor_sharing = FORCE;   -- this session

ALTER SYSTEM SET cursor_sharing = FORCE SCOPE=BOTH;

No restart: ALTER SYSTEM with SCOPE=BOTH applies immediately and is saved in the SPFILE. A session can also change its own value with ALTER SESSION. It can be set inside a PDB (ISPDB_MODIFIABLE = TRUE).

When to change it

As a stopgap for applications that build SQL with literals and cause library cache contention, ideally per session or service.

What can go wrong

Plans are shared across values with different selectivity (adaptive cursor sharing helps only partly), and the reported width of selected literals can change.

Questions about cursor_sharing

What is the default value of cursor_sharing in Oracle?

EXACT. EXACT (Oracle 23ai/26ai).

Does changing cursor_sharing require a restart?

No. No restart: ALTER SYSTEM with SCOPE=BOTH applies immediately and is saved in the SPFILE. A session can also change its own value with ALTER SESSION. It can be set inside a PDB (ISPDB_MODIFIABLE = TRUE).

When should I change cursor_sharing?

As a stopgap for applications that build SQL with literals and cause library cache contention, ideally per session or service.

Back to all Oracle settings, or check the Oracle manual for every option.

// one client for every engine

Check cursor_sharing on your own server

SQLly runs the query above against Oracle and the other engines in this reference, from one desktop app on macOS, Windows and Linux.