• Clustered vs Nonclustered Index: Key Differences with Example


    Clustered vs Non-clustered Index: Key Differences with Example

    What is an Index?
    An Index is a key built from one or more columns in the database that speeds up fetching rows from the table or view. This key helps a Database like Oracle, SQL Server, MySQL, etc. to find the row associated with key values quickly.

    Two types of Indexes are:

    Clustered Index
    Non-Clustered Index
    In this tutorial, you will learn:

    What is an Index?
    What is a Clustered index?
    What is Non-clustered index?
    Characteristic of Clustered Index
    Characteristics of Non-clustered Indexes
    An example of a clustered index
    An example of a non-clustered index
    Differences between Clustered Index and NonClustered Index
    Advantages of Clustered Index
    Advantages of Non-clustered index
    Disadvantages of Clustered Index
    Disadvantages of Non-clustered index

    Differences between Clustered Index and NonClustered Index

    Advantages of Clustered Index
    The pros/benefits of the clustered index are:

    Clustered indexes are an ideal option for range or group by with max, min, count type queries
    In this type of index, a search can go straight to a specific point in data so that you can keep reading sequentially from there.
    Clustered index method uses location mechanism to locate index entry at the start of a range.
    It is an effective method for range searches when a range of search key values is requested.
    Helps you to minimize page transfers and maximize the cache hits.
    Advantages of Non-clustered index
    Pros of using non-clustered index are:

    A non-clustering index helps you to retrieves data quickly from the database table.
    Helps you to avoid the overhead cost associated with the clustered index
    A table may have multiple non-clustered indexes in RDBMS. So, it can be used to create more than one index.
    Disadvantages of Clustered Index
    Here, are cons/drawbacks of using clustered index:

    Lots of inserts in non-sequential order
    A clustered index creates lots of constant page splits, which includes data page as well as index pages.
    Extra work for SQL for inserts, updates, and deletes.
    A clustered index takes longer time to update records when the fields in the clustered index are changed.
    The leaf nodes mostly contain data pages in the clustered index.
    Disadvantages of Non-clustered index
    Here, are cons/drawbacks of using non-clustered index:

    A non-clustered index helps you to stores data in a logical order but does not allow to sort data rows physically.
    Lookup process on non-clustered index becomes costly.
    Every time the clustering key is updated, a corresponding update is required on the non-clustered index as it stores the clustering key.

  • 相关阅读:
    特性类
    WebGL中的第三个小程序(着色器)
    C#紧耦合的例子
    特性
    python两个目录匹配,粘贴图片
    Leetcode 53
    逻辑回归-1.原理
    多项式回归-4.模型正则化
    python 线程
    python 进程
  • 原文地址:https://www.cnblogs.com/chucklu/p/16421638.html
Copyright © 2020-2023  润新知