You are on page 1of 1

 

DATA / CONTRIBUTED

The Di erence between Clustered


and Non-Clustered SQL Indexes
1 Oct 2019 10:25am, by Vikash Kumar

Indexes are used to speed the query process in the SQL,


which results in higher performance. They are similar to
the textbook indexes where you need to go to a speci c
chapter, nd the page number of the chapter and directly
visit that page. It can be troublesome to nd the desired
chapter without indexes and the process could be much
slower. The relational database management system
(RDBMS) has to go through all the records in the table to
Vikash Kumar
get the desired results if there are no indexes. This Vikash Kumar writes articles on
technical topics while working
method is called table-scanning.
in a so ware development
company Tatvaso .com. You
An index is a key that helps a database like MySQL, Oracle can follow him on Twitter and
and SQL Server to nd the associated row with the LinkedIn.

accurate key values in real-time. Basically, there are two


di erent types of indexes used in the SQL servers, clustered and non-clustered.

In this article, we will take a look at the di erence between these two indexes in
a relational database.

What Is a Clustered Index?


A clustered index is a kind of le that sorts the information in the table on their
key qualities. There is just one bunched list for every table in the database.
Consequently, there is just a solitary grouped record for each table. Here are a
few characteristics of the clustered index:

Default and sorted data storage


Helps to store Data and index at the same time
Clustered index scan and index seek
Key Lookup

Illustrative B-Tree Structure added below on how clustered Indexes work:

Image source: red-gate

Advantages:

Clustered indexes are an ideal option for range or group that get min, max
or count type queries.
Any relevant search goes directly to a particular point in the information
with the goal that you can continue perusing successively from the table.
It utilizes the location mechanism to nd the le section toward the start
of the range.
A compelling technique for range searches when a hunt key qualities are
mentioned.
Minimize the page transfers and maximize the cache hits.

Disadvantages:

Limit the page moves and augment the reserve searches.


Di erent methods for non-successive request
Makes a lot of consistent pages parts including information page just as list
pages.
Additional work for inserts, updates, and deletes in SQL.
Sets aside longer e ort to refresh the records.
Almost all the data is contained in the lead nodes of the index.

What Is a Non-Clustered Index?


A non-clustered index stores the meta-information in one area and les in
another area. The le comprises of the pointers to the location of that
information. A solitary table can have numerous non-bunched records as a le.
A non-clustering index is de ned in the non-ordering eld of the table and this
type of method improves the performance of the queries as they use keys that
are not assigned as a primary key. Here are a few characteristics of the
clustered index:

Stores only key values


Pointers to Heap/Clustered Index rows
Allows to access Secondary data
Bridging data
Operations of Index Scan and Index Seek
Create a nonclustered index for a table or view

Advantages:

It helps to retrieve the data on a quick basis from the database table.
Overhead costs can be avoided as compared to the clustered index.
It can be used to create more than one index as multiple non-clustered
indexes are there in RDBMS.

Disadvantages:

Store the data in the most logical order without permitting to sort the data
rows physically.
Lookup process on the non-clustered index is a bit expensive.
A corresponding update is required every time the clustering key is updates
so as to store it on the non-clustered index.

Illustrative B-Tree Structure added below on how non-clustered indexes work:

Non-Clustered Indexes store the clustering key for data Lookup in Clustered
Index.

What’s the Di erence Between these Indexes?


Speci cations Clustered Non-Clustered

Storage Stores the data pages of It does not permit storing


the index in the leaf data pages of the index in the
nodes. leaf nodes.

Size Quite large Small

Access to Quick and Faster Slower


Data

Extra Disk Not needed Required to separately store


Storage the data.

Key types The primary key of the Used with a unique constraint
table is a clustered index acting as a composite key on
by default. the table.

Attractive Performance of data Creates the columns that are


feature retrieval can be used in joins.
improved.

Feature image via Pixabay.

CONTRIBUTED

A newsletter digest of the week’s most important stories &


analyses.

Email Address

Subscribe

We don’t sell or share your email. By continuing, you agree to our Terms of Use
and Privacy Policy.

RELATED STORIES

KUBERNETES / MICROSERVICES / NETWORKING / CLOUD SERVICES / MICROSERVICES /


SPONSORED / CONTRIBUTED SERVERLESS / CONTRIBUTED
Meshy and Happy with All Cloud Native Roads Lead to
Kubernetes Ingress Fargate
18 Aug 2020 12:00pm, by Patrick McFadin and 18 Aug 2020 12:00pm, by Michele Mancioppi
Christopher Bradford and Thorsten Höger

SPONSORED FEED
How to migrate Kubernetes applications from Openshi 3 to Openshi
4
AUGUST 18, 2020

Cyber Hygiene From the Inside Out


AUGUST 18, 2020

AWS announces AWS Contact Center Intelligence solutions


AUGUST 18, 2020

Redis Security Course Is Now Live at Redis University


AUGUST 18, 2020

Troubleshoot Issues Faster with Enhanced Alert Analysis in New Relic


Applied Intelligence
AUGUST 18, 2020

Test Blog
AUGUST 18, 2020

OpenShi Performance Sensitive Applications: STAC-A2 With Intel


CPUs
AUGUST 18, 2020

Testing Kafka Streams – A Deep Dive


AUGUST 18, 2020

Incident Review: Meta-Review, August 2020


AUGUST 18, 2020

The Value of a Kubernetes Developer Certification


AUGUST 18, 2020

Pipelines, speed, and a new test summary: what you need to know
about CircleCI's new UI
AUGUST 18, 2020

Best Practices for Monitoring Kubernetes Cluster in Production with


AppDynamics
AUGUST 18, 2020

Ensure unrivaled customer experience with Davis AI-powered HTTP


and custom error analytics
AUGUST 18, 2020

Remote Learning: How WISEflow Powered Online Tests When


Universities Shut Down
AUGUST 18, 2020

Cloud Native Computing Foundation Announces Intuit as Gold Member


AUGUST 18, 2020

3 Takeaways From SaaStr Summit: Transformation, Opportunity, and


Social Responsibility by PagerDuty
AUGUST 18, 2020

TL;DR Tech Tips – How to Construct a Table with Flux


AUGUST 18, 2020

Building a Boring Kubernetes System


AUGUST 18, 2020

The Secret to High Performing Organizations


AUGUST 17, 2020

Want to iterate faster? Choose boring solutions


AUGUST 17, 2020

Meet the Business Development Research Team at MongoDB


AUGUST 17, 2020

Call for Papers for Ignite 2020: Share Your Cybersecurity Expertise
AUGUST 17, 2020

Linux Foundation project news for August 2020


AUGUST 17, 2020

How cf-for-k8s Reinvents Cloud Foundry as a Native Kubernetes App


Platform
AUGUST 17, 2020

Terrascan Leverages OPA to Make Policy as Code Extensible


AUGUST 17, 2020

Announcing New Collections on HashiCorp Learn


AUGUST 17, 2020

Introducing Kubernetes Enrichment Early Access


AUGUST 16, 2020

How to send iOS push notification from ABAP to SCP Mobile Services
AUGUST 16, 2020

Instant security information with the Snyk security badge


AUGUST 14, 2020

Use HAProxy Response Policies to Stop Threats


AUGUST 14, 2020

Tutorial: Scanning AWS CDK-generated templates at build time with


Bridgecrew
AUGUST 12, 2020

Introducing our 2020 State of the So ware Supply Chain Report


AUGUST 12, 2020

SSH vs. kubectl exec


AUGUST 11, 2020

GitHub Chaos Actions in Your CI/CD workflow [Part-1]


AUGUST 11, 2020

The Pain of Debugging WebAssembly


AUGUST 10, 2020

The Register – TriggerMesh hooks up with AWS EventBridge to connect


‘virtually any application’ with cloudy service
AUGUST 10, 2020

Akka at Enterprise Scale: Performance Tuning Distributed Applications


AUGUST 03, 2020

What’s a Service Mesh?


JULY 28, 2020

Our Application Powered World Requires Stronger Infrastructure


JULY 22, 2020

Citrix ADC CPX and Ingress Controller on the Azure Marketplace


JULY 15, 2020

Kubernetes our Own Way


JULY 08, 2020

Join us at our new blog home


JULY 02, 2020

Getting storage engines ready for fast storage devices


MARCH 16, 2020

ARCHITECTURE DEVELOPMENT OPERATIONS THE NEW STACK

Cloud Native Cloud Services CI/CD Ebooks

Containers Data Culture Podcasts

Edge/IoT Development DevOps Events


Microservices Machine Kubernetes Newsletter
Learning
Networking Monitoring About / Contact
Security
Serverless Service Mesh Sponsors

Storage Tools Sponsorship

Disclosures

Contributions

Twit Face YouT Sou Link SlideRSS

© 2020 The New Stack. All rights reserved.

Privacy Policy. Terms of Use.

You might also like