Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Getting Started with CockroachDB

You're reading from   Getting Started with CockroachDB A guide to using a modern, cloud-native, and distributed SQL database for your data-intensive apps

Arrow left icon
Product type Paperback
Published in Mar 2022
Publisher Packt
ISBN-13 9781800560659
Length 246 pages
Edition 1st Edition
Languages
Concepts
Arrow right icon
Author (1):
Arrow left icon
Kishen Das Kondabagilu Rajanna Kishen Das Kondabagilu Rajanna
Author Profile Icon Kishen Das Kondabagilu Rajanna
Kishen Das Kondabagilu Rajanna
Arrow right icon
View More author details
Toc

Table of Contents (17) Chapters Close

Preface 1. Section 1: Getting to Know CockroachDB
2. Chapter 1: CockroachDB – A Brief Introduction FREE CHAPTER 3. Chapter 2: How Does CockroachDB Work Internally? 4. Section 2: Exploring the Important Features of CockroachDB
5. Chapter 3: Atomicity, Consistency, Isolation, and Durability (ACID) 6. Chapter 4: Geo-Partitioning 7. Chapter 5: Fault Tolerance and Auto-Rebalancing 8. Chapter 6: How Indexes Work in CockroachDB 9. Section 3: Working with CockroachDB
10. Chapter 7: Schema Creation and Management 11. Chapter 8: Exploring the Admin User Interface 12. Chapter 9: An Overview Of Security Aspects 13. Chapter 10: Troubleshooting Issues 14. Chapter 11: Performance Benchmarking and Migration 15. Other Books You May Enjoy Appendix: Bibliography and Additional Resources

Introduction to indexes

An index or a database index helps with returning the query results quickly, by avoiding full table scans. An index can be created for a specific table and can include one or more keys. Keys refer to the columns in the table. However, there will be extra space used to keep a separate sorted copy of indexed columns.

Let's take a simple example and see how an index works.

Consider a population table with the following columns and some sample values:

Figure 6.1 – Population table

Now, let's say you just want to retrieve the list of populations for specific continents, for example:

SELECT population_in_millions, country FROM population WHERE continent = "Asia";

Here, in order to find rows 1 and 4, which are countries in Asia, you would have to iterate through each of the rows in the table, which is called a full table scan.

Now, if you want to avoid a full table scan, you can create an index...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image