1

我正在尝试针对由 6 个表构建的 Oracle 视图优化一些遗留 SQL SP,每个表由相同的字段连接,一个数字 ID。视图中的一些表有一个索引,它完全是这个 ID 字段,其他的则没有。

如果我只使用此字段在视图中的其余表上创建索引,然后使用此字段作为唯一参数执行实际的选择查询,它会显着提高性能吗?如果有必要,我可以发布 s.proc,因为 SP 中可能存在其他可能无法通过单独索引来解决的缺陷。有问题的查询需要大约 6 秒才能返回 1 行,没有一个表包含大量记录,无论如何也不超过 100,000 条记录。

提前致谢,

斯科特

4

2 回答 2

0

If the ID field is the first column in the indexes (or the only column) then adding indexes to the ID column of those remaining tables that need them will improve the query if you are returning a small number of rows.

于 2011-08-26T08:35:54.417 回答
0

确保视图中的每个表都有一个以 id 字段开头的索引。只要 id 字段在前,索引就可以包含更多字段。

如果这对性能没有帮助,请发布选择语句和解释计划。

于 2011-08-26T08:33:45.507 回答