Traditional Culture Encyclopedia - Traditional stories - What are the forms of database storage structure?

What are the forms of database storage structure?

The existence of database is very necessary for the operation of any software and the storage of website information. But not all storage methods can meet the demand, and we need to make adjustments according to different situations. The following IT training will understand the advantages and disadvantages of different database storage structures from the perspective of case analysis.

From the aspects of workload balance, consistency requirements, delay and access mode, the application is different. If we can make a clear decision on the architecture of the database and storage facilities, it will help us understand the reasons for the system behavior pattern, and once the problem is solved, we can tune the database according to the workload.

One of the main structural differences between B-tree and LSM-tree lies in the purpose and significance of optimization.

Let's compare B-tree and LSM-tree. In a word, B-tree has the following characteristics:

B-tree is variable, which supports in-place update by introducing some space overhead and more related write paths. B-tree does not need complete file rewriting or multi-source merging.

B-tree is read optimized. That is, there is no need to read B-trees from multiple sources (so there is no need for subsequent merging operations), which simplifies the reading path.

Writing may trigger cascading splitting of nodes, which will make some writing operations more expensive.

B-tree is optimized for paging (block storage) environment, where there are no byte addresses. They are optimizedforgedenvironments (block storage), which is impossible.

Although it needs rewriting, B-tree storage usually requires less maintenance than LSM-tree storage.

Concurrent access requires read/write isolation with a series of locks and latches.

LSM tree has the following characteristics:

LSM tree is not writable. SSTable is written to disk only once and never updated. Compact operations achieve spatial integration by removing entries from multiple data files and merging data with the same key. During compression, the merged table will be discarded and deleted after successful merging. Another useful feature provided by non-writeability is the concurrent access to refreshed tables.

LSM is write optimized. This means that writes will be cached and flushed to disk in order, which may support spatial locality on disk.

A read operation may require accessing data from multiple data sources. Because data with the same key written at different times may fall in different data files. Records must be merged before being returned to customers.

LSM trees need to be maintained and reduced, because cached writes will be flushed to disk.