Shared Memory Buffer Pool Processing Method, Storage Medium and Device of Database

By opening a fixed buffer pool in the database memory cache space and optimizing the page control structure of B-tree index, the overhead problem caused by concurrent update of B-tree index is solved and the overall performance of the database is improved.

CN114860723BActive Publication Date: 2025-07-18CETC JINCANG (BEIJING) TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210451345.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-26
Publication Date
2025-07-18
Estimated Expiration
2042-04-26

AI Technical Summary

Technical Problem

The overhead brought about by concurrent updates of the page control structure of B-tree index affects database performance.

Method used

By opening an independent fixed buffer pool in the memory cache space of the database, obtain the access status of the B-tree index and wait for the access to the end, move the fixed page from the fixed buffer pool to the normal buffer pool to avoid reference counter updates and optimize the moving in and out of node pages.

Benefits of technology

In high concurrency scenarios, the concurrent update overhead of the page control structure is reduced and the performance of database index query is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114860723B_ABST
    Figure CN114860723B_ABST
Patent Text Reader

Abstract

The present invention provides a method, a storage medium and a device for processing a shared memory buffer pool of a database. The method includes: obtaining an unfix instruction, where the unfix instruction is used to instruct a fixed buffer pool to release the fixed pages of a specified B-tree index, and the fixed buffer pool is a buffer pool that is pre-opened in the memory cache space of the database and is independent of the normal buffer pool; obtaining the access status of the B-tree index; waiting for all accesses to the B-tree index to end; setting the fixed buffer pool flag of the B-tree index to the unfixed state, and moving the fixed pages of the B-tree index from the fixed buffer pool to the normal buffer pool. The solution of the present invention can enable the pages of the unfixed B-tree index to participate in the replacement of the normal buffer pool normally, without affecting the normal access response of the database.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to database technology, and particularly to a method for processing a shared memory buffer pool of a B-tree index database, a storage medium, and a device. Background Art

[0002] The B-tree index is one of the most commonly used indexes in a database. It can support processing equality and range queries on sortable data and greatly increase the query speed using this index. The B-tree index makes the actions of finding data, sequential access, inserting data, and deleting data all achievable within logarithmic time by sorting the data and constructing a B-tree.

[0003] Generally speaking, a B-tree is a generalized self-balancing n-ary search tree. Different from a self-balancing binary search tree, the B-tree is optimized for the read and write operations of large chunks of data in the system. The B-tree reduces the intermediate processes experienced when locating a record, thereby increasing the access speed.

[0004] In a B-tree, an internal (non-leaf) node can have a variable number of child nodes, and the number range is predefined. When data is inserted or removed from a node, the number of its child nodes changes. To maintain within the preset number range, internal nodes may be merged or split. Because there is a certain allowable range for the number of child nodes, the B-tree does not need to rebalance as frequently as other self-balancing search trees. A B-tree maintains balance by constraining all leaf nodes to be at the same depth, and the depth of the entire tree will slowly increase during the process of adding data to the tree.

[0005] In addition, there are some variants of the original B-tree, such as B+ -tree and B* -tree, which can also be considered as schemes belonging to the B-tree category in a broad sense and are often used as database indexes.

[0006] The search structure for building an index by a B-tree can indeed greatly accelerate the speed of finding data in a database. The B-tree structure can ensure that the number of nodes read in the whole process is small enough and ensure that the I / O (input / output) overhead is very small. However, all search operations in a B-tree start from its root node and go to the nodes storing key values level by level, which means that the access operation to the root node may become a bottleneck of the system.

[0007] When the database accesses a page, it is necessary to update the page control structure, mainly the update of the reference counter. The reference counter records whether there are current references to the page and whether there have been recent references, and is used to judge buffer replacement. Generally speaking, this part of the overhead accounts for a relatively small proportion. However, with the increase in concurrency, the overhead caused by concurrent updates to the page control structure also rises sharply and becomes a non-negligible part. Therefore, for B-tree indexes, updating the control structure of root nodes or bottom-level node pages also incurs relatively large overhead. However, if these page control structures are not updated, other interferences will occur, such as affecting memory buffer replacement. Summary of the Invention

[0008] An object of the present invention is to provide a method to avoid the increase in overhead caused by concurrent updates of the page control structure of B-tree indexes.

[0009] A further object of the present invention is to improve the overall performance of the database.

[0010] In particular, the present invention provides a method for processing a shared memory buffer pool of a B-tree index database, the method comprising:

[0011] Obtaining an unfix instruction, the unfix instruction being used to instruct the fixed buffer pool to release the fixed page of the specified B-tree index, the fixed buffer pool being a buffer pool independently opened in the memory cache space of the database and independent of the ordinary buffer pool;

[0012] Obtaining the access status of the B-tree index;

[0013] Waiting for all accesses to the B-tree index to end;

[0014] Setting the fixed buffer pool flag of the B-tree index to the released state, and moving the fixed page of the B-tree index from the fixed buffer pool to the ordinary buffer pool.

[0015] Optionally, during the process of waiting for all accesses to the specified B-tree index to end, it further includes:

[0016] Applying for and holding an exclusive relation lock for the B-tree index;

[0017] Using the exclusive relation lock to suspend responding to new accesses to the specified B-tree index.

[0018] Optionally, after the step of moving the fixed page of the B-tree index from the fixed buffer pool to the ordinary buffer pool, it further includes:

[0019] Releasing the exclusive relation lock to resume responding to accesses to the specified B-tree index.

[0020] Optionally, after the step of resuming access to the specified B-tree index, it further includes:

[0021] Resume the update of the reference counter for the pinned page so that the pinned page participates in the buffer replacement of the normal buffer pool.

[0022] Optionally, after the step of obtaining the unpinned instruction, it further includes:

[0023] Search for the pinned page in the pinned buffer pool to determine whether the pinned page is stored in the pinned buffer pool;

[0024] If so, execute the step of obtaining the access status of the B-tree index.

[0025] Optionally, in the case where the pinned page is not stored in the pinned buffer pool, maintain the state of the pinned page participating in replacement in the normal buffer pool.

[0026] Optionally, after the step of moving the pinned page of the B-tree index from the pinned buffer pool to the normal buffer pool, it further includes:

[0027] Refresh the remaining space size of the pinned buffer pool for storing new pinned pages.

[0028] Optionally, before the step of obtaining the unpinned instruction, it further includes:

[0029] Obtain a buffer pool setting instruction;

[0030] Execute the process of moving the pinned node page of the specified B-tree index into the pinned buffer pool according to the buffer pool setting instruction.

[0031] According to another aspect of the present invention, there is also provided a machine-readable storage medium, on which a machine-executable program is stored, and when the machine-executable program is executed by a processor, it implements the shared memory buffer pool processing method of any one of the above B-tree index databases.

[0032] According to still another aspect of the present invention, there is also provided a computer device, including a memory, a processor, and a machine-executable program stored on the memory and running on the processor, and when the processor executes the machine-executable program, it implements the shared memory buffer pool processing method of any one of the above B-tree index databases.

[0033] The method for processing the shared memory buffer pool of the B-tree index database of the present invention fixes the node pages (generally the root node and the child nodes with a smaller depth) of the nodes to be fixed in the B-tree index in a fixed buffer pool independent of the ordinary buffer pool opened in the memory cache space. When the fixation of the B-tree index needs to be cancelled, after all accesses to the B-tree index before the cancellation of the fixation are completed, the fixed pages of the B-tree index are moved from the fixed buffer pool to the ordinary buffer pool. Thus, the access control structure (reference counter) of these pages can reflect the real number of accesses after the fixation is released, enabling the pages released from the fixation to participate in the replacement of the ordinary buffer pool normally and not affecting the normal access response of the database.

[0034] Furthermore, in the method for processing the shared memory buffer pool of the B-tree index database of the present invention, the node pages of the B-tree index are set through buffer pool setting instructions, achieving flexible configuration. When the database user makes correct settings, the overall performance of the database can be effectively improved.

[0035] Even further, in the method for processing the shared memory buffer pool of the B-tree index database of the present invention, the process of moving the node pages of the B-tree index into the fixed buffer pool is optimized. After the node pages are moved into the fixed buffer pool, these node pages no longer participate in the replacement of ordinary pages, thus avoiding the increase in overhead caused by the concurrent update of the page control structure of the B-tree index and achieving a significant improvement in the performance of database index queries in a high-concurrency scenario.

[0036] From the following detailed description of the specific embodiments of the present invention in conjunction with the accompanying drawings, those skilled in the art will become more clear about the above and other objects, advantages and features of the present invention. Description of the Drawings

[0037] Hereinafter, some specific embodiments of the present invention will be described in detail with reference to the accompanying drawings in an exemplary but not restrictive manner. The same reference numerals in the drawings denote the same or similar components or parts. Those skilled in the art should understand that these drawings are not necessarily drawn to scale. In the drawings:

[0038] Figure 1 is a schematic flowchart of the method for processing the shared memory buffer pool of the B-tree index database according to an embodiment of the present invention;

[0039] Figure 2 Schematic diagram of the database shared memory in the method for processing the shared memory buffer pool of the B-tree index database according to an embodiment of the present invention;

[0040] Figure 3 is a schematic flowchart of the process of fixing the node pages in the method for processing the shared memory buffer pool of the B-tree index database according to an embodiment of the present invention;

[0041] Figure 4 It is a schematic flowchart of the process of accessing pages in the fixed buffer pool by the shared memory buffer pool processing method of the B-tree index database according to an embodiment of the present invention;

[0042] Figure 5 It is a schematic flowchart of the process of releasing node pages by the shared memory buffer pool processing method of the B-tree index database according to an embodiment of the present invention;

[0043] Figure 6 It is a schematic diagram of a machine-readable storage medium according to an embodiment of the present invention; and

[0044] Figure 7 It is a schematic diagram of a computer device according to an embodiment of the present invention.. Detailed implementation manners

[0045] Figure 1 It is a schematic flowchart of the shared memory buffer pool processing method of the B-tree index database according to an embodiment of the present invention, Figure 2 A schematic diagram of the database shared memory in the shared memory buffer pool processing method of the B-tree index database according to an embodiment of the present invention. The processing method of the database shared memory buffer pool generally may include:

[0046] Step S102, obtaining an unfix instruction; the unfix instruction is used to instruct the fixed buffer pool to release the fixed page of the specified B-tree index. The fixed buffer pool is a buffer pool independently opened in the memory cache space of the database and is independent of the ordinary buffer pool. The pages stored in the fixed buffer pool do not participate in the normal replacement of the ordinary buffer pool, and there is no need to update the reference counter.

[0047] The unfix instruction can use SQL (Structured Query Language), and includes information such as the identification of the B-tree index that needs to be specified.

[0048] The above step S102 may include: parsing the unfix instruction; determining the specified B-tree index according to the B-tree index information in the parsing result. The root node of the specified B-tree index and the child nodes with a depth less than a set value (generally the bifurcated nodes with a depth of 2) are used as fixed nodes and are allowed to use the fixed buffer pool.

[0049] Step S104, obtaining the access status of the B-tree index; that is, determining whether there is a process accessing the B-tree index that needs to be unfixed before unfixing.

[0050] Step S106, waiting for all accesses to the B-tree index to end. During the waiting process, an exclusive relationship lock for holding the B-tree index can be applied; the exclusive relationship lock is used to suspend responding to new accesses to the specified B-tree index.

[0051] Step S108: Set the fixed buffer pool flag of the B-tree index to the released state, and move the fixed pages of the B-tree index from the fixed buffer pool to the normal buffer pool.

[0052] After step S108, the exclusive relation lock can also be released to resume responding to accesses to the specified B-tree index. Thereafter, the update of the reference counter for the fixed pages is resumed, enabling the fixed pages to participate in the buffer replacement of the normal buffer pool. Through the above steps, after the access control structure (reference counter) of these fixed pages is released from fixation, it reflects the actual number of accesses, enabling the pages released from fixation to participate normally in the replacement of the normal buffer pool without affecting the normal access response of the database.

[0053] Considering that there may be a situation where the node pages of the specified B-tree index have not been moved into the fixed buffer pool, after the step of obtaining the release instruction, it can also include: searching for fixed pages in the fixed buffer pool to determine whether the fixed pages are stored in the fixed buffer pool; if so, execute the step of obtaining the access status of the B-tree index. In the case where the fixed pages are not stored in the fixed buffer pool, it is only necessary to directly maintain the state of the fixed pages participating in the replacement in the normal buffer pool.

[0054] After the step of moving the fixed pages of the B-tree index from the fixed buffer pool to the normal buffer pool, the remaining space size of the fixed buffer pool can also be refreshed to store new fixed pages.

[0055] In the database of this embodiment, the buffer space of the shared memory is pre-allocated with a normal buffer pool and a fixed buffer pool. The normal buffer pool uses traditional buffer replacement algorithms for normal replacement of pages, such as using replacement algorithms like LRU (Least Recently Used), LFU (Least Frequently Used), OPT (OPTimal replacement), etc. The fixed buffer pool is used for buffering the pages specified by the database users. The fixed buffer pool and the normal buffer pool are independent of each other. After the node pages are moved into the fixed buffer pool, these node pages no longer participate in the normal page replacement, thus avoiding the increase in overhead caused by the concurrent update of the page control structure of the B-tree index and achieving a significant improvement in the performance of database index queries in a high-concurrency scenario.

[0056] The size of the fixed buffer pool can be configured through a configuration file and exists independently of the normal buffer pool. Before moving the node pages of the fixed nodes into the fixed buffer pool, they are first cached in the cache space of the shared memory of the database. That is, caching is completed using the normal cache pool to provide the caching service.

[0057] The fixed buffer pool in this embodiment is used to store the pages of the nodes to be fixed in the B-tree index. These pages are frequently accessed and their sizes are controllable, avoiding excessive consumption of the fixed buffer pool. Additionally, it can also prevent the overly large fixed buffer pool from unexpectedly occupying too much system memory, which is beneficial to the operation of the database. The nodes to be fixed can be those with a relatively small tree depth, such as the root node and the forking nodes at depth 2. These nodes are fixed in the buffer pool instead of fixing all pages. Since there is a strict upper limit on the number of child nodes of each node in the B-tree, the total size of these nodes is completely controllable and does not pose a risk of exhausting the fixed buffer pool.

[0058] The database can establish a mapping from the disk page number to the specific location in the buffer pool through a hash table. The specific location in the buffer pool includes the buffer pool it belongs to and the offset relative to the base address of the buffer pool. Then, the specific location of the page in the buffer pool can be determined by the base address of the buffer pool and the above offset.

[0059] Storage bits for recording the relevant status of the page can be set on the page header in the buffer pool. The information recorded can include whether the page exists in the fixed buffer pool, the reference counter, whether it can be replaced and cleared, etc.

[0060] On the disk where the database is arranged, data files 21, log files 22, and configuration files 23 can be stored. In the shared memory 10 of the database, a general buffer pool 11, a fixed buffer pool 12, and other shared memory can be allocated. As is well-known to those skilled in the art, the reading speed of the disk is significantly slower than that of the memory. In the database of this embodiment, a general buffer pool 11 and a fixed buffer pool 12 are allocated in the shared memory 10. The general buffer pool 11 can be used for normal caching of pages, and the fixed buffer pool 12 can, according to the settings of the database user, fix and cache the node pages of the nodes to be fixed in the specified B-tree index.

[0061] Before the step of obtaining the unfix instruction, a process of fixing the fixed node pages of the above B-tree index can also be included. The step of fixing the fixed node pages of the above B-tree index in the fixed buffer pool can be to obtain a buffer pool setting instruction; and execute a process of moving the fixed node pages of the specified B-tree index into the fixed buffer pool according to the buffer pool setting instruction.

[0062] The buffer pool setting instruction can also use SQL (Structured Query Language) and include information about the B-tree index to be specified, such as identification, etc.

[0063] The process of moving the fixed node pages of the specified B-tree index into the fixed buffer pool according to the buffer pool setting instruction may include: obtaining the buffer pool setting instruction; determining the specified B-tree index and the nodes to be fixed of the specified B-tree index according to the buffer pool setting instruction; setting the fixed buffer pool flag of the B-tree index to the fixed state; after receiving an access to the specified B-tree index, executing the process of moving the node pages of the nodes to be fixed into the fixed buffer pool, where the fixed buffer pool is a buffer pool that is pre-opened in the memory cache space of the database and is independent of the ordinary buffer pool.

[0064] Among them, determining the specified B-tree index and the nodes to be fixed of the specified B-tree index according to the buffer pool setting instruction may include parsing the buffer pool setting instruction; determining the specified B-tree index according to the B-tree index information in the parsing result; using the root node of the specified B-tree index and the child nodes with a depth less than the set value as the nodes to be fixed. That is, after obtaining the buffer pool setting instruction and parsing to determine the specified B-tree index, the root node of this B-tree index and the child nodes with a depth less than the set value (generally the bifurcation nodes with a depth of 2) are used as the nodes to be fixed.

[0065] Modify the fixed buffer pool flag of the B-tree index to the fixed state, that is, set the fixed buffer pool flag, so that it identifies that this B-tree index has been specified as the index that needs to be fixed. Thus, it can be determined whether this B-tree index is specified through the fixed buffer pool flag. The fixed buffer pool flag can be set to a flag bit. When it is set to 1, it means that this B-tree index is specified; when it is set to 0, it means that this B-tree index is not specified.

[0066] The process of moving the node pages of the nodes to be fixed into the fixed buffer pool may include: caching the node pages into the ordinary buffer pool; obtaining the remaining space size of the fixed buffer pool; determining whether the remaining space is sufficient to store the node pages; if so, moving the node pages into the fixed buffer pool.

[0067] In the case where the remaining space is not sufficient to store the node pages, the node pages can also be stored in the ordinary buffer pool, and the reference counter for the node pages is maintained and updated. That is, when the node pages are not stored in the fixed buffer pool, the ordinary buffer pool can be used to cache the node pages, and the node pages participate in the buffer replacement of the ordinary buffer pool.

[0068] After moving the fixed pages of other B-tree indexes from the fixed buffer pool to the ordinary buffer pool in the above step S108, refresh the remaining space size of the fixed buffer pool so that new fixed pages can be stored. That is to say, after the step of storing the node pages in the ordinary buffer pool, after an event of releasing the fixation occurs in the fixed buffer pool, the step of determining whether the remaining space is sufficient to store the node pages can be re-executed, and after the remaining space is sufficient to store the node pages, the node pages are moved into the fixed buffer pool.

[0069] After the step of moving the node page into the fixed buffer pool, it may further include: setting the fixed flag of the node page to the fixed state; stopping updating the reference counter of the node page. Since the reference counter of the node page in the fixed buffer pool does not need to be updated, the increase in overhead caused by the concurrent update of the page control structure of the B-tree index can be avoided.

[0070] The process of handling the access to the specified B-tree index after the step of executing the process of moving the node page of the node to be fixed into the fixed buffer pool may include: obtaining the access to the specified B-tree index, determining the access target page; judging whether the fixed flag of the access target page is in the fixed state; if so, ignoring the processing of the reference counter of the access target page and reading the access target page from the fixed buffer pool; if not, updating the reference counter of the access target page and reading the access target page from the normal buffer pool.

[0071] When using the method of the above embodiment, the database user can be allowed to specify a B-tree index to use the fixed buffer pool, and limit the fixed range to the high-frequency node pages of the B-tree index, such as including the root node (depth 1) and the fork nodes at depth 2. All pages within the fixed range, as well as subsequent extended pages that meet this range, are moved into the fixed buffer pool, unless the capacity of the fixed buffer pool is no longer sufficient to meet the storage requirements. The pages that cannot be moved into the fixed buffer pool due to insufficient storage capacity are still temporarily stored in the normal buffer pool. For the already fixed pages, stop updating their reference counters and ignore the replacement operation at the same time.

[0072] The process of releasing the fixed pages in the fixed buffer pool can be: obtaining the release fixed instruction; according to the release fixed instruction, the B-tree index to be released from fixation; executing the process of moving the B-tree index to be released from fixation out of the fixed buffer pool to free up the space of the fixed buffer pool.

[0073] In the method of this embodiment, the processing of the control structure (i.e., the reference counter) of the node page is particularly crucial. The process of releasing the fixation needs to ensure that the reference counter of the node page returns to the normal state. For the page to be fixed, each process that has accessed the page before fixing it must record whether the state of the page has been fixed at the time of reading. If it has been fixed, the accessing process must correctly update the reference counter; otherwise, reference count leakage will occur. Secondly, for the page to be released from fixation, the processes that have accessed the page before releasing the fixation must ensure that they have ended correctly before the release. Coarse-grained locks (exclusive relationship locks) can be used to ensure this, that is, the session for releasing the fixation will wait for all current accessing processes to finish accessing through the exclusive-mode relationship lock before starting to execute the release process. In this way, after the page is released from fixation, the reference counter of the page will also be equal to the actual number of accesses at that moment, so that it can participate in replacement normally.

[0074] Figure 3 FIG. is a schematic diagram of the process of fixing a node page according to the method for processing a shared memory buffer pool of a B-tree index database according to an embodiment of the present invention. The process of fixing a node page of a B-tree index may include:

[0075] Step S302, obtain a buffer pool setting instruction input by a database user, where the buffer pool setting instruction is used to specify a fixed buffer pool for a B-tree index of the database;

[0076] Step S304, the database parses the buffer pool setting instruction to determine the B-tree index to be specified;

[0077] Step S306, determine the root node of the specified B-tree index and the nodes at a set depth (generally the depth is 2);

[0078] Step S308, open the specified B-tree index and set its fixed buffer pool flag to the fixed state;

[0079] Step S310, obtain access to the database and determine whether this access is the first access after the above B-tree index is specified;

[0080] Step S312, read the node page to be fixed of the B-tree index into the ordinary buffer pool in the shared memory; by executing steps S314 to S318, attempt to fix the node page to be fixed into the fixed buffer pool;

[0081] Step S314, determine whether the remaining space in the fixed buffer pool is sufficient to store the node page. If not, save the node page to be fixed in the ordinary buffer pool;

[0082] Step S316, if there is remaining space, move the above node page into the fixed buffer pool;

[0083] Step S318, set the fixed flag to the fixed state and stop updating the reference counter of the node page.

[0084] Through the above steps, database users can assign a higher memory buffer stickiness to the pages with a smaller size and higher access frequency in the database B-tree index, avoiding the increase in overhead caused by the concurrent update of the page control structure of the B-tree index, and achieving a significant improvement in the performance of database index queries in a high-concurrency scenario.

[0085] Figure 4 It is a schematic diagram of the process of accessing pages in the fixed buffer pool according to the method for processing the shared memory buffer pool of the B-tree index database according to an embodiment of the present invention. The access process may include:

[0086] Step S402, obtain the access to the specified B-tree index and determine the access target page;

[0087] Step S404, determine whether the fixed flag of the access target page is in the fixed state;

[0088] Step S406, when the fixed flag of the access target page is in the fixed state, ignore the processing of the reference counter of the access target page;

[0089] Step S408, read the access target page from the fixed buffer pool and perform the access response operation;

[0090] Step S410, when the fixed flag of the access target page is in the unfixed state, read the access target page from the normal buffer pool and perform the access response operation; update the reference counter of the access target page and accumulate the number of times;

[0091] Step S412, after the access to the access target page ends, if the fixed flag of the access target page is still in the unfixed state, update the reference counter of the access target page and decrement the number of times by one.

[0092] Figure 5 It is a schematic diagram of the process of releasing the fixation of node pages according to the method for processing the shared memory buffer pool of the B-tree index database according to an embodiment of the present invention. The process of releasing the fixation of the node pages of the B-tree index stored in a fixed buffer pool may include:

[0093] Step S502, obtain the release fixation instruction, which is used to instruct the fixed buffer pool to release the fixed page of the specified B-tree index;

[0094] Step S504, the database parses the release fixation instruction and determines the B-tree index for which the fixation needs to be cancelled;

[0095] Step S506: Search for fixed pages in the fixed buffer pool to determine whether the fixed pages have been stored in the fixed buffer pool. For example, determine whether the fixed pages have been stored in the fixed buffer pool through the fixed flag of the node pages. If the fixed flag is in the fixed state, the fixed pages have been stored in the fixed buffer pool. If the fixed flag is in the non-fixed state, the fixed pages are still stored in the normal buffer pool.

[0096] Step S508: When determining whether the fixed pages have been stored in the fixed buffer pool, determine whether there is an access process accessing the B-tree index.

[0097] Step S510: If there is an access, apply for and hold an exclusive relationship lock for the B-tree index.

[0098] Step S510: Use the exclusive relationship lock to suspend new access to the specified B-tree index and wait for all accesses to end.

[0099] Step S512: Set the fixed buffer pool flag of the B-tree index to the released state.

[0100] Step S514: Move the fixed pages of the B-tree index from the fixed buffer pool to the normal buffer pool and set the fixed flag to the non-fixed state.

[0101] Step S516: Release the exclusive relationship lock to resume access to the specified B-tree index.

[0102] Step S518: Resume updating the reference counter of the fixed pages so that the fixed pages participate in the buffer replacement of the normal buffer pool.

[0103] Step S520: When the fixed pages are not stored in the fixed buffer pool, directly set the fixed buffer pool flag of the B-tree index to the released state and then end the process of releasing the fixity.

[0104] This embodiment also provides a machine-readable storage medium and a computer device. Figure 6 It is a schematic diagram of a machine-readable storage medium 40 according to an embodiment of the present invention. Figure 7 It is a schematic diagram of a computer device 50 according to an embodiment of the present invention.

[0105] The machine-readable storage medium 40 stores a machine-executable program 41 thereon. When the machine-executable program 41 is executed by a processor, it implements the method for processing the shared memory buffer pool of the B-tree index database in any of the above embodiments.

[0106] The computer device 50 may include a memory 520, a processor 510, and a machine-executable program 41 stored on the memory 520 and running on the processor 510. When the processor 510 executes the machine-executable program 41, it implements the shared memory buffer pool processing method of the B-tree index database in any of the above embodiments.

[0107] It should be noted that the logic and / or steps represented in the flowchart or described in other ways herein, for example, can be considered as a definite sequence list of executable instructions for implementing logical functions, and can be specifically implemented in any machine-readable storage medium for use by an instruction execution system, apparatus, or device (such as a computer-based system, a system including a processor, or other systems that can fetch and execute instructions from the instruction execution system, apparatus, or device), or in combination with these instruction execution systems, apparatus, or devices.

[0108] For the description of this embodiment, the machine-readable storage medium 40 can be any device that can contain, store, communicate, propagate, or transmit a program for use by an instruction execution system, apparatus, or device or in combination with these instruction execution systems, apparatus, or devices. More specific examples (non-exhaustive list) of computer-readable media include the following: an electrical connection part with one or more wirings (electronic device), a portable computer disk cartridge (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disc read-only memory (CDROM). Additionally, the computer-readable medium 40 can even be paper or other suitable media on which the program can be printed, because the program can be obtained electronically, for example, by optically scanning the paper or other media, then editing, interpreting, or processing it in other suitable ways as necessary, and then storing it in a computer memory.

[0109] It should be understood that various parts of the present invention can be implemented by hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system.

[0110] The computer device 50 can be, for example, a server, a desktop computer, a laptop computer, a tablet computer, or a smart phone. In some examples, the computer device 50 can be a cloud computing node. The computer device 50 can be described in the general context of computer system executable instructions, such as program modules, executed by a computer system. Generally, program modules can include routines, programs, object programs, components, logic, data structures, etc. that perform particular tasks or implement particular abstract data types. The computer device 50 can be implemented in a distributed cloud computing environment where tasks are performed by remote processing devices linked through a communication network. In a distributed cloud computing environment, program modules can be located on local or remote computing system storage media including storage devices.

[0111] The computer device 50 can include a processor 510 adapted to execute stored instructions and a memory 520 that provides temporary storage space for the operation of the instructions during operation. The processor 510 can be a single-core processor, a multi-core processor, a computing cluster, or any number of other configurations. The memory 520 can include random access memory (RAM), read-only memory, flash memory, or any other suitable storage system.

[0112] The processor 510 can be connected through a system interconnect (such as PCI, PCI-Express, etc.) to an I / O interface (input / output interface) adapted to connect the computer device 50 to one or more I / O devices (input / output devices). The I / O devices can include, for example, a keyboard and a pointing device, where the pointing device can include a touchpad or a touch screen, etc. The I / O devices can be built-in components of the computer device 50 or can be devices externally connected to the computing device.

[0113] The processor 510 can also be linked through a system interconnect to a display interface adapted to connect the computer device 50 to a display device. The display device can include a display screen as a built-in component of the computer device 50. The display device can also include a computer monitor, a television, a projector, etc. externally connected to the computer device 50. In addition, a network interface controller (NIC) can be adapted to connect the computer device 50 to a network through a system interconnect. In some embodiments, the NIC can use any suitable interface or protocol (such as Internet Small Computer System Interface, etc.) to transmit data. The network can be a cellular network, a radio network, a wide area network (WAN), a local area network (LAN), or the Internet, etc. Remote devices can be connected to the computing device through the network.

[0114] The flowcharts provided in this embodiment are not intended to indicate that the operations of the method will be executed in any specific order, or that all operations of the method are included in every case. In addition, the method may include additional operations. Within the scope of the technical concept provided by the method of this embodiment, additional changes can be made to the above method.

[0115] The solution of this embodiment uses the fixed buffer pool technology to avoid updating the reference counter, thereby reducing the overhead of concurrent conflict detection; by selecting an appropriate range of pages using the fixed buffer pool, the impact of the fixed buffer pool on the memory capacity is reduced. The process of releasing the fixed buffer pool enables the pages that have lost the reference counter to return to normal after the ability is released. On the one hand, the access when entering the fixed state is processed through the internal state record of the referencer; on the other hand, the exit from the fixed state is processed through a coarse-grained lock (exclusive relationship lock).

[0116] After testing the solution of this embodiment, in the case of ultra-high concurrency, the performance of accessing and searching the same B-tree index has been greatly improved. Since B-tree indexes are usually widely used in databases and most services have hot index queries, the solution of this embodiment can achieve obvious performance improvement for most actual services or mainstream benchmark tests (such as TPCC).

[0117] At this point, those skilled in the art should recognize that although multiple exemplary embodiments of the present invention have been shown and described in detail herein, many other variations or modifications that conform to the principles of the present invention can still be directly determined or derived from the content disclosed in the present invention without departing from the spirit and scope of the present invention. Therefore, the scope of the present invention should be understood and determined to cover all these other variations or modifications.

Claims

1. A method for processing a shared memory buffer pool of a B-tree index database, comprising: Obtaining an unfix instruction, which is used to instruct a fixed buffer pool to release a fixed page of a specified B-tree index, and the fixed buffer pool is a buffer pool that is pre-opened in the memory cache space of the database and is independent of a normal buffer pool; Obtaining the access status of the B-tree index; Waiting for all accesses to the B-tree index to end; Setting the fixed buffer pool flag of the B-tree index to the unfixed state, and moving the fixed page of the B-tree index from the fixed buffer pool to the normal buffer pool; Before the step of obtaining the unfix instruction, it further includes: obtaining a buffer pool setting instruction; executing a process of moving the fixed node page of the specified B-tree index into the fixed buffer pool according to the buffer pool setting instruction; after the fixed node page is moved into the fixed buffer pool, setting the fixed flag of the fixed node page to the fixed state, and stopping updating the reference counter of the fixed node page.

2. The method for processing a shared memory buffer pool of a B-tree index database according to claim 1, wherein, During the process of waiting for all accesses to the specified B-tree index to end, it further includes: Applying for an exclusive relationship lock for holding the B-tree index; Using the exclusive relationship lock to suspend responding to new accesses to the specified B-tree index.

3. The method for processing the shared memory buffer pool of the B-tree index database according to claim 2, wherein, After the step of moving the fixed page of the B-tree index from the fixed buffer pool to the normal buffer pool, it further includes: Releasing the exclusive relationship lock to resume responding to accesses to the specified B-tree index.

4. The method for processing a shared memory buffer pool of a B-tree index database according to claim 3, wherein, After the step of resuming access to the specified B-tree index, it further includes: Resuming the update of the reference counter of the fixed page, so that the fixed page participates in the buffer replacement of the normal buffer pool.

5. The shared memory buffer pool processing method of the B-tree index database according to claim 1, wherein, After the step of obtaining the unfix instruction, it further includes: Searching for the fixed page in the fixed buffer pool to determine whether the fixed page is stored in the fixed buffer pool; If so, execute the step of obtaining the access status of the B-tree index.

6. The method for processing a shared memory buffer pool of a B-tree index database according to claim 1, wherein, In the case where the fixed page is not stored in the fixed buffer pool, keep the state of the fixed page participating in replacement in the normal buffer pool.

7. The method for processing a shared memory buffer pool of a B-tree index database according to claim 1, wherein, After the step of moving the fixed page of the B-tree index from the fixed buffer pool to the normal buffer pool, it further includes: Refreshing the remaining space size of the fixed buffer pool for storing new fixed pages.

8. A machine-readable storage medium, on which a machine-executable program is stored, and when the machine-executable program is executed by a processor, it implements the method for processing a shared memory buffer pool of a B-tree index database according to any one of claims 1 to 7.

9. A computer device, including a memory, a processor, and a machine-executable program stored on the memory and running on the processor, and when the processor executes the machine-executable program, it implements the method for processing a shared memory buffer pool of a B-tree index database according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Data access method and device, equipment and storage medium

    CN110489425A