Smart Indexing for Faster Queries and Efficient Storage

Smart Indexing for Faster Queries and Efficient Storage

Table of Contents

In our previous blog post, we explored techniques for optimizing cardinality analysis to address resource constraints, enhance query performance, and streamline data processing. We discussed various data shaping strategies aimed at effectively managing high cardinality data and its implications for observability systems. In this blog we will talk about the storage considerations for high cardinality data.

To optimize the storage and retrieval of observability data, it's advantageous to use different indexing strategies for low and high cardinality attributes.

Understanding Low Cardinality vs. High Cardinality Data

Before diving into indexing strategies, let’s briefly recap what we mean by cardinality:

Indexing Strategies for Low Cardinality Attributes

For low cardinality attributes, using an inverted index is most beneficial. An inverted index is a data structure that maps each unique value of an attribute to a list of records containing that value. It's particularly efficient for filtering and aggregation operations. When querying data based on low cardinality attributes, such as categories or statuses, an inverted index allows for rapid lookup and retrieval of relevant records.

Example of Low Cardinality Indexing
Consider a monitoring system where you need to query records based on the “status” attribute. If you use an inverted index for this attribute, it looks like this:

When you need to query all records with the status “error,” the inverted index allows for quick retrieval of Record IDs 1, 7, and 9 without scanning through the entire dataset.

Indexing Strategies for High Cardinality Attributes

High cardinality attributes require a different indexing approach, as traditional indexing techniques may not scale well due to the large number of unique values. High cardinality indexes are useful for operations like unique counts, where you need to determine the count of distinct values for a particular attribute.

Advanced techniques such as data sketches can be used for high cardinality indexes. Data Sketches are a specialized class of algorithms known as streaming algorithms. Developed by Apache, they aim to expedite the analysis of large data volumes that are otherwise challenging to scale due to their demand for extensive compute resources and time to produce exact results.

Example of High Cardinality Indexing
By harnessing Data Sketches, observability solutions can effectively manage high cardinality attributes with significantly reduced computational and storage overhead compared to conventional methods. Some examples include:

Using different indexes for low and high cardinality attributes optimizes data storage and query performance. Low cardinality indexes facilitate efficient filtering and aggregation, speeding up common query operations. High cardinality indexes enable accurate unique counts and other operations on attributes with a large number of unique values, while minimizing resource usage.

Observe. Analyze. Automate.