We had our oracle server choking during processing a select statement with close to 3500(!!) bind variables.
This select is, obviously, built dynamically by code that we can’t change. During the execution of this select the db server went to 100% cpu usage and our system almost halted.
We know how to reproduce this problem. So we can prevent this specific condition. But I am wondering if there is a way to protect the db ( by configuration) from this type of problems.
Update:
The select looks like that:
SELECT "FieldOfChar20"
FROM "TableOf111Krows"
WHERE ( "FieldOfChar20" BETWEEN :a0 AND :a1
OR "FieldOfChar20" BETWEEN :a2 AND :a3
OR "FieldOfChar20" BETWEEN :a4 AND :a5
snip snip
OR "FieldOfChar20" BETWEEN :a290 AND :a291
OR "FieldOfChar20" BETWEEN :a292 AND :a293
)
OR ( "FieldOfChar20" IN
(:a294,
:a295,
snip snip
:a1292,
:a1293
)
OR "FieldOfChar20" IN
(:a1294,
:a1295,
snip snip
:a2292,
:a2293
)
OR "FieldOfChar20" IN
(:a2294,
:a2295,
snip snip
:a3292,
:a3293
)
OR "FieldOfChar20" IN
(:a3294,
:a3295,
snip snip
:a3476,
:a3477
)
)
Oracle version is 10.2.0.2
In Oracle 8 and later, you can create usage profiles that control and limit the resources that any one session can consume. You create a profile and associate it to a user or role and the database will make sure that thing like logical/physical IO, CPU, and other limited resources are shared more equitably.
The interesting bits of a profile include:
As for bind variables, I’m not aware of any way to have the database or OCI client limit the use of these. In fact, bind variables are generally better for performance (and security) than embedded values in the SQL. Specifically, the reduce the number of hard parses that the database must perform when executing SQL that only varies in the values of parameters.