Are SQL binding options related to performance?

Suppose I have a table with a name Projectswith a column with a name Budgetwith a standard index of B-Tree. The table shows 50,000 projects, and only 1% of them have a budget of more than one million. If I run the SQL query:

SELECT * From Projects WHERE Budget > 1000000;

The scheduler will use index range scan on Budgetto get rows from the heap table. However, if I use the query:

SELECT * From Projects WHERE Budget > 50;

The scheduler will most likely perform sequential scans in the table, as he will know that this query will ultimately return most or all of the rows, and there is no reason to load all the index pages in memory.

Now let's say that I run the query:

SELECT * From Projects WHERE Budget > :budget;

Where :budgetis the binding parameter passed to my database. From what I read, the request, as indicated above, will be cached, and no power data can be output. In fact, most databases will simply accept even distribution, and the cached query plan will reflect that. This surprised me, as usual, when you read about the benefits of binding options to prevent SQL injection attacks.

Obviously, this can improve performance if the resulting query plan is the same since the new plan does not need to be compiled, but it can also hurt performance if the values :budgetvary greatly.

: , ? , ?

. , , mySql, mySql SQL. , , Postgres, Oracle MS SQL.

+5
2

Oracle, , .

( , 9i) Oracle peeking. , . , , . 99% , , , , , . , , (, , , ), .

11g, Oracle . . , . N , , N- , , . , . , DBA , DBA , , .

+7

All Articles