Distinguish B-tree and B + tree in SQLite-index and storage

Source: Internet
Author: User

When reading some posts online. Someone found that the mechanism for organizing and managing database file storage in Sqlite is B-tree.

I think this is not rigorous.

So I turned out the definitive guide to sqlite SECOND EDITON. After review, I would like to summarize it here.

In Sqlite, the origins of B-and B + trees are different, in other words. It is the difference between the indexing mechanism and the file storage mechanism in the embedded database SQLite.

1. Index

Let's say a few more words about the index. We can cut the tree and push it by hand, but we can use an ax to quickly reverse the trunk.

Search operations (Update, delete, and insert all use search operations) are like tree cutting. indexes are our axes.

First of all, it is easy to use. This accelerates the retrieval speed. At the same time, like an ax. It is not intended for white use. I bought an ax. It is borrowed and owed a favor. In short, it is costly to use indexes (axes) to retrieve data (to read books.

Yes, this is required. Place the ax at home. Indexes also occupy memory. And if it is not a memory database, the index will occupy the external storage.

The ax cost money. In addition to the search operation, indexes do not need to be updated, deleted, or inserted. This is the overhead of auxiliary tools.

We must be clear. Indexes, like tables, arrays, and variables, lie on our hard disk or in memory.

To put it bluntly, he is a data structure (in fact, the word "Data Structure" is abstract, what do you think ?). In short, we can directly control the memory occupied by the program.

He can clearly lie in front of us. Don't bother me. These are the essence of indexes.

As mentioned above, indexes and data structures are very close. Okay. We have two typical index data structures: 1. Hash, which is calculated using numerical values through a feature called a hash function, you can quickly find the location of the target record in the hash table, and then quickly find it based on the information in the hash table location. Static and Dynamic Hashing are also divided. For their knowledge points, Baidu and Google.

2: As the data volume increases, the tree can adjust itself. It can hold a lot of data. Comparison is used to quickly locate the problem. The number of comparisons is often closely related to the depth of the tree. Generally, the time complexity of a pair of numbers. Generally, there is a typical number of B (also known as B-tree, not a tree called B minus tree or B-bar tree), B + tree, AVL tree, red/black tree (RBTree ).

About their knowledge, Baidu, Google ..

2. Storage

Let me make it simple.

Small memory, large memory. What should I do if the database file is large and the memory cannot be installed? The solution is simple. First install a part, first make it.

Very familiar.

Is there any wood in the operating system? (Dynamic or static) What is the webpage management mechanism? Is there a page disconnection problem?

Here is a concept "Page (pager )". This is what sqlite says. A database file is consecutively divided into X pages and a page number is given. It is "Block" and "block number ".

If you are not familiar with this, check the relevant information.

3. Application of B and B + trees in SQLite.

It is a section from the beginning of the article.

  • 1
  • 2
  • Next Page

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.