Distributed database local temporary table management method, device, equipment and medium

By setting up a memory cache layer and localized metadata management in the distributed database, the problem of frequent network communication and delay in temporary table metadata management under the storage-computing separation architecture is solved, the system scalability and performance are improved, and data consistency is ensured. .

CN118519998BActive Publication Date: 2024-10-22BEIJING SIWEIZONGHENG DATA TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202410977580.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-22
Publication Date
2024-10-22
Estimated Expiration
2044-07-22

AI Technical Summary

Technical Problem

Under the storage-computing separation architecture, the metadata management of temporary tables suffers from frequent network communication, access delays and consistency problems, resulting in limited system scalability and performance.

Method used

By setting up a memory cache layer between the system cache and the metadata server, creating metadata tables and index tables, storing metadata and index data of temporary tables, and caching them locally on the computing node, reducing access to the metadata server and using virtual The row number and page-level indexing mechanism manages metadata and implements localized metadata maintenance and caching.

Benefits of technology

It effectively reduces access delays, improves metadata access speed and system scalability, reduces metadata server load, avoids bottlenecks, and ensures data consistency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118519998B_ABST
    Figure CN118519998B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention provides a distributed database local temporary table management method, device, equipment and medium, which relates to the technical field of database management. The method includes creating a metadata table and an index table, wherein the metadata table is used to store the original table data of the metadata of the temporary table, and the index table is used to store the index data of the metadata of the temporary table; a memory cache layer is set between the system cache and the metadata server, and the metadata table and the index table are stored in the memory cache layer; when the data required by the current computing node does not exist in the system cache, the current computing node obtains data from the metadata table by scanning the index table; when the data required by the current computing node does not exist in the memory cache layer, the current computing node accesses the metadata server to obtain the data. The solution improves the scalability of the system and the metadata access speed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of database management, and in particular to a method, device, equipment and medium for managing a local temporary table of a distributed database. Background Art

[0002] In modern database systems, data storage and computing are typically tightly coupled. However, with the advent of the big data era, the explosive growth of data volumes and the increasing demand for computing resources, a storage-computing separation architecture is becoming increasingly popular. In this architecture, data storage and computing resources are separated into different servers, enabling flexible expansion of storage and computing capabilities and better optimization of resource utilization.

[0003] Defects of temporary tables in the storage-computing separation architecture: Although the storage-computing separation architecture brings flexibility and scalability, it also introduces new challenges. Especially in terms of metadata management, since metadata (such as table structure, index, statistical information, etc.) are usually stored on independent metadata servers, computing nodes need to frequently access these centrally stored metadata, resulting in the following problems: High latency: Every time a computing node needs to access or modify metadata, it needs to communicate with the metadata server through the network, which will result in higher latency; High load: The metadata server needs to process requests from many computing clusters, which is a bottleneck that restricts the system's scalability; Consistency issues: Concurrent access and modification of metadata by multiple computing nodes may lead to consistency issues. Dealing with these consistency issues will further increase the complexity and overhead of the system;

[0004] PostgreSQL's temporary table solution: PostgreSQL allows users to create temporary tables, which are automatically deleted at the end of a session or transaction (depending on the definition at creation time). Metadata for temporary tables is stored on local disk, just like regular tables. This means that while data in temporary tables does not need to be persisted, they still require disk I / O operations. Metadata for temporary tables is stored in system catalog tables, which require access to the system catalog to manage and maintain this metadata. Accessing this metadata can lead to disk I / O bottlenecks, especially in highly concurrent environments.

[0005] Greenplum's temporary table solution and metadata management: As a parallel extension of PostgreSQL, Greenplum inherits PostgreSQL's temporary table features. Although temporary table data is stored on the local disk of the segment node, network communication may still be involved in a distributed environment, especially when queries need to cross segment nodes. Greenplum's metadata is distributed across the Master node and Segment nodes. The Master node maintains global metadata and system catalogs, while the Segment node manages metadata for local data. When a compute node (Segment node) needs to access or modify metadata, coordination is usually required through the Master node. The Master node becomes the hub for metadata access. Although the Segment node can cache some metadata, the need for coordination through the Master node still involves network communication and potential bottlenecks. Summary of the Invention

[0006] In view of this, an embodiment of the present invention provides a method for managing local temporary tables in a distributed database to solve the technical problems of frequent network communication, access delays, and limited access speed in data processing in the prior art. The method includes:

[0007] Create a metadata table and an index table, wherein the metadata table is used to store original table data of the metadata of the temporary table, and the index table is used to store index data of the metadata of the temporary table;

[0008] Setting a memory cache layer between the system cache and the metadata server, and storing the metadata table and the index table in the memory cache layer;

[0009] When the data required by the current computing node does not exist in the system cache, the current computing node obtains the data from the metadata table by scanning the index table;

[0010] When the data required by the current computing node does not exist in the memory cache layer, the current computing node accesses the metadata server to obtain the data.

[0011] The present invention also provides a distributed database local temporary table management device to solve the technical problems of frequent network communication, access delay, and limited access speed in data processing in the prior art. The device includes:

[0012] A creation module is used to create a metadata table and an index table, wherein the metadata table is used to store the original table data of the metadata of the temporary table, and the index table is used to store the index data of the metadata of the temporary table;

[0013] A memory cache layer setting module, configured to set a memory cache layer between the system cache and the metadata server, and store the metadata table and the index table in the memory cache layer;

[0014] A scanning module, configured to, when the data required by the current computing node does not exist in the system cache, enable the current computing node to obtain data from the metadata table by scanning the index table;

[0015] The metadata server access module is used for, when the data required by the current computing node does not exist in the memory cache layer, the current computing node accesses the metadata server to obtain data.

[0016] An embodiment of the present invention also provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the computer device implements any of the above-mentioned methods for managing local temporary tables in a distributed database, thereby solving the technical problems of frequent network communication, access delays, and limited access speed in data processing in the prior art.

[0017] An embodiment of the present invention also provides a computer-readable storage medium, which stores a computer program for executing any of the above-mentioned distributed database local temporary table management methods to solve the technical problems of frequent network communication, access delay, and limited access speed in data processing in the prior art.

[0018] Compared with the prior art, the beneficial effects that can be achieved by at least one of the above-mentioned technical solutions adopted in the embodiments of this specification include at least the following: The present application provides a method for managing temporary tables under an architecture of storage and computing separation and shared metadata, which achieves high efficiency while ensuring data consistency and improves the scalability of the system. Specifically, by setting up a memory cache layer between the system cache and the metadata server and placing the metadata of the temporary table in the local memory cache layer, the number of accesses to the metadata server can be effectively reduced, and the scalability of the system and the speed of metadata access can be improved; at the same time, the metadata is only placed in the memory locally, which can effectively improve the access speed compared to storing the metadata on disk, and further improve the data processing performance. In addition, since the metadata is stored in the local memory, the metadata maintenance process can reduce the number of requests to the centralized metadata server, reduce the load on the metadata server, and effectively avoid bottleneck problems. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0020] Figure 1 This is a flow chart of a distributed database local temporary table management method provided by an embodiment of the present invention;

[0021] Figure 2 This is a schematic diagram of the location of the memory cache layer provided by an embodiment of the present invention;

[0022] Figure 3 This is a structural block diagram of a computer device provided by an embodiment of the present invention;

[0023] Figure 4 This is a structural block diagram of a distributed database local temporary table management device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0024] The embodiments of the present application are described in detail below with reference to the accompanying drawings.

[0025] The following describes the embodiments of the present application through specific examples, and those skilled in the art can easily understand other advantages and effects of the present application from the contents disclosed in this specification. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. The present application can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present application. It should be noted that, in the absence of conflict, the features in the following embodiments and embodiments can be combined with each other. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without making creative work are within the scope of protection of this application.

[0026] In an embodiment of the present invention, a method for managing a local temporary table of a distributed database is provided. Figure 1 As shown, the method includes:

[0027] Step S101: Create a metadata table and an index table, wherein the metadata table is used to store original table data of metadata of a temporary table, and the index table is used to store index data of metadata of the temporary table;

[0028] Step S102: Setting a memory cache layer between the system cache and the metadata server, and storing the metadata table and the index table in the memory cache layer;

[0029] Step S103: When the data required by the current computing node does not exist in the system cache, the current computing node obtains data from the metadata table by scanning the index table;

[0030] Step S104: When the data required by the current computing node does not exist in the memory cache layer, the current computing node accesses the metadata server to obtain the data.

[0031] In the current storage and computing separation solution, if the syscache (system cache) does not hit, the remote metadata server is accessed. This embodiment adds a memory cache layer to cache and manage metadata in the local memory cache layer of the computing node. Figure 2 As shown in the in-memory metadata location, all cache misses access only the in-memory cache layer and no longer the metadata server. This avoids frequent network communication and significantly reduces access latency. Temporary table data and metadata are both stored in local memory, further reducing disk I / O operations and improving access speed.

[0032] In one embodiment, creating a metadata table includes:

[0033] For each metadata table, create a page set for storing records of original table data, wherein the page set includes multiple pages;

[0034] Set a virtual row number starting from 0. The virtual row number is used to mark the position of each record. Each time a record is inserted, the virtual row number is incremented.

[0035] For multiple versions of a record, each version of the record is inserted as a new record, and the virtual row number is incremented;

[0036] A visibility field is set for each version of the record, and the visibility field is used to identify the validity of different versions of the record;

[0037] All the inserted records are arranged in sequence in the page according to the order of the virtual row numbers, and the number of the virtual row numbers in each page is the same.

[0038] In implementation, each metadata table is mapped to a set of pages. A virtual row number is maintained, starting at 0 and incremented with each record. The original table's pages are divided into fixed row numbers, and records are arranged sequentially within the pages by row number. A metadata table can have multiple versions. Even when the same record is updated, a new record is created, and a visibility field indicates whether the data is valid.

[0039] Setting virtual row numbers ensures that every row of data can be efficiently managed and accessed, even with large amounts of data. By assigning each record a unique virtual row number, it is possible to locate the record independently of its physical location, helping to speed up query processing, especially when performing range queries or full table scans.

[0040] In one embodiment, creating the index table includes:

[0041] Creating the index table for the index attributes of the metadata table, wherein the index table is sorted by key value, where the key value is a combination of the corresponding index attribute values ​​in the record;

[0042] When a record is inserted into the metadata table, an index record corresponding to the record is inserted into the index table;

[0043] For multiple versions of a record, insert an index record corresponding to each version of the record into the index table;

[0044] The index records are maintained in the order of insertion of the index table page. When the number of the index records reaches the preset maximum capacity of the index table page, the index table page is split.

[0045] In practice, each metadata index is a separate table, sorted by key value, which is a combination of the corresponding index attribute values ​​in the record. Pages are maintained in the order of insertion, and pages are split when the page size is exceeded. This not only avoids performance degradation caused by overfilling pages, but also maintains the orderliness of the index, thereby improving query efficiency. The index entry records all versions of the original table record and does not store visibility information. In a multi-version control environment, the validity of the version is determined through additional data structures or metadata, reducing index complexity and storage overhead while ensuring data consistency and correctness.

[0046] Furthermore, a page-level index is created for each page of the metadata table, sorted by page, and the metadata table is sequentially scanned using the page-level index. This index helps quickly locate data blocks and improves query speed by reducing the number of disk I / O operations, which is particularly important for large-scale datasets.

[0047] In one embodiment, the current computing node obtains data from the metadata table by scanning the index table, including:

[0048] By accessing the hash table, determine whether there is data in the temporary table;

[0049] When data in the temporary table exists, the scanning context is reset, and the scanning requirement for the temporary table is identified in the scanning context, and the scanning is performed according to the identification;

[0050] When the metadata is scanned sequentially, each page in the metadata table is traversed according to the page-level index to obtain records related to the current computing node. If the visibility field corresponding to the record is displayed as invisible, the record is ignored; otherwise, the record is returned.

[0051] When the metadata is index scanned, the first record in the metadata table pointed to by the index record is determined according to the index record in the index table. If the visibility field corresponding to the record is displayed as invisible, the record is ignored; otherwise, the record is returned;

[0052] All returned scan results are judged for multi-version concurrency control and then returned to the current computing node.

[0053] In practice, metadata is scanned sequentially and indexed, requiring an additional scan of the local temporary cache to be added to the existing scan process. The aforementioned process already records which tables have locally cached records during local temporary table operations. Therefore, after scanning the shared data, another scan of the temporary cache is initiated. Therefore, this embodiment, by adding a rescan mechanism, facilitates integration with the existing metadata access process.

[0054] In one embodiment, the method further comprises:

[0055] For each computing node, metadata related to the computing node is maintained. The maintenance methods include OID allocation, metadata insertion, metadata modification, and metadata deletion.

[0056] In specific implementation, the table creation process is used to illustrate the operation of local temporary tables. Localized temporary tables combine the implementation features of both the storage and computing integration mode and the separation mode. The necessary unified information is transmitted between the coordinator and participants, and each computing node independently generates and maintains the metadata information in memory. The specific maintenance process includes the following:

[0057] (1) Assignment of OIDs (Object Identifiers). For example, the OIDs for pg_class (a system table in the PostgreSQL database system that stores basic metadata information for all tables (including views, indexes, sequences, composite types, and other database objects)) are still assigned by the metaserver. This is to allow for docking with the catalog cache and access using a unified relid (table identifier). However, some IDs that are only relevant locally, such as relfilenode (table file node), can be assigned locally. The assigned OIDs are distributed to participants to maintain a unified OID.

[0058] (2) If a new record is inserted, the next virtual rownum is calculated based on the current virtual rownum of the table, and then inserted into the next memory location of the metadata table. At the same time, the corresponding index information is generated and inserted into the corresponding page position of the index table;

[0059] (3) If the existing metadata is modified, the original record is marked as deleted and the new record is inserted into the next position in the metadata table. For the index, after finding the corresponding item, a new item pointing to the new record is added.

[0060] (4) If a piece of metadata is deleted, the data is marked as deleted.

[0061] In this embodiment, metadata is generated and managed locally. The coordinator and participants maintain their own metadata independently, without any coupling between them. This reduces the number of requests to the centralized metadata server, lowering the metadata server load and avoiding bottlenecks. Each compute node only needs to manage and maintain metadata related to itself, further distributing the load. It should be noted that this embodiment uses the PostgreSQL database as an example, but is not limited to PostgreSQL databases.

[0062] In one embodiment, the method further comprises:

[0063] According to different metadata maintenance methods, the visibility field corresponding to the record to be maintained is edited accordingly to generate the effectiveness information corresponding to the record;

[0064] When the record is scanned, the visibility of the record is determined according to the validation information.

[0065] This embodiment ensures metadata consistency in a distributed environment by setting up a local cache mechanism and a modification notification mechanism, avoiding complex concurrency control mechanisms. Since the metadata load is reduced, scalability is greatly improved.

[0066] In practice, in-memory temporary tables allow users to specify the timing of data visibility. The specific steps are as follows:

[0067] (1) During metadata maintenance, each operation records a piece of effective information, including:

[0068] The visibility field is marked as visible=false, deleted=false when inserting;

[0069] When deleting, the visibility field is marked as visible=false, deleted=true;

[0070] When updating, split the record into two, the original record is marked as visible=false, deleted=true; the new record is marked as visible=false, deleted=false; at the same time, record the link relationship between the original record and the new record;

[0071] (2) Put the recorded validity information into a queue of this process;

[0072] (3) When a record is scanned, the visibility is determined as follows: visible = true and deleted = false or deleted = true and visible = false, indicating that the record is not visible.

[0073] (4) When the aforementioned records need to be made effective, the messages are processed in sequence, including:

[0074] For insertion and deletion, mark the record as visible=true, so that insertion becomes visible and deletion becomes invisible;

[0075] For update, mark the original record as visible=true, the original record is invisible, and the new record becomes visible because of visible=true.

[0076] Therefore, this embodiment sets the data visibility time, and the data becomes invisible when modified, allows the specification of the visibility time, and proposes a novel visibility judgment mechanism to ensure the consistency of metadata in a distributed environment and avoid complex concurrency control mechanisms.

[0077] The method of this application has the following advantages:

[0078] Reduced latency. By caching and managing metadata in the local memory of the compute node, frequent network communication is avoided, significantly reducing access latency. Temporary table data and metadata are both stored in local memory, further reducing disk I / O operations and improving access speed.

[0079] Reduced load. Compute nodes independently maintain local metadata caches, reducing the number of requests to the centralized metadata server, lowering the metadata server load and avoiding bottlenecks. Each compute node only needs to manage and maintain metadata related to itself, further distributing the load.

[0080] Improved performance and scalability. Local caching and modification notification mechanisms ensure metadata consistency across distributed environments, avoiding complex concurrency control mechanisms. By reducing metadata load, scalability is significantly improved.

[0081] In this embodiment, a computer device is provided, such as Figure 3 As shown, it includes a memory 301, a processor 302 and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, any of the above-mentioned methods for managing local temporary tables of a distributed database is implemented.

[0082] Specifically, the computer device may be a computer terminal, a server or a similar computing device.

[0083] In this embodiment, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program for executing any of the above-mentioned methods for managing local temporary tables in a distributed database.

[0084] Specifically, computer-readable storage media include permanent and non-permanent, removable and non-removable media that can be used to store information by any method or technology. The information can be computer-readable instructions, data structures, program modules or other data. Examples of computer-readable storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable storage media does not include transitory media such as modulated data signals and carrier waves.

[0085] Based on the same inventive concept, an embodiment of the present invention further provides a distributed database local temporary table management device, as described in the following embodiments. Since the principle of solving the problem by the distributed database local temporary table management device is similar to that of the distributed database local temporary table management method, the implementation of the distributed database local temporary table management device can refer to the implementation of the distributed database local temporary table management method, and the repeated parts will not be repeated. As used below, the term "unit" or "module" can be a combination of software and / or hardware that implements the predetermined function. Although the device described in the following embodiments is preferably implemented in software, implementation in hardware, or a combination of software and hardware, is also possible and conceivable.

[0086] Figure 4 This is a structural diagram of a distributed database local temporary table management device according to an embodiment of the present invention. Figure 4As shown, it includes: a creation module 401, a memory cache layer setting module 402, a scanning module 403 and a metadata server access module 404. The structure is described below.

[0087] A creation module 401 is used to create a metadata table and an index table, wherein the metadata table is used to store original table data of metadata of a temporary table, and the index table is used to store index data of metadata of the temporary table;

[0088] A memory cache layer setting module 402 is configured to set a memory cache layer between the system cache and the metadata server, and store the metadata table and the index table in the memory cache layer;

[0089] Scanning module 403, configured to, when the data required by the current computing node does not exist in the system cache, enable the current computing node to obtain data from the metadata table by scanning the index table;

[0090] The metadata server access module 404 is configured to enable the current computing node to access the metadata server to obtain data when the data required by the current computing node does not exist in the memory cache layer.

[0091] In one embodiment, the creation module 401 is further configured to:

[0092] For each metadata table, create a page set for storing records of original table data, wherein the page set includes multiple pages;

[0093] Set a virtual row number starting from 0. The virtual row number is used to mark the position of each record. Each time a record is inserted, the virtual row number is incremented.

[0094] For multiple versions of a record, each version of the record is inserted as a new record, and the virtual row number is incremented;

[0095] A visibility field is set for each version of the record, and the visibility field is used to identify the validity of different versions of the record;

[0096] All the inserted records are arranged in sequence in the page according to the order of the virtual row numbers, and the number of the virtual row numbers in each page is the same.

[0097] In one embodiment, the creation module 401 is further configured to:

[0098] Creating the index table for the index attributes of the metadata table, wherein the index table is sorted by key value, where the key value is a combination of the corresponding index attribute values ​​in the record;

[0099] When a record is inserted into the metadata table, an index record corresponding to the record is inserted into the index table;

[0100] For multiple versions of a record, insert an index record corresponding to each version of the record into the index table;

[0101] The index records are maintained in the order of insertion of the index table page. When the number of the index records reaches the preset maximum capacity of the index table page, the index table page is split.

[0102] In one embodiment, the apparatus further comprises:

[0103] The page-level index creation module is used to create page-level indexes sorted by page for different pages of the metadata table, and sequentially scan the metadata table through the page-level indexes.

[0104] In one embodiment, the scanning module 403 is further configured to:

[0105] By accessing the hash table, determine whether there is data in the temporary table;

[0106] When data in the temporary table exists, the scanning context is reset, and the scanning requirement for the temporary table is identified in the scanning context, and the scanning is performed according to the identification;

[0107] When the metadata is scanned sequentially, each page in the metadata table is traversed according to the page-level index to obtain records related to the current computing node. If the visibility field corresponding to the record is displayed as invisible, the record is ignored; otherwise, the record is returned.

[0108] When the metadata is index scanned, the first record in the metadata table pointed to by the index record is determined according to the index record in the index table. If the visibility field corresponding to the record is displayed as invisible, the record is ignored; otherwise, the record is returned;

[0109] All returned scan results are judged for multi-version concurrency control and then returned to the current computing node.

[0110] In one embodiment, the apparatus further comprises:

[0111] The maintenance module is used to maintain metadata related to each computing node. The maintenance methods include OID allocation, metadata insertion, metadata modification and metadata deletion.

[0112] In one embodiment, the apparatus further comprises:

[0113] An effective information generation module is used to edit the visibility field corresponding to the record to be maintained according to different metadata maintenance methods, and generate effective information corresponding to the record;

[0114] The visibility judgment module is used to judge the visibility of the record according to the validation information when the record is scanned.

[0115] The embodiments of the present invention achieve the following technical effects: The present application provides a method for managing temporary tables under an architecture of storage and computing separation and shared metadata, which achieves high efficiency while ensuring data consistency and improves the scalability of the system. Specifically, by setting up a memory cache layer between the system cache and the metadata server, and placing the metadata of the temporary table in the local memory cache layer, the number of accesses to the metadata server can be effectively reduced, thereby improving the scalability of the system and the speed of metadata access; at the same time, the metadata is only placed locally in memory, which can effectively increase the access speed compared to storing the metadata on disk, further improving data processing performance. In addition, since the metadata is stored in local memory, the metadata maintenance process can reduce the number of requests to the centralized metadata server, reduce the load on the metadata server, and effectively avoid bottleneck problems.

[0116] Obviously, those skilled in the art should understand that the various modules or steps of the above-mentioned embodiments of the present invention can be implemented using a general-purpose computing device, they can be concentrated on a single computing device, or distributed across a network composed of multiple computing devices. Alternatively, they can be implemented using program code executable by the computing device, so that they can be stored in a storage device and executed by the computing device. In some cases, the steps shown or described can be performed in a different order than herein, or they can be made into separate integrated circuit modules, or multiple modules or steps can be made into a single integrated circuit module for implementation. Thus, the embodiments of the present invention are not limited to any specific combination of hardware and software.

[0117] The foregoing description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Those skilled in the art will readily appreciate that various modifications and variations of the present invention are possible. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present invention are intended to be within the scope of protection of the present invention.

Claims

1. A method for managing local temporary tables in a distributed database. It is characterized in that include: Create a metadata table and an index table, wherein the metadata table is used to store original table data of metadata of the temporary table, and the index table is used to store index data of metadata of the temporary table; A memory cache layer is set between the system cache and the metadata server, and the metadata table and the index table are stored in the memory cache layer; When the data required by the current computing node does not exist in the system cache, the current computing node obtains the data from the metadata table by scanning the index table; When the data required by the current computing node does not exist in the memory cache layer, the current computing node accesses the metadata server to obtain the data; The step of creating a metadata table includes: For each metadata table, create a page set for storing records of original table data, wherein the page set includes multiple pages; Set a virtual row number starting from 0, the virtual row number is used to mark the position of each record, and the virtual row number increases each time a record is inserted; For multiple versions of a record, each version of the record is inserted as a new record, and the virtual row number is incremented; A visibility field is set for each version of the record, and the visibility field is used to identify the validity of different versions of the record; Arrange all the inserted records in the pages in the order of the virtual row numbers, and the number of the virtual row numbers in each page is the same; The step of creating an index table includes: Creating the index table for the index attributes of the metadata table, wherein the index table is sorted by key value, and the key value is a combination of the corresponding index attribute values ​​in the record; When a record is inserted into the metadata table, an index record corresponding to the record is inserted into the index table; For multiple versions of a record, inserting index records corresponding to each version of the record into the index table; The index records are maintained in the index table page in the order of insertion, and when the number of the index records reaches the preset maximum capacity of the index table page, the index table page is split; The method further comprises: For different pages of the metadata table, a page-level index sorted by page is created, and the metadata table is sequentially scanned through the page-level index.

2. The distributed database local temporary table management method according to claim 1, It is characterized in that The current computing node obtains data from the metadata table by scanning the index table, including: By accessing the hash table, determine whether there is data in the temporary table; When data in the temporary table exists, the scanning context is reset, and the scanning requirement for the temporary table is identified in the scanning context, and the scanning is performed according to the identification; When the metadata is scanned sequentially, traverse each page in the metadata table according to the page-level index to obtain records related to the current computing node. If the visibility field corresponding to the record is displayed as invisible, ignore the record; otherwise, return the record. When the metadata is index scanned, the first record in the metadata table pointed to by the index record is determined according to the index record in the index table, and if the visibility field corresponding to the record is displayed as invisible, the record is ignored, otherwise the record is returned; All returned scan results are judged for multi-version concurrency control and then returned to the current computing node.

3. The distributed database local temporary table management method according to claim 1, It is characterized in that The method further comprises: For each computing node, metadata related to the computing node is maintained, and the maintenance methods include OID allocation, metadata insertion, metadata modification and metadata deletion.

4. The distributed database local temporary table management method according to claim 3, It is characterized in that The method further comprises: According to different metadata maintenance methods, the visibility field corresponding to the record to be maintained is edited accordingly to generate effective information corresponding to the record; When the record is scanned, the visibility of the record is determined according to the validation information.

5. A distributed database local temporary table management device, It is characterized in that include: A creation module, used to create a metadata table and an index table, wherein the metadata table is used to store original table data of metadata of a temporary table, and the index table is used to store index data of metadata of a temporary table; The step of creating a metadata table includes: For each metadata table, create a page set for storing records of original table data, wherein the page set includes multiple pages; Set a virtual row number starting from 0, the virtual row number is used to mark the position of each record, and the virtual row number increases each time a record is inserted; For multiple versions of a record, each version of the record is inserted as a new record, and the virtual row number is incremented; A visibility field is set for each version of the record, and the visibility field is used to identify the validity of different versions of the record; Arrange all the inserted records in the pages in the order of the virtual row numbers, and the number of the virtual row numbers in each page is the same; The step of creating an index table includes: Creating the index table for the index attributes of the metadata table, wherein the index table is sorted by key value, and the key value is a combination of the corresponding index attribute values ​​in the record; When a record is inserted into the metadata table, an index record corresponding to the record is inserted into the index table; For multiple versions of a record, inserting index records corresponding to each version of the record into the index table; The index records are maintained in the index table page in the order of insertion, and when the number of the index records reaches the preset maximum capacity of the index table page, the index table page is split; A memory cache layer setting module, used to set a memory cache layer between the system cache and the metadata server, and store the metadata table and the index table in the memory cache layer; A scanning module, used for, when the data required by the current computing node does not exist in the system cache, the current computing node obtains data from the metadata table by scanning the index table; A metadata server access module, configured to enable the current computing node to access the metadata server to obtain data when the data required by the current computing node does not exist in the memory cache layer; The page-level index creation module is used to create page-level indexes sorted by page for different pages of the metadata table, and sequentially scan the metadata table through the page-level indexes.

6. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the computer program, the distributed database local temporary table management method according to any one of claims 1 to 4 is implemented.

7. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer program for executing the distributed database local temporary table management method according to any one of claims 1 to 4.

Citation Information

Patent Citations

  • Distributed cache management system and method for implementing distributed cache management

    CN102833352A

  • Database cache construction method and apparatus, computer device, and storage medium

    CN109542907A

  • Mass big data retrieval method and system

    CN110162528A

  • Metadata query method based on distributed file system, and device and storage medium

    WO2023093245A1