惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Schneier on Security
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
T
Threat Research - Cisco Blogs
C
Cyber Attacks, Cyber Crime and Cyber Security
C
CXSECURITY Database RSS Feed - CXSecurity.com
A
Arctic Wolf
Security Latest
Security Latest
Simon Willison's Weblog
Simon Willison's Weblog
I
Intezer
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
T
Troy Hunt's Blog
Latest news
Latest news
Help Net Security
Help Net Security
S
Security Affairs
Webroot Blog
Webroot Blog
The Hacker News
The Hacker News
AI
AI
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
T
Tor Project blog
Forbes - Security
Forbes - Security
Google DeepMind News
Google DeepMind News
AWS News Blog
AWS News Blog
Attack and Defense Labs
Attack and Defense Labs
P
Proofpoint News Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
H
Help Net Security
L
Lohrmann on Cybersecurity
S
SegmentFault 最新的问题
Google Online Security Blog
Google Online Security Blog
MongoDB | Blog
MongoDB | Blog
Cyberwarzone
Cyberwarzone
The Last Watchdog
The Last Watchdog
S
Securelist
N
News and Events Feed by Topic
S
Secure Thoughts
F
Fortinet All Blogs
博客园_首页
C
Cybersecurity and Infrastructure Security Agency CISA
量子位
M
MIT News - Artificial intelligence
F
Full Disclosure
T
The Blog of Author Tim Ferriss
T
Tailwind CSS Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Microsoft Security Blog
Microsoft Security Blog
I
InfoQ
P
Privacy International News Feed
L
LangChain Blog
Know Your Adversary
Know Your Adversary
C
CERT Recently Published Vulnerability Notes

Datadog | The Monitor blog

Introducing our open source AI-native SAST Instrument and monitor Boomi integration flows with OpenTelemetry and Datadog Platform engineering metrics: What to measure and what to ignore Integrate Recorded Future threat intelligence with Datadog Cloud SIEM CI/CD security: threat modeling using a MITRE-style threat matrix CI/CD security: How to secure your GitHub ecosystem Ingress NGINX is EOL: A practical guide for migrating to Kubernetes Gateway API Operating agentic AI with Amazon Bedrock AgentCore and Datadog LLM Observability: Lessons from NTT DATA Introducing the Datadog Code Security MCP Capture and analyze custom heatmaps in Session Replay Understand session replays faster with AI summaries and smart chapters Monitor ClickHouse query performance with Datadog Database Monitoring How we designed empathetic alert sounds for on-call engineers Search and act across Datadog to resolve issues faster with Bits Assistant Measure the business impact of every product change with Datadog Experiments Analyzing round trip query latency Configuring JavaScript caches for better performance Introducing Bits AI Dev Agent for Code Security Datadog achieves ISO 42001 certification for responsible AI Monitor Nutanix clusters, hosts, and VMs with Datadog Monitor Juniper Mist in Datadog A new Host Map for modern infrastructure Annotate traces to improve LLM quality with Datadog LLM Observability What’s new in Cloud SIEM: AI-powered investigations, enhanced threat intelligence, and scalable security operations Explore Kubernetes with native OpenTelemetry data Monitor Oracle Fusion Cloud Applications with Datadog Announcing the Datadog Terraform provider v4.0.0 Scaling Kubernetes workloads on custom metrics How to design cloud environments for AI-powered threat analysis Monitor Aruba Central in Datadog How we centralize and remediate risks with Datadog Case Management Accelerate incident response with Datadog and ServiceNow Monitor your application and network load balancer logs Understanding Karpenter architecture for Kubernetes autoscaling Tools for collecting metrics and logs from Karpenter Monitor Karpenter with Datadog What your product data is actually saying Key metrics for monitoring Karpenter Securing Datadog’s platform in the AI age: The role of observability data Four ways engineering teams use the Datadog MCP Server to power AI agents Approaching your observability migration with the right mindset Meet the new Bits AI SRE: Deeper reasoning, twice as fast Key learnings from the 2026 State of DevSecOps study Use plain English to query your multi-cloud infrastructure in Resource Catalog Simplifying troubleshooting across the user journey with Datadog Synthetic Monitoring Protect your OCI resources with Datadog Cloud Security This Month in Datadog - February 2026 Amazon EC2 security: How misconfigured and public AMIs expand your cloud attack surface Enable end-to-end visibility into your Java apps with a single command Measure and improve mobile app startup performance with Datadog RUM Evaluating our AI Guard application to improve quality and control cost Identify untested code across every level of your codebase Make use of guardrail metrics and stop babysitting your releases Monitor Versa Networks SD-WAN performance in Datadog Improve performance and reliability with APM Recommendations Remediate transitive vulnerabilities faster with Datadog Software Composition Analysis Generate audit-ready vulnerability and compliance reports with Datadog Sheets Monitor Fortinet FortiManager performance in Datadog Improve test coverage across codebases with Datadog Code Coverage Move fast, don’t break things: Consistent testing standards at scale Enrich logs with ServiceNow CMDB context before routing to any SIEM or logging tool Monitor Lustre with Datadog Make faster, better product decisions with Datadog Product Analytics Surface and remediate runtime posture issues with Workload Protection Findings Protect agentic AI applications with Datadog AI Guard How to optimize JavaScript code with CSS Trace Google Pub/Sub workloads in Cloud Run with Datadog Detect human names in logs with ML in Sensitive Data Scanner How we cut our NLQ agent debugging time from hours to minutes with LLM Observability Debug PostgreSQL query latency faster with EXPLAIN ANALYZE in Datadog Database Monitoring Datadog acquires Propolis Unify and correlate frontend and backend data with retention filters Scale compliance across global frameworks with Datadog Cloud Security Monitor Arista VeloCloud SD-WAN performance with Datadog Building reliable dashboard agents with Datadog LLM Observability Simplify log collection and aggregation for MSSPs with Datadog Observability Pipelines Mitigation for Node.js denial-of-service vulnerability affecting Datadog APM Automate flaky test fixes with the Bits AI Dev Agent and Test Optimization How we built an AI SRE agent that investigates like a team of engineers Datadog integrations 2025 recap: Observability for AI, security, and hybrid cloud Design effective executive dashboards with Datadog Implement dbt data quality checks with dbt-expectations Bring faster visibility into AWS Lambda functions with remote instrumentation Troubleshoot faster with the GitLab Source Code integration in Datadog How Cambia Health Solutions saved $30,000 monthly with Cloud Cost Management and the Datadog Resource Catalog Normalize any logs for Cloud SIEM with Datadog's OCSF processor Optimizing Datadog at scale: Cost-efficient observability at Zendesk Detect, diagnose, and resolve network issues easily with CNM Network Health Securing customer logins with breach intelligence Connect engineering errors to user impact in early-stage products Cilium configuration for Kubernetes operations at scale Designing feedback loops for progressive delivery Ship features faster and safer with Datadog Feature Flags Choosing the right OpenTelemetry Collector distribution Route your monitor alerts with Datadog monitor notification rules Automate Cloud SIEM investigations with Bits AI Security Analyst Cloud threat detection: How to identify risky activity across control and data planes Collecting Kafka performance metrics Monitoring Kafka with Datadog Monitoring Kafka performance metrics
Not all index scans are equal: How we cut query latency by over 99%
Nenad Noveljic, Bowen Chen · 2026-04-09 · via Datadog | The Monitor blog

When engineers investigate SQL queries, they normally think of index scans as a fast and efficient step in the query’s execution plan. When executed correctly, they fetch only the relevant rows from your table as opposed to sequential scans that read the entire table, reducing latency and query costs. However, just because an execution plan uses an index scan doesn’t mean that the scan is fast or performant.

In this blog, we’ll unravel a case of an expensive index scan that Datadog was using to query a PostgreSQL table in our production environment. We’ll walk you through why the execution plan was inefficient and slow despite being an index scan, and how we used a targeted index to cut average query latency from 300 ms to 38 μs.

We’ll also cover updates to Datadog Database Monitoring (DBM) that automatically detect suboptimal index scans across PostgreSQL and other databases. DBM flags these issues and recommends a fix so you can surface and resolve similar patterns without manual investigation.

Understanding the PostgreSQL table and its composite index

Our PostgreSQL database includes a recommendations table that stores customer recommendations, such as long-running queries, missing indexes, query regressions, and more.

Table "public.recommendations"

Column | Type | Nullable | Default

------------+--------+----------+------------------------------------------------

id | bigint | not null | nextval('recommendations_id_seq'::regclass)

org_id | bigint | not null |

type | text | not null |

dbms | text | not null |

entity | text | not null |

severity | text | |

tags | jsonb | |

description | text | |

Indexes:

"recommendations_pkey" PRIMARY KEY, btree (id)

"unique_entity_dbms_org_type" UNIQUE, btree (entity, dbms, org_id, type)

One of the indexes for this table is unique_entity_dbms_org_type, a composite unique index that ensures no two rows share the same combination of entity, dbms, org_id, and type. The most frequently executed query joins recommendations with a separate mute table that tracks muted recommendations for each customer organization. Each time a user opens DBM, our frontend runs this query to determine which recommendations to show within the Datadog app.

SELECT r.id, r.entity, r.type, r.severity,

array_agg(m.id) AS mute_ids

FROM recommendations r

LEFT JOIN mute m ON m.recommendation_id = r.id

WHERE r.org_id = ?

AND r.dbms = ?

GROUP BY r.id;

Our engineers first flagged this query for investigation after noticing that its runtime seemed much longer than expected, especially given its frequency of execution. Upon inspecting its execution plan in DBM, they confirmed that the query was performing an index scan using unique_entity_dbms_org_type.

By aligning the query predicates with the column order of the index, Datadog engineers cut the node cost of the query by over 99%.

Normally, an engineer might conclude their investigation after confirming the correct index and scan type is being used. However, this query had a relative node cost of 317,000 and accounted for 100% of the total query cost, while returning only 25 rows. The mismatch between node cost and the number of rows returned was a huge red flag. It signaled that the query was indexing inefficiently and driving up the query’s latency.

Why does column order matter in a B-tree index?

The reason our index scan was so expensive was because of a mismatch between the column order of our index and the query’s predicates. unique_entity_dbms_org_type is defined as a B-tree index, which means its entries are ordered from left to right by column:

(entity, dbms, org_id, type)

However, our query filters the recommendations table using the following:

WHERE r.org_id = ? AND r.dbms = ?

The leading column of our index is entity. Because the query does not filter on entity, PostgreSQL cannot seek directly to the relevant portion of the index. Instead it has to scan a larger range of index entries—increasing disk I/O and node costs—and apply the dbms and org_id filters as it scans.

How to optimize index scan latency using targeted indexes

We still needed to keep the unique index and its columns to ensure that each entry in recommendations remained unique. To optimize for our query pattern, we added a second, targeted index:

CREATE INDEX idx_recommendations_org_dbms

ON recommendations (org_id, dbms);

Using this targeted index, PostgreSQL is able to directly seek rows by org_id, followed by dbms. After adding the targeted index, we reduced the node cost of our index scan to 104.9 from its previous cost of 317,000.

By investigating the query in DBM, engineers noticed a mismatch between the number of rows returned and the node cost.

While node costs are relative, we can see how this affects the real-time performance of our database by viewing its runtime. Prior to creating the targeted index, the average latency for our query exceeded 300 ms. After applying the index, our average query latency decreased to 38 μs. Even though both execution plans used index scans, we were able to decrease latency by over 99% simply by ensuring that our indexes were aligned with the query’s predicates.

Applying a targeted index reduced the average latency of the query from 300 ms to 38 μs.

When investigating query performance in your databases, you can use the following checklist:

  • Identify your query’s most selective WHERE predicates.

  • Confirm that existing composite indexes start with these predicates.

  • Check for a large mismatch between rows returned and the plan’s node cost.

  • Create a targeted index to match predicate column order.

  • Use DBM metrics to validate changes in costs and runtime.

Detect suboptimal index scans with Datadog DBM

DBM Recommendations analyze these metrics and data to surface high-priority issues within your database instances and queries. We’ve expanded our recommendations to automatically detect suboptimal index scans similar to the pattern covered in this blog, enabling customers to surface and remediate these issues without manual investigation.

Surface suboptimal index scans with DBM Recommendations.

Recommendations is an included feature for all DBM customers. To see how you can use Datadog to detect and fix suboptimal index scans in your databases, sign up for a free 14-day trial today.