数据库索引为什么能加快查询?
Why do database indexes speed up queries?
索引通常用 B+ 树组织,把无序的全表扫描变成树上有序查找,复杂度从 O(n) 降到 O(log n),并把相邻数据聚簇在磁盘页上以减少 IO。
Indexes usually use B+ trees, turning a full scan into an ordered tree search from O(n) to O(log n), and cluster adjacent rows on disk pages to reduce IO.
难度 专业 · 适合 大众
CC BY 4.0 · 来源待核验 · Source pending review
来源 · Source
出处备注:此条未指向带版次的可引用著作(通识性内容、机构文件或未展开的英文书名),本库不提供独立书目出处;如需精确引用,需由编辑补全具体篇目与版次。
Database System Concepts
Database System Concepts
#数据库 #索引
MVCC 多版本并发控制是怎么实现“快照隔离”的?
How does MVCC implement snapshot isolation?
MVCC 给每行数据保留多个版本,并打上事务可见性标记(如事务 ID、时间戳)。一个事务启动时看到的是那一刻的一致性快照,读不阻塞写、写不阻塞读,从而在高并发下既保证隔离又减少锁争用。
MVCC keeps several versions of each row tagged with visibility info (transaction IDs, timestamps). A transaction sees a consistent snapshot from its start; reads don't block writes and vice versa, giving isolation with less locking under concurrency.
难度 专业 · 适合 大众
CC BY 4.0 · 已核验 · Verified 2026-08-23 · 2 条独立证据
来源 · Source
Silberschatz 等,《Database System Concepts》第7版,McGraw-Hill,2019
A. Silberschatz et al., Database System Concepts, 7th ed., McGraw-Hill, 2019
独立核验依据 · Independent verification: 核验依据 2 OPENLIBRARY 标识 /works/OL21198749W:Database System Concep
#MVCC #并发
B+ 树索引为什么特别适合放在磁盘上?
Why is a B+ tree index especially suited to disks?
B+ 树是矮胖的多路平衡树,一个节点存很多键、高度很低,每次查找只需很少次磁盘 I/O;且所有数据都放在叶子节点并用链表串起来,范围扫描非常高效,正好契合磁盘按块读写的特性。
A B+ tree is a short, fat balanced multi-way tree: each node holds many keys, so lookups need few disk I/Os; all data sits in leaf nodes linked in a list, making range scans efficient—ideal for block-oriented disks.
难度 专业 · 适合 大众
CC BY 4.0 · 已核验 · Verified 2026-08-23 · 2 条独立证据
来源 · Source
Silberschatz 等,《Database System Concepts》第7版,McGraw-Hill,2019
A. Silberschatz et al., Database System Concepts, 7th ed., McGraw-Hill, 2019
独立核验依据 · Independent verification: 核验依据 2 OPENLIBRARY 标识 /works/OL21198749W:Database System Concep
#B+树 #索引
数据库范式是用来解决什么问题的?
What problem do database normal forms solve?
范式通过拆分表消除数据冗余与更新异常(插入、删除、修改异常),例如第三范式要求非主属性不传递依赖于主键;过度范式化可能增加联表开销。
Normal forms split tables to remove redundancy and update anomalies (insert/delete/modify), e.g. 3NF requires non-key attributes depend only on the key; over-normalizing can add join cost.
难度 专业 · 适合 小学高段(9-12)
CC BY 4.0 · 已核验 · Verified 2026-08-23 · 2 条独立证据
来源 · Source
Silberschatz 等,《Database System Concepts》第7版,McGraw-Hill,2019
A. Silberschatz et al., Database System Concepts, 7th ed., McGraw-Hill, 2019
独立核验依据 · Independent verification: 核验依据 2 OPENLIBRARY 标识 /works/OL21198749W:Database System Concep
#数据库 #设计
CAP 定理说明了什么权衡?
What trade-off does the CAP theorem describe?
CAP 指出分布式系统在网络分区(P)发生时,只能在一致性(C)和可用性(A)之间二选一;实际系统通常保 P,并在 CP 与 AP 间依业务取舍。
CAP says that during a network partition (P) a distributed system must choose between consistency (C) and availability (A); real systems keep P and trade C vs A by needs.
难度 专业 · 适合 高中(15-18)
CC BY 4.0 · 来源待核验 · Source pending review
来源 · Source
出处备注:此条未指向带版次的可引用著作(通识性内容、机构文件或未展开的英文书名),本库不提供独立书目出处;如需精确引用,需由编辑补全具体篇目与版次。
Brewer 2000
Brewer 2000
#数据库 #理论
查询优化器的“代价模型”是干什么的?
What does a query optimizer's cost model do?
面对同一条查询,数据库有很多种执行方式(如先连接还是先过滤)。代价模型根据表大小、索引、统计信息估算每种计划的 I/O 与 CPU 开销,挑出估算最便宜的一条去执行。
One query can be executed many ways (join order, filter first, etc.). The cost model uses table sizes, indexes and statistics to estimate each plan's I/O and CPU cost, then picks the cheapest estimated plan.
难度 进阶 · 适合 初中(12-15)
CC BY 4.0 · 已核验 · Verified 2026-08-23 · 2 条独立证据
来源 · Source
Silberschatz 等,《Database System Concepts》第7版,McGraw-Hill,2019
A. Silberschatz et al., Database System Concepts, 7th ed., McGraw-Hill, 2019
独立核验依据 · Independent verification: 核验依据 2 OPENLIBRARY 标识 /works/OL21198749W:Database System Concep
#优化器 #代价
乐观锁和悲观锁有什么区别?
What is the difference between optimistic and pessimistic locking?
悲观锁假设冲突频发,提前加锁(如 SELECT FOR UPDATE)阻塞他人;乐观锁假设冲突少,提交时校验版本号或时间戳,冲突则重试,适合读多写少、并发高的场景。
Pessimistic locking assumes frequent conflicts and locks early (e.g. SELECT FOR UPDATE); optimistic locking assumes rare conflicts and checks a version/timestamp at commit, retrying on conflict—good for read-heavy, high-concurrency cases.
难度 进阶 · 适合 初中(12-15)
CC BY 4.0 · 来源待核验 · Source pending review
来源 · Source
出处备注:此条未指向带版次的可引用著作(通识性内容、机构文件或未展开的英文书名),本库不提供独立书目出处;如需精确引用,需由编辑补全具体篇目与版次。
Database System Concepts
Database System Concepts
#并发 #锁
数据库死锁是怎么产生的?
How does a database deadlock occur?
当两个事务各自持有对方需要的锁并互相等待时形成循环等待,数据库通常用超时或等待图检测并回滚其中一个事务来解除。
A deadlock occurs when two transactions each hold a lock the other needs and wait on each other; databases detect it via timeout or wait-for graphs and roll back one transaction.
难度 进阶 · 适合 大众
CC BY 4.0 · 来源待核验 · Source pending review
来源 · Source
出处备注:此条未指向带版次的可引用著作(通识性内容、机构文件或未展开的英文书名),本库不提供独立书目出处;如需精确引用,需由编辑补全具体篇目与版次。
Database System Concepts
Database System Concepts
#并发 #死锁
数据库主从复制有什么作用?
What is the purpose of database master-slave replication?
主库处理写操作并把变更日志异步或半同步地复制到从库,从库承担读请求实现读写分离与水平扩展,并作为备份与故障切换节点提升可用性。
The master handles writes and ships change logs to replicas, which serve reads for read/write splitting and scale-out, and also act as backups and failover nodes for availability.
难度 进阶 · 适合 高中(15-18)
CC BY 4.0 · 已核验 · Verified 2026-08-23 · 2 条独立证据
来源 · Source
Silberschatz 等,《Database System Concepts》第7版,McGraw-Hill,2019
A. Silberschatz et al., Database System Concepts, 7th ed., McGraw-Hill, 2019
独立核验依据 · Independent verification: 核验依据 2 OPENLIBRARY 标识 /works/OL21198749W:Database System Concep
#数据库 #复制
视图和物化视图有什么区别?
What is the difference between a view and a materialized view?
普通视图是保存的查询,每次访问实时计算,不占存储;物化视图把结果实际存成表,查询快但需刷新以保持与基表同步,适合昂贵的聚合报表。
A normal view is a stored query computed live with no storage; a materialized view physically stores results for fast reads but must be refreshed to stay in sync, suiting expensive aggregates.
难度 进阶 · 适合 大众
CC BY 4.0 · 来源待核验 · Source pending review
来源 · Source
出处备注:此条未指向带版次的可引用著作(通识性内容、机构文件或未展开的英文书名),本库不提供独立书目出处;如需精确引用,需由编辑补全具体篇目与版次。
PostgreSQL 文档
PostgreSQL Docs
#数据库 #视图
预写日志(WAL)为什么能让数据库崩溃后恢复?
Why does write-ahead logging (WAL) let a database recover after a crash?
WAL 规定任何修改都要先按顺序写进日志、再改内存页。崩溃重启时,数据库重放(redo)已提交但未落盘的日志、撤销(undo)未提交的日志,从而回到一致状态,保证“要么全做、要么不做”。
WAL requires every change to be logged before the page is modified. After a crash, the DB replays (redo) committed-but-unsaved log entries and undoes uncommitted ones, restoring consistency and the all-or-nothing guarantee.
难度 进阶 · 适合 初中(12-15)
CC BY 4.0 · 已核验 · Verified 2026-08-23 · 2 条独立证据
来源 · Source
Silberschatz 等,《Database System Concepts》第7版,McGraw-Hill,2019
A. Silberschatz et al., Database System Concepts, 7th ed., McGraw-Hill, 2019
独立核验依据 · Independent verification: 核验依据 2 OPENLIBRARY 标识 /works/OL21198749W:Database System Concep
#WAL #恢复
NoSQL 和关系型数据库该如何选择?
How to choose between NoSQL and relational databases?
关系库强一致、支持复杂事务与联表,适合结构化强、一致性要求高的场景;NoSQL(文档/键值/列族/图)以灵活 schema 和高可扩展性见长,适合海量、结构多变或低延迟的场景,常牺牲强一致换可用性。
Relational DBs give strong consistency, transactions and joins for structured, consistency-critical data; NoSQL (document/key-value/column/graph) offers flexible schema and scale, trading strong consistency for availability.
难度 入门 · 适合 初中(12-15)
CC BY 4.0 · 来源待核验 · Source pending review
来源 · Source
出处备注:此条未指向带版次的可引用著作(通识性内容、机构文件或未展开的英文书名),本库不提供独立书目出处;如需精确引用,需由编辑补全具体篇目与版次。
MongoDB 白皮书
MongoDB whitepaper
#数据库 #选型
数据库的“索引”是不是就像书的目录?
Is a database index like a book's table of contents?
很像!目录告诉你“某主题在第几页”,索引告诉数据库“某条数据在哪个位置”,这样不用一页页翻就能直接跳过去找到,速度快很多。
Very much! A contents page tells you 'this topic is on page X'; an index tells the database 'this record is at position Y', so it jumps straight there instead of flipping through everything.
难度 入门 · 适合 幼儿(3-6)
CC BY 4.0 · 已核验 · Verified 2026-08-23 · 2 条独立证据
来源 · Source
Silberschatz 等,《Database System Concepts》第7版,McGraw-Hill,2019
A. Silberschatz et al., Database System Concepts, 7th ed., McGraw-Hill, 2019
独立核验依据 · Independent verification: 核验依据 2 OPENLIBRARY 标识 /works/OL21198749W:Database System Concep
#索引 #数据库