<i id='JjEk7'><tr id='JjEk7'><dt id='JjEk7'><q id='JjEk7'><span id='JjEk7'><b id='JjEk7'><form id='JjEk7'><ins id='JjEk7'></ins><ul id='JjEk7'></ul><sub id='JjEk7'></sub></form><legend id='JjEk7'></legend><bdo id='JjEk7'><pre id='JjEk7'><center id='JjEk7'></center></pre></bdo></b><th id='JjEk7'></th></span></q></dt></tr></i><div id='JjEk7'><tfoot id='JjEk7'></tfoot><dl id='JjEk7'><fieldset id='JjEk7'></fieldset></dl></div>

<small id='JjEk7'></small><noframes id='JjEk7'>

    <legend id='JjEk7'><style id='JjEk7'><dir id='JjEk7'><q id='JjEk7'></q></dir></style></legend>
    <tfoot id='JjEk7'></tfoot>

    • <bdo id='JjEk7'></bdo><ul id='JjEk7'></ul>

      1. oracle索引如何选择和优化?

        时间:2023-10-25

          1. <i id='p3BFO'><tr id='p3BFO'><dt id='p3BFO'><q id='p3BFO'><span id='p3BFO'><b id='p3BFO'><form id='p3BFO'><ins id='p3BFO'></ins><ul id='p3BFO'></ul><sub id='p3BFO'></sub></form><legend id='p3BFO'></legend><bdo id='p3BFO'><pre id='p3BFO'><center id='p3BFO'></center></pre></bdo></b><th id='p3BFO'></th></span></q></dt></tr></i><div id='p3BFO'><tfoot id='p3BFO'></tfoot><dl id='p3BFO'><fieldset id='p3BFO'></fieldset></dl></div>
              <bdo id='p3BFO'></bdo><ul id='p3BFO'></ul>

              <small id='p3BFO'></small><noframes id='p3BFO'>

              1. <tfoot id='p3BFO'></tfoot>
                    <tbody id='p3BFO'></tbody>
                  <legend id='p3BFO'><style id='p3BFO'><dir id='p3BFO'><q id='p3BFO'></q></dir></style></legend>
                  本文介绍了oracle索引如何选择和优化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想知道是否有创建索引的一般规则.我如何选择应在此索引中包含哪些字段或何时不包含它们?

                  I would like to know if there are general rules for creating an index or not. How do I choose which fields I should include in this index or when not to include them?

                  我知道它总是取决于环境和数据量,但我想知道我们是否可以制定一些全球公认的关于在 Oracle 中创建索引的规则.

                  I know its always depends on the environment and the amount of data, but I was wondering if we could make some globally accepted rules about making indexes in Oracle.

                  推荐答案

                  Oracle 文档为索引选择提供了一组出色的注意事项:http://download.oracle.com/docs/cd/B28359_01/server.111/b28274/data_acc.htm#PFGRF004

                  The Oracle documentation has an excellent set of considerations for indexing choices: http://download.oracle.com/docs/cd/B28359_01/server.111/b28274/data_acc.htm#PFGRF004

                  19c 更新:https://docs.oracle.com/en/database/oracle/oracle-database/19/tgdba/designing-and-developing-for-performance.html#GUID-99A7FD1B-CEFD-4E91-9486-2CBBFC2B7A1D

                  引用:

                  • 考虑在 WHERE 子句中频繁使用的索引键.

                  • Consider indexing keys that are used frequently in WHERE clauses.

                  考虑经常用于连接 SQL 语句中的表的索引键.有关优化连接的更多信息,请参阅使用哈希集群提高性能"部分.

                  Consider indexing keys that are used frequently to join tables in SQL statements. For more information on optimizing joins, see the section "Using Hash Clusters for Performance".

                  选择具有高选择性的索引键.索引的选择性是表中具有相同索引键值的行的百分比.如果少数行具有相同的值,则索引的选择性是最佳的.注意:Oracle 会在您使用完整性约束定义的唯一键和主键的键和表达式上自动创建索引或使用现有索引.如果数据分布有偏差,因此一两个值的出现频率远低于其他值,那么索引低选择性列会很有帮助.

                  Choose index keys that have high selectivity. The selectivity of an index is the percentage of rows in a table having the same value for the indexed key. An index's selectivity is optimal if few rows have the same value. Note: Oracle automatically creates indexes, or uses existing indexes, on the keys and expressions of unique and primary keys that you define with integrity constraints. Indexing low selectivity columns can be helpful if the data distribution is skewed so that one or two values occur much less often than other values.

                  不要在具有很少不同值的键或表达式上使用标准 B 树索引.此类键或表达式通常具有较差的选择性,因此不会优化性能,除非经常选择的键值出现的频率低于其他键值.在这种情况下,您可以有效地使用位图索引,除非在高并发 OLTP 应用程序中频繁修改索引.

                  Do not use standard B-tree indexes on keys or expressions with few distinct values. Such keys or expressions usually have poor selectivity and therefore do not optimize performance unless the frequently selected key values appear less frequently than the other key values. You can use bitmap indexes effectively in such cases, unless the index is modified frequently, as in a high concurrency OLTP application.

                  不要索引经常修改的列.修改索引列的 UPDATE 语句和修改索引表的 INSERT 和 DELETE 语句比没有索引时花费的时间更长.此类 SQL 语句必须修改索引中的数据以及表中的数据.它们还会生成额外的撤消和重做.

                  Do not index columns that are modified frequently. UPDATE statements that modify indexed columns and INSERT and DELETE statements that modify indexed tables take longer than if there were no index. Such SQL statements must modify data in indexes as well as data in tables. They also generate additional undo and redo.

                  不要索引只出现在带有函数或运算符的 WHERE 子句中的键.使用除 MIN 或 MAX 以外的函数的 WHERE 子句或具有索引键的运算符不会使使用该索引的访问路径可用,除非使用基于函数的索引.

                  Do not index keys that appear only in WHERE clauses with functions or operators. A WHERE clause that uses a function, other than MIN or MAX, or an operator with an indexed key does not make available the access path that uses the index except with function-based indexes.

                  在大量并发 INSERT、UPDATE 和 DELETE 语句访问父表和子表的情况下,考虑索引参照完整性约束的外键.这样的索引允许对父表进行 UPDATE 和 DELETE 操作,而无需共享锁定子表.

                  Consider indexing foreign keys of referential integrity constraints in cases in which a large number of concurrent INSERT, UPDATE, and DELETE statements access the parent and child tables. Such an index allows UPDATEs and DELETEs on the parent table without share locking the child table.

                  选择索引键时,请考虑查询的性能提升是否值得插入、更新和删除的性能损失以及存储索引所需空间的使用.您可能希望通过比较带索引和不带索引的 SQL 语句的处理时间来进行试验.您可以使用 SQL 跟踪工具测量处理时间.

                  When choosing to index a key, consider whether the performance gain for queries is worth the performance loss for INSERTs, UPDATEs, and DELETEs and the use of the space required to store the index. You might want to experiment by comparing the processing times of the SQL statements with and without indexes. You can measure processing time with the SQL trace facility.

                  这篇关于oracle索引如何选择和优化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Hive 查询语言中的主键和索引是否可行? 下一篇:如何检查 MySQL 中的表字段上是否存在索引?

                  相关文章

                • <legend id='yp1IN'><style id='yp1IN'><dir id='yp1IN'><q id='yp1IN'></q></dir></style></legend>

                • <tfoot id='yp1IN'></tfoot>
                    <bdo id='yp1IN'></bdo><ul id='yp1IN'></ul>
                  <i id='yp1IN'><tr id='yp1IN'><dt id='yp1IN'><q id='yp1IN'><span id='yp1IN'><b id='yp1IN'><form id='yp1IN'><ins id='yp1IN'></ins><ul id='yp1IN'></ul><sub id='yp1IN'></sub></form><legend id='yp1IN'></legend><bdo id='yp1IN'><pre id='yp1IN'><center id='yp1IN'></center></pre></bdo></b><th id='yp1IN'></th></span></q></dt></tr></i><div id='yp1IN'><tfoot id='yp1IN'></tfoot><dl id='yp1IN'><fieldset id='yp1IN'></fieldset></dl></div>

                  1. <small id='yp1IN'></small><noframes id='yp1IN'>