How MurmurHash Powers Real-Time Query Insights at Atatus Database Monitoring

Atatus database monitoring takes you to the next level by offering comprehensive tools to track query performance, uncover bottlenecks, and optimize database efficiency.

A key component of our database monitoring is the use of query signatures, where we leverage MurmurHash to generate unique, consistent identifiers for normalized SQL queries. This enables efficient aggregation and analysis of query metrics, even for complex workloads.

In this blog, we will explore how MurmurHash powers our query signature system and highlight the powerful features of Atatus database monitoring, including metrics tracking and EXPLAIN plans.

Lets get started!

Table of Contents:

  1. Why Query Signatures Matter in Database Monitoring?
  2. Why Atatus Uses MurmurHash Over MySQL Digest for Query Signature
  3. Key Benefits of MurmurHash for Atatus Database Monitoring
  4. How Atatus uses MurmurHash for Query Signatures
  5. Key Features of Database Monitoring in Atatus
  6. Benefits of using Atatus for Database Monitoring

Why Query Signatures Matter in Database Monitoring?

Databases often process similar SQL queries with slight variations. For instance:

SELECT * FROM users WHERE id = 123;
SELECT * FROM users WHERE id = 456;

While the queries differ in the literal value of id, they are semantically identical. Treating them as separate can overload your monitoring system with duplicate entries, making it harder to understand overall performance.

To solve this, we normalize SQL queries by replacing literals with placeholders:

SELECT * FROM users WHERE id = ?;

A query signature is then generated from this normalized query text. At Atatus, we use MurmurHash for this task.

Why Atatus Uses MurmurHash Over MySQL Digest for Query Signature

At Atatus, we chose MurmurHash to generate query signatures for our database monitoring, as opposed to relying on MySQL's digest hash from the Performance Schema. This decision was driven by the unique demands of real-time query monitoring, such as speed, cross-platform compatibility, and seamless integration.

While MySQL digest hash algorithms (like SHA1 or MD5) offer cryptographic security, their overhead and reliance on MySQL make them less suitable for a multi-database monitoring platform like Atatus.

MurmurHash is a fast, lightweight, and efficient hash function that works well for non-cryptographic purposes, such as query aggregation. It provides a low-collision hashing mechanism, which ensures that normalized query texts produce consistent signatures, even for semantically identical queries.

In contrast, MySQL's digest hash ties directly to MySQL's internal workings and hashes raw query texts, which adds complexity and limits flexibility when trying to integrate into a broader, cross-database monitoring system.

One of the most significant advantages of using MurmurHash is its compact output, which helps reduce storage requirements when processing vast numbers of query signatures.

MurmurHash is platform-agnostic, providing consistent hashing across different databases while maintaining the performance needed for large-scale monitoring. This makes MurmurHash an ideal choice for Atatus' database monitoring platform.

Key Benefits of MurmurHash for Atatus Database Monitoring

1. Speed and Efficiency: MurmurHash is a fast, non-cryptographic hash function, making it well-suited for real-time query monitoring. With thousands of queries processed per second, MurmurHash ensures that hashing doesn't affect database performance or slow down the monitoring process.

2. Uniform Distribution: MurmurHash generates uniformly distributed hash values, minimizing the risk of collisions. This ensures that identical normalized queries always map to the same signature, while distinct queries generate unique signatures, making query tracking and aggregation more reliable.

3. Compact and Consistent: The compact hash output of MurmurHash ensures that storage remains efficient even when handling millions of query signatures. Additionally, its consistent behaviour across platforms provides the reliability needed for distributed environments, ensuring Atatus can monitor queries from various databases seamlessly.

How Atatus uses MurmurHash for Query Signatures

Here's a simplified view of how query signature generation works in Atatus:

(i). Normalization: Raw SQL queries are parsed and literals (e.g., numbers, strings) are replaced with placeholders.

Example:

SELECT * FROM users WHERE id = 123;

becomes

SELECT * FROM users WHERE id = ?;

(ii). Hashing: The normalized query text is passed through MurmurHash to generate a signature. MurmurHash takes this normalized query text as input. It applies a series of transformations to produce a fixed-size numerical output (the hash)

Example in Python:

import mmh3

normalized_query = "SELECT * FROM users WHERE id = ?;"
query_signature = mmh3.hash(normalized_query)
print(f"Query Signature: {query_signature}")

(iii). Aggregation and Metrics Tracking: Using the query signature, Atatus aggregates metrics like execution time, frequency, and latency. This provides a clear overview of your database's performance.

Key Features of Database Monitoring in Atatus

At Atatus, we provide a robust set of tools to help you monitor and optimize your database:

Atatus Database Monitoring
Key Features of Atatus Database Monitoring

1. Query Metrics

Atatus tracks essential metrics for every query signature, including:

  • Execution Time: Identify slow queries.
  • Frequency: Discover queries executed frequently.
  • Error Rates: Detect queries causing database errors.

2. EXPLAIN Plans

With Atatus understand the execution plan for your queries with detailed EXPLAIN output:

  • Visualize table scans, indexes used, and joins.
  • Identify performance bottlenecks (e.g., missing indexes or expensive joins).
  • Compare explain plans for normalized queries to spot inefficiencies.

Example:

+----+-------------+-------+------+---------------+------+---------+------+------+----------+-------+
| id | select_type | table | type | possible_keys | key  | key_len | ref  | rows | filtered | Extra |
+----+-------------+-------+------+---------------+------+---------+------+------+----------+-------+
|  1 | SIMPLE      | users | ALL  | NULL          | NULL | NULL    | NULL | 1000 |   100.00 |       |
+----+-------------+-------+------+---------------+------+---------+------+------+----------+-------+

Atatus simplifies this information, showing actionable insights to optimize your queries.

3. Real-Time Query Insights

Monitor queries as they happen. Identify and resolve slow queries before they impact your application.

4. Historical Analysis

Review trends over time, helping you track the long-term health of your database and plan optimizations.

5. Database-Specific Support

Whether you're using MySQL, PostgreSQL, or MongoDB, Atatus tailors its monitoring to your database's specifics.

Benefits of using Atatus for Database Monitoring

  1. Enhanced Performance: Quickly identify and optimize slow queries.
  2. Better Resource Utilization: Reduce database load by optimizing frequently executed queries.
  3. Proactive Issue Resolution: Detect anomalies and fix issues before they affect your users.
  4. Developer Productivity: With clear insights and query explain plans, your developers can focus on fixing the right problems.

Conclusion

At Atatus, we utilize MurmurHash to create efficient and consistent query signatures by normalizing SQL queries. This process simplifies tracking and analyzing similar queries by grouping them under unique identifiers, reducing redundancy. Combined with our advanced monitoring capabilities, it enables precise insights into query execution and performance metrics.

With features like real-time query insights, metrics tracking, and detailed EXPLAIN plans, Atatus provides a comprehensive view of your database’s performance. These tools empower you to identify bottlenecks, optimize queries, and enhance overall database efficiency. Ready to take charge? Explore Atatus and experience the difference.

Start your 14-day free trial of Atatus today!

Atatus

#1 Solution for Logs, Traces & Metrics

tick-logo APM

tick-logo Kubernetes

tick-logo Logs

tick-logo Synthetics

tick-logo RUM

tick-logo Serverless

tick-logo Security

tick-logo More

Pavithra Parthiban

Pavithra Parthiban

A technical content writer specializing in monitoring and observability tools, adept at making complex concepts easy to understand.
Chennai