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

推荐订阅源

cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Y
Y Combinator Blog
O
OpenAI News
K
Kaspersky official blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Hacker News: Ask HN
Hacker News: Ask HN
S
SegmentFault 最新的问题
L
Lohrmann on Cybersecurity
S
Securelist
C
CERT Recently Published Vulnerability Notes
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
IT之家
IT之家
Jina AI
Jina AI
大猫的无限游戏
大猫的无限游戏
V
Vulnerabilities – Threatpost
量子位
爱范儿
爱范儿
I
Intezer
博客园 - 叶小钗
The Hacker News
The Hacker News
N
News and Events Feed by Topic
Project Zero
Project Zero
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
P
Privacy & Cybersecurity Law Blog
Google Online Security Blog
Google Online Security Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
H
Heimdal Security Blog
NISL@THU
NISL@THU
V
Visual Studio Blog
The Last Watchdog
The Last Watchdog
Know Your Adversary
Know Your Adversary
Cisco Talos Blog
Cisco Talos Blog
P
Proofpoint News Feed
M
MIT News - Artificial intelligence
Stack Overflow Blog
Stack Overflow Blog
The Cloudflare Blog
小众软件
小众软件
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
S
Schneier on Security
雷峰网
雷峰网
B
Blog RSS Feed
美团技术团队
T
Threat Research - Cisco Blogs
Engineering at Meta
Engineering at Meta
Recent Announcements
Recent Announcements
N
Netflix TechBlog - Medium
月光博客
月光博客
S
Security Affairs

Mox的笔记库

2026PPoPP MLIR Tutorial学习 | Mox的笔记库 MacOS配置《明日方舟:终末地》 | Mox的笔记库 2025:向内生长 | Mox的笔记库 由mlir::ExecutionEngine引发的跨系统问题 | Mox的笔记库 WSL2配置Cuda-Tile环境记录(未完待续) | Mox的笔记库 Vibe Coding手搓项目记录 | Mox的笔记库 给Debian上包——以DuckDB为例 | Mox的笔记库 UCPD.sys事件存档 | Mox的笔记库 换新电脑之Mac mini M4从购买到配置 | Mox的笔记库 Mac配置MLX-C开发环境 | Mox的笔记库 RISC-V meets RDBMS——RISC-V架构上可运行数据库一览 | Mox的笔记库 DuckDB Sort实现调查 | Mox的笔记库 修复Redis在树莓派5上无法运行的问题 | Mox的笔记库 如何在MLIR中自定义类型并且输出运行 | Mox的笔记库 网站网络结构变更记录 | Mox的笔记库 EDBT25论文阅读:PhoebeDB——A Disk-Based RDBMS Kernel for High-Performance and Cost-Effective OLTP SIGMOD25论文阅读:BPF-DB:——A Kernel-Embedded Transactional Database Management System For eBPF Applications Apache Arrow Gandiva项目解析 | Mox的笔记库 VLDB24论文阅读:Cloud-Native Database Systems and Unikernels——Reimagining OS Abstractions for Modern Hardware NoisePage源码分析(未完待续) | Mox的笔记库 VLDB20论文阅读:Mainlining Databases——Supporting Fast Transactional Workloads on Universal Columnar Data File Formats VLDB17论文阅读:Relaxed Operator Fusion for In-Memory Databases:Making Compilation, Vectorization, and Prefetching Work Together At Last 论文阅读:How not to structure your database-backed web applications——a study of performance bugs in the wild SIGMOD24阅读:ROME——Robust Query Optimization via Parallel Multi-Plan Execution 文章阅读:First Past the Post-Evaluating Query Optimization in MongoDB SIGMOD文章阅读:Apache Calcite——A Foundational Framework for Optimized Query Processing Over Heterogeneous Data Sources SIGMOD22论文阅读:Efficient Massively Parallel Join Optimization for Large Queries VLDB论文阅读:Weaving Relations for Cache Performance VLDB22论文阅读:ConnectorX——Accelerating Data Loading From Databases to Dataframes 论文阅读:UniKraft-Fast, Specialized Unikernels the Easy Way 当DuckDB遇上RISC-V | Mox的笔记库 SIGMOD25论文阅读:An Elephant Under The Microscope——Analyzing The Interaction Of Optimizer Components In PostgreSQL 论文阅读:Compile-Time Analysis of Compiler Frameworks for Query Compilation VLDB23阅读:Bringing Compiling Databases to RISC Architectures SIGMOD24文章阅读:Query Compilation Without Regrets | Mox的笔记库 淦!MLIR输出Hello World不应该这么难! | Mox的笔记库 2024:拥挤年代的想象与创造 | Mox的笔记库 如何给自己的博客添加MLIR和LLVM IR语法高亮 | Mox的笔记库 博客重构:从Hexo到Astro | Mox的笔记库 VLDB19-Parsing Gigabytes of JSON per Second论文阅读 CIDR25:Runtime-Extensible Parsers阅读 | Mox的笔记库 SIGMOD24文章阅读:VeriTxn | Mox的笔记库 MLIR学习资料整理 | Mox的笔记库 VLDB23文章阅读——Exploiting Cloud Object Storage for High-Performance Analytics VLDB24——OLAP on Modern Chiplet-Based Processors走马观花阅读 如何让数据库中的Python跑的更快-VLDB22-YeSQL文章阅读 | Mox的笔记库 你好,世界! | Mox的笔记库 如何愉快的运行一个MLIR程序 | Mox的笔记库 让系统研究更有意义:HarmonyOS NEXT的教训和经验——讲座回顾 | Mox的笔记库 VLDB22:YeSQL文章阅读(已废弃) | Mox的笔记库 UNSW 24T3 COMP9336上课记录 | Mox的笔记库 Velox开发环境配置踩坑记录 | Mox的笔记库 LingoDB源码编译与分析 | Mox的笔记库 论文阅读:Declarative Sub-Operators for Universal Data Processing 论文阅读:Designing an Open Framework for Query Optimization and Compilation MLIR Toy Tutorial实践记录 | Mox的笔记库 2024年7月RSSHub开发体验 | Mox的笔记库 LLVM-Kaleidoscope实操踩坑记录 | Mox的笔记库 澳洲大学计算机硕士比较 | Mox的笔记库 论文阅读——CDUL:CLIP-Driven Unsupervised Learning for Multi-Label Image Classification CVPR2023-CLIP算法调研 | Mox的笔记库 论批量快速添加图片与视频水印的事 | Mox的笔记库 基于元信息写入的服务器压力测试 | Mox的笔记库 家庭组网IPv6+Mesh折腾 | Mox的笔记库 MjAyMw==,希望,前进与平庸之道 | Mox的笔记库 code-server初体验 | Mox的笔记库 从Nginx到Caddy | Mox的笔记库 RMM观察与初探 | Mox的笔记库 计算机网络课设——UDP/TCP/TLS Socket实验 | Mox的笔记库 JQuery的XSS初探 | Mox的笔记库 生产实习记录 | Mox的笔记库 Fedora-CoreOS配置与试用(2023年) | Mox的笔记库 Electron学习笔记 | Mox的笔记库 ServerSentEvent学习 | Mox的笔记库 报告翻译:容器云的安全挑战 | Mox的笔记库 Vagrant配置Metarget靶场环境 | Mox的笔记库 OpenAI-whisper折腾 | Mox的笔记库 202202,困惑,混乱与未曾设想之路 | Mox的笔记库 2022年Hack the box:Tier1免费区全解 | Mox的笔记库 Navidrome部署记录 | Mox的笔记库 长安杯2021-snake复现 | Mox的笔记库 报告概要翻译:OBFUSCATING C++ PROGRAMS VIA CONTROL FLOW FLATTENING 从零开始的Django CVE-2022-28346复现 | Mox的笔记库 2022CISCN(西北区赛)-The shinning | Mox的笔记库 Docker+QEMU+Arm64(Ubuntu)+环境配置(2022版) | Mox的笔记库 Arch Linux运行树莓派系统(2022年) | Mox的笔记库 2022CISCN初赛-ez_usb-复盘WriteUp | Mox的笔记库 Arch Linux迁移计划 | Mox的笔记库 Django事务使用 | Mox的笔记库 记录第一次EduSRC上报 | Mox的笔记库 Jetbrain问题应急处理 | Mox的笔记库 Celery5.2学习&配置 | Mox的笔记库 Waline部署记录 | Mox的笔记库 Frida hook初次实战 | Mox的笔记库 NodeMCU-MicroPython配置实录 | Mox的笔记库 Log4j2漏洞复现 | Mox的笔记库 2022长安“战疫”网络安全卫士守护赛回顾 | Mox的笔记库 2021年12月 Vivo千镜杯回顾 | Mox的笔记库 Windows的WSL2+Docker初探 | Mox的笔记库 Hexo部署安装全流程回顾 | Mox的笔记库
VLDB23论文阅读:Analyzing the Impact of Cardinality Estimation on Execution Plans in Microsoft SQL Server
MocusEZ · 2025-04-16 · via Mox的笔记库

这篇文章在CMU-15799的Lecture #14被提及,Andy提到微软的SQL Server拥有目前数据库中最好的Query Optimizer。而这篇来自微软研究人员的文章会介绍Query Optimize中最关键的一环:Cardinality Estimation

CMU提供的论文下载地址:https://15799.courses.cs.cmu.edu/spring2025/papers/14-cardinalities2/lee-vldb2023.pdf

INTRODUCTION

Cardinality estimation, the task of estimating the number of output rows for a SQL expression, is one of the challenging problems in query optimization

这里需要给不太了解Query Optimizer的人介绍下:数据库中的 Cardinality Estimation(基数估计) 是查询优化器的核心组成部分,它用于估计查询中各个中间结果(如某一列、某个连接条件、某个过滤条件等)返回的行数或值的数量,会直接影响到生成物理计划的质量

下面内容当中,会把Cardinality Estimaition简化为CE这个缩写

query optimizers on modern execution engines have the ability to use query execution techniques at runtime that can potentially mask (i.e., mitigate) the adverse impact of CE errors by reducing the latency of the plan obtained using estimated cardinalities.

“降低CE获得的计划的延迟来掩盖CE错误的不利影响” 即不应该过度追求生成计划的完美,而应该在生成计划的延迟与执行速度上达成平衡

To conduct our evaluation on the Microsoft SQL Server query optimizer, we needed to develop a new cardinality injection API, such that when the query optimizer requests the cardinality of a logical sub-expression of the query, we are able to inject a value that overrides the cardinality estimated by the optimizer’s built-in cardinality estimation model.

“cardinality injection API” 有意思,头一回听说这东西

1.1 Key Findings

这一块内容是将如何CE的优化是如何快的,相比一定是有提升的

image-20250415174953045

We find that bitmap filtering is more frequently used in columnstores than rowstores because they require Index Scan and Hash Join operators, which are more predominant in columnstores.

详见6.1

1.2 Open Questions

The choice of appropriate physical operators for aggregation and join is an important area where existing runtime execution techniques are unable to mask the impact of inaccurate CE.

没太明白,想说的是需要新的Physical Operator能面对CE错误更加有弹性?(那会是什么东西?)

MICROSOFT SQL SERVER QUERY OPTIMIZER

2.1 Overview

Microsoft SQL Server’s query optimizer uses the Cascades framework’s [27] extensible optimizer architecture.

Cascades也是今年CMU-15799讲的重点内容

The optimizer uses two kinds of rules: transformation rules that map one algebraic expression into another (i.e., logical expression → logical expression) and implementation rules that map an algebraic expression into an operator tree (i.e., logical expression → physical operator tree)

简要的阐述了下Cascades

Bitmap filtering: Microsoft SQL Server uses bitmaps to perform a semi-join reduction for plans containing Hash Join operators. This technique performs early filtering of rows that will not qualify a join …… Bitmap pushdown in Microsoft SQL Server are performed on operators in the final plan chosen by the optimizer.

哦?那听起来不错👍

Adaptive join: The Microsoft SQL Server optimizer can use the adaptive join operator [6], which enables the choice of Hash Join or Nested Loops join method to be deferred to runtime until after the first join input has been scanned

Adaptive join? Mark下,最近准备在做了

2.2 Physical design

In Microsoft SQL Server, indexes fall into one of two categories: rowstore and columnstore

Microsoft SQL Server既有列存,也有行存(但却不属于HTAP的范畴?应该是分开的两类)

RowStore使用B+树,ColumnStore则具备要压缩率

2.3 API for exact cardinality injection

We extend the Microsoft SQL Server query optimizer with two APIs (see Figure 2):

(1) cardinality injection, which allows a client to inject a cardinality value for a specific memogroup during optimization, thereby overriding the optimizer estimated cardinality, and

(2) SQL decoding, which enables a client to obtain a valid and logically equivalent SQL statement corresponding to a memogroup.

image-20250415182047151

Limitations of cardinality injection: There are some cardinalities used by the optimizer for which we are unable to inject cardinalities, and therefore the optimizer falls back to its default cardinality estimation logic in these cases.

并非所有都能Inject Cardinality,有些关于MemoGroup的操作就不行

EVALUATION SETUP AND METHODOLOGY

3.1 Workloads

(1) CE benchmarks: JOB [33], CEB [38], STATS [28]

(2) Industry benchmarks: TPC-DS, modified industry benchmarks DSB, TPC-H

  1. Real workloads: a suite of real queries over 6 different real databases. Both databases and queries were collected from customers of Microsoft SQL Server

• REAL1: Analyzes sales and inventory data for a US bookstore chain using dimensions of time, item, store, merchant etc.

• REAL2: Analyzes products and orders for an international cosmetic retailer.

• REAL3: Internal application that stores and queries the catalog of a source control system.

• REAL4: ERP application that analyzes retail invoices and sales by time, customer, point of sale etc.

• REAL5 and REAL6: Internal applications tracking agreements, customers and sales of products/services.

Andy好像在课上说过这些案例来源于微软的用户

image-20250415203125953

3.2 Methodology

Our evaluation varies the following dimensions:

(1) Cardinality: {Optimizer-Est, Exact}

(2) Physical Design: {Rowstore, Columnstore}. For rowstore, for real workloads, we retain the original physical design present in the database. For all other workloads, we create indexes recommended by Microsoft SQL Server Database Engine Tuning Advisor (DTA) tool. For columnstores, we create one clustered columnstore index on each table.

(3) For Parallelism, Bitmaps and Adaptive Join, we run with each feature turned On/Off. We run each query in isolation with a cold cache i.e., the buffer pool is reset prior to each execution using dbcc dropcleanbuffers

RESULTS: EXECUTION-TIME OPTIMIZATIONS TURNED OFF

In particular, we use serial plans only (i.e., disable multicore parallelism), and turn off bitmap filtering and adaptive join techniques.

这一章占据了文章的很大篇幅,在我看来像一种消融实验,检查各个Optimization的实际作用

实验将Physical Operator分为4类

(1) Seek operators, i.e., operators that access base tables using random I/O

(2) Scan operators, i.e. , operators that access base tables using sequential I/O

(3) Non-leaf operators (e.g., physical join operators, sort, hash aggregate, …)

(4) A catch-all category where none of the conditions (1)-(3) apply and the elapsed time improvement is spread across multiple leaf and/or non-leaf operators.

image-20250416112836591

但大多数是定量分析,反倒没什么值得说的😂想了解的可以看论文本体

Figure 3(a) shows for each workload the percentage of queries that improve (green bar) or regress (red bar) 2× or more when using exact cardinalities.

Figure 3(b) shows the improvement or regression in total elapsed time, i.e., sum of elapsed time over all queries in the workload. In 7 workloads we observe more than 40% improvement in total elapsed time,

image-20250416105258016

这里可能会有人对文中的“absolute time regression”感到疑惑,实际上就是性能退化的意思

Example 4.1. An example query of first category, JOB Q17a, with its before and after plans are shown in Figure 4. The expensive Index Seek operators in Porig which contributes most to its elapsed time are shown in color. In Pexact the Index Nested Loops Join with table “name” is replaced with a Merge Join with an Index Scan of the “name” table, and the number of seeks for the table “cast_info” are significantly reduced due to join order change.

image-20250416111002206

使用准确的CE后,原本和 name 表的 Index Nested Loop Join 被替换成了 Merge Join + Scan,从而提高了效率

image-20250416111559071

对于TPC-H Q3,提供准确的CE后,可以不查找lineitem表image-20250416111854784

而在实际测试场景中,提供准确的CE后,Non-leaf operators (Sort and StreamAgg)使用了更小的数据

image-20250416112146428

同理,提供准确CE后,Join Order也会调整为更为合理的顺序

The three major components of the query optimizer are cardinality estimation, cost model and search

啧,cardinality estimation, cost model and search,有意思

文中还提到了Cost Estimation对列存的影响

Figure 8(a) shows the percentage of queries for each workload with 2× or more improvement in elapsed time (green bar) and 2× or more regression in elapsed time (red bar).

image-20250416113722857

SENSITIVITY TO CARDINALITY ERRORS

这个章节主要是关于两个问题:

(1) How few memogroups can we inject with exact CE and still get to the same plan as injecting all memogroups with exact CE?

  1. How large CE errors can be tolerated by the optimizer without significantly affecting plan quality?

5.1 Essential set of memogroups

image-20250416115159742

对memogroup进行消融实验

The algorithm initializes the essential set to the set of all memogroups and then iteratively shrinks the set by attempting to remove a memogroup in each iteration.

这部分内容并没有明确答复,并不是所有 memogroup 都需要准确的基数估计,只有少量“关键 memogroups”真正决定了优化器是否能生成最优执行计划(Pexact)

5.2 Impact of varying CE error

The impact of varying q-error on plan quality is captured using box plots for each ε value in Figure 11. The outliers are shown as dots in the figure. The y-axis is the suboptimality ratio of the plan with respect to elapsed time of Pexact and x-axis is ε.

image-20250416115114672

同样,这一部分内容的结论也比较模糊,CE Arrow的影响还和计划执行的事件有关——可以理解为执行时间越短,CE error的影响就越小

EFFECT OF RUNTIME TECHNIQUES: BITMAP FILTERING AND ADAPTIVE JOIN

这里Bitmap Filter和Adaptive Join是微软团队提供的优化

(i) {Opt-Est cardinalities, Techniqueoff}

(ii) {Exact cardinality, Technique-off}

(iii) {Opt-Est cardinalities,Technique-on}

(iv) {Exact cardinality, Technique-on}

6.1 Bitmap filtering

image-20250416120940267

For this experiment, we use columnstores since bitmap filtering is used more extensively in columnstores when compared to rowstore.

原来如此,BitMap Filtering只在列存中用

从图中来看,效果还行?

6.2 Adaptive join

When using only exact cardinalities (see Figure 1(a)) 13% of the queries improve by 2× or more. In contrast, when using only adaptive join (see Figure 13(a)), we find only a few queries (less than 1%) that improve by 2× or more.

image-20250416121703847

We find several reasons why adaptive join is unable to mask the impact of inaccurate CE, e.g., change in join order, change in physical operator, aggregation push-down (as noted in Section 4.2).

Such changes that lead to plan improvements are not achievable using adaptive join alone.

似乎效果达不到预期?因为其无法改变 Join 顺序、物理算子、或开启聚合下推(aggregation pushdown)等更根本的计划结构——说白了还是需要准确的CE

6.3 Other techniques and combinations

其实也没别的,就是并行对于计划的影响

In our study, for many queries, the optimizer uses parallelism only after exact cardinality injection.

Query Optimize对于并行的优化一直是个难题

主要是关于数据集的介绍

the Join Order Benchmark (JOB) using hand-crafted queries over the IMDB database.

CEB [38] provides additional queries over the IMDB schema

STATS [28], uses a real-world dataset similar to JOB, a snapshot of Stats Stack Exchange data

评论

好像有通过神经网络进行Cardinality Estimate的方案(Andy说他会在后面的课提到,但Andy的课4月份后就停更了)

一开始提到有Adaptive Join,我还是蛮期待的(和我目前做的方向有关),但看到不能调换Join顺序时就没兴趣了——怎么说,Cardinality Estimate是很重要,你说这不是废话吧,但大家确实对此没有定量分析的认知。

同样,CMU-15799的Lecture #14也是围绕这篇论文展开,感兴趣的可以去看看

image-20250416123951191