简体   繁体   English

RDBMS B +树索引如何用于选择查询

[英]How RDBMS B+ Tree Indexing works for Select Query

I learnt that B+ Trees are used for implementing RDBMS , and Now i want to implement an RDBMS in C/C++ , i've read about B+ Trees and also saw the SQLite. 我了解到B +树用于实现RDBMS,现在我想在C / C ++中实现RDBMS,我已经了解了B +树,还看到了SQLite。

I have a conceptual doubt of how the Search Query works on Database, we store (key,values) on the B+ Tree ,Now say i had a table 我对搜索查询在数据库上的工作方式有概念上的疑问,我们将(键,值)存储在B +树上,现在说我有一张桌子

with columns {id,name,phone,address} 与列{id,name,phone,address}

and i have to search for the record with phone = 'xyz' , how will database use B+ Trees to efficiently get that record. 我必须用phone ='xyz'搜索记录,数据库将如何使用B +树有效地获取该记录。

Is it complete O(N) search on the records or optimized? 它是对记录的完整O(N)搜索还是已优化?

It is a complete O ( N ) search if you do not have an index. 如果您没有索引, 是完整的ON )搜索
It is optimized if you have an index. 如果您有索引,它将进行优化

Average case O(logb(n)) 平均情况O(logb(n))

Worst Cast O(n) 最差的演员O(n)

A B+ tree is a blanced tree , it works more like binary search tree specially in MYSQL . B +树是一个盲目的树,它的工作方式更类似于MYSQL中的二进制搜索树。 its implementation can be varied. 它的实现可以变化。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM