A distributed database can distribute the query and most of the work of the sort operation, but can’t reduce the workload without using an index. This index is ordered by email, enabling the server to isolate only the user’s messages, and ignore the other 999,000 in the table. It still has 3 stages, but when you take a closer look, the scan stage only touches 1,000 rows.

10m read timeFrom cockroachlabs.com
Post cover image
Table of contents
How to get the most out of your indexesRule #0: Use statement plans to see how your database services your queryRule #1: Filter your query with your index to avoid a full table scanRule #2: Sort your query with your index to speed up the queryRule #3: Cover your query with your index to avoid the table entirelyCaveats to these index best practices
4 Comments

Sort: