Indexes are the best apposite choice for quickly retrieving the records. This is nothing but cutting down the number of Disk IO. Instead of scanning the complete table for the results, we can decrease the number of IO's or page fetches using index structures such as B-Trees or Hash Indexes to retrieve the data faster. The most convenient way to consider an index is to think like a dictionary. It has words and its corresponding definitions against those words. The dictionary will have an index on "word" because when we open a dictionary and we want to fetch its corresponding word quickly, then find its definition. The dictionary generally contains just a single index - an index ordered by word. When we modify any record and change the corresponding value of an indexed column in a clustered index, the database might require moving the entire row into a separately new position to maintain the rows in the sorted order. This action is essentially turned into an update query into a DELETE followed by an INSERT, and it decreases the performance of the query. The clustered index in the table can often be available on the primary key or a foreign key column because key values usually do not modify once a record is injected into the database.
翻译:索引是快速检索记录的最佳适当选择。 这只不过是减少磁盘 IO 的数量而已。 我们不用扫描完整表格的完整结果, 也可以用 B- Treees 或 Hash 索引等索引结构来减少 IO 或页面获取的数量, 以便更快地检索数据。 最方便地考虑索引的方法是像字典一样思考索引。 它有词及其相对这些词的相应定义。 字典上将有一个“ 字典” 索引, 因为当我们打开字典并想要快速获取相应的单词, 然后找到定义 。 字典一般只包含一个单一索引 - 单词命令的索引 。 当我们修改任何记录并改变组合索引索引中索引列的相应值时, 数据库可能需要将整个行移动到一个单独的新位置, 以维持排序顺序中的行。 这一行动基本上变成更新查询, 由 INSERT 跟随为 DELETE, 并且它会降低查询的性能。 表格中的组合索引通常会在主键或外部键列上提供, 因为通常不会修改数据库。