是否更好在select语句中使用sql hint / * + opt_param('_ optimizer_use_feedback''false')* /

时间:2016-04-06 11:04:07

标签: sql indexing oracle11g

执行计划:

计划1:

  --------------------------------------------------------------------------------------------------------
  | Id  | Operation                   | Name                     | Rows  | Bytes | Cost (%CPU)| Time     |
  --------------------------------------------------------------------------------------------------------
  |   0 | SELECT STATEMENT            |                          |       |       |     9 (100)|          |
  |   1 |  TABLE ACCESS BY INDEX ROWID| EMP_HISTORY              |     1 |   190 |     9   (0)| 00:00:01 |
  |   2 |   INDEX RANGE SCAN          | IND_EMP_HISTORY_VALDT    |    15 |       |     4   (0)| 00:00:01 |
  --------------------------------------------------------------------------------------------------------

计划2:

  ------------------------------------------------------------------------------------------------------
  | Id  | Operation                   | Name                   | Rows  | Bytes | Cost (%CPU)| Time     |
  ------------------------------------------------------------------------------------------------------
  |   0 | SELECT STATEMENT            |                        |       |       |   281 (100)|          |
  |   1 |  TABLE ACCESS BY INDEX ROWID| EMP_HISTORY            |     3 |   570 |   281   (0)| 00:00:04 |
  |   2 |   INDEX RANGE SCAN          | IND_EMP_HISTORY_EMPNO  |  1203 |       |     6   (0)| 00:00:01 |
  ------------------------------------------------------------------------------------------------------

我通过在数据库级别禁用设置参数“_OPTIMIZER_USE_FEEDBACK”= FALSE为第一个plan1做了,但这不合适,因为它可能会影响其他查询。对于第二个问题,sql提示/ * + opt_param('_ optimizer_use_feedback''false ')* /用于select语句。

有人可以提供建议吗。

谢谢, 拉朱

0 个答案:

没有答案