Database data dictionary management method and device, equipment and storage medium
By using the reference counting mechanism to manage metadata in the data dictionary, the problem of low access efficiency of data dictionary is solved, and more efficient access and resource utilization is achieved.
Patent Information
- Application Number
- CN202510912862.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-03
- Publication Date
- 2025-08-01
- Estimated Expiration
- 2045-07-03
AI Technical Summary
In the prior art, the access efficiency of the data dictionary is low, especially when the metadata reference count is zero, it is necessary to rescan the system table and apply for memory, resulting in reduced access efficiency and waste of memory resources.
The reference counting mechanism is used to manage the metadata in the data dictionary. If the reference count is zero but the memory is sufficient, the metadata is not deleted immediately, but it is temporarily retained in the data dictionary for easier access and reducing scanning time and memory applications.
It improves the access efficiency of data dictionary, reduces the scanning time and memory application time of the database system, avoids waste of memory resources, and improves resource utilization.
Smart Images

Figure CN120407572A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of database memory, and particularly to a method, apparatus, device and storage medium for managing a data dictionary of a database. Background Art
[0002] When a database session accesses a table in a database, it is necessary to obtain the meta-information of the table, including schema information, table name, table identifier, column attributes, number of rows, etc. The meta-information of the table is stored in the system table, and this meta-information is called a data dictionary.
[0003] Since this meta-information is accessed very frequently, in order to improve the access efficiency, after accessing this information, it is cached in the memory context of the session. When it is no longer used, the information is released from the memory. However, when accessing again, since the table information is not in the data dictionary, it is necessary to scan the system table and apply for memory again, which will reduce the access efficiency of the data dictionary. Therefore, there is an urgent need for a method that can improve the access efficiency of the data dictionary. Summary of the Invention
[0004] The present invention provides a method, apparatus, device and storage medium for managing a data dictionary of a database to implement the management of the data dictionary of the database and improve the access efficiency of the data dictionary.
[0005] In a first aspect, an embodiment of the present invention provides a method for managing a data dictionary of a database, the method including:
[0006] For the stored metadata in the data dictionary, if indexing is performed based on the stored metadata, the reference count of the stored metadata is increased by a preset value, and if the indexing based on the stored metadata ends, the reference count of the stored metadata is decreased by a preset value;
[0007] If the reference count of the stored metadata is reduced to zero and there is no need to release the occupied memory of the data dictionary, the stored metadata is retained in the data dictionary.
[0008] In a second aspect, an embodiment of the present invention further provides a device for managing a data dictionary of a database, the device including:
[0009] A count modification module, configured to, for the stored metadata in the data dictionary, if indexing is performed based on the stored metadata, increase the reference count of the stored metadata by a preset value, and if the indexing based on the stored metadata ends, decrease the reference count of the stored metadata by a preset value;
[0010] A data retention module, which is configured to retain the stored metadata in the data dictionary if the reference count of the stored metadata is reduced to zero and there is no need to release the occupied memory of the data dictionary.
[0011] In a third aspect, an embodiment of the present invention further provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the program, it implements the data dictionary management method of any one of the embodiments of the present invention for a database.
[0012] In a fourth aspect, an embodiment of the present invention further provides a storage medium storing computer-executable instructions, and the computer-executable instructions are used to execute the data dictionary management method of any one of the embodiments of the present invention for a database when executed by a computer processor.
[0013] The technical solution of the embodiment of the present invention implements a reference counting mechanism for metadata in the data dictionary. However, when the reference count of the stored metadata is reduced to zero and the memory of the data dictionary is sufficient, instead of deleting the stored metadata with a zero reference count, the stored metadata is temporarily retained in the data dictionary. This is to reduce the database system scanning time and the data dictionary memory application time during subsequent access to the same stored metadata, effectively shortening the data dictionary response time, improving the data dictionary access efficiency, and at the same time avoiding waste of the data dictionary memory resources and improving the resource utilization rate of the data dictionary.
[0014] It should be understood that the content described in this part is not intended to identify the key or important features of the embodiments of the present invention, nor is it used to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. Description of the Drawings
[0015] To more clearly illustrate the technical solutions in the embodiments of the present invention, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0016] Figure 1 is a flowchart of a data dictionary management method for a database provided in Embodiment 1 of the present invention;
[0017] Figure 2 is a flowchart of a data dictionary management method for a database provided in Embodiment 2 of the present invention;
[0018] Figure 3 is a flowchart of saving target metadata into the data dictionary provided in Embodiment 2 of the present invention;
[0019] Figure 4 It is a schematic structural diagram of a data dictionary management device for a database provided in Embodiment 3 of the present invention;
[0020] Figure 5 It is a schematic structural diagram of an electronic device for implementing the data dictionary management method of the database in the embodiment of the present invention. Specific embodiments
[0021] In order to enable those skilled in the art to better understand the solution of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
[0022] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and do not necessarily need to be used to describe a specific order or sequence. It should be understood that such data used may be interchanged under appropriate circumstances so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device including a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0023] Embodiment 1
[0024] Figure 1 This is a flowchart of a data dictionary management method for a database provided in Embodiment 1 of the present invention. This embodiment is applicable to the situation of data dictionary management of a database. This method can be executed by a data dictionary management device for a database. The data dictionary management device for a database can be implemented in the form of hardware and / or software, and the data dictionary management device for a database can be configured in any electronic device with network communication and computing capabilities. As Figure 1 shown, the method includes:
[0025] S110. For the stored metadata in the data dictionary, if indexing is performed based on the stored metadata, the reference count of the stored metadata is increased by a preset value. If the indexing based on the stored metadata ends, the reference count of the stored metadata is decreased by a preset value.
[0026] It should be noted that this embodiment is a method for managing a data dictionary based on the memory context of a database system.
[0027] In this embodiment, metadata is data that describes data and is used to define and explain information such as the structure, attributes, relationships, and constraints of data. Among them, the stored metadata in the data dictionary is the metadata that already exists in the data dictionary, and the type of stored metadata can be structural metadata, business metadata, operation metadata, or technical metadata.
[0028] If the type of stored metadata is structural metadata, the storage form of the metadata in the data dictionary can be composed of table name, field name, data type, whether the data can be null, and business description, etc.
[0029] Among them, the reference count of metadata is used to record the number of times the metadata is referenced by other objects or entities. At the same time, the reference count of metadata can be used to track the usage of metadata to ensure the lifecycle management of metadata and data consistency. The preset value in this embodiment is usually 1.
[0030] In the data dictionary, each time a new reference points to the target metadata, the reference count of the target metadata is incremented by 1; when the reference is deleted, the reference count of the target metadata is decremented by 1.
[0031] Specifically, when a database session is started, in the SysCache (system cache) memory context, the content of the data dictionary is empty at this time. As subsequent accesses to the metadata of the table are made and found from the system tables, memory is allocated in the system cache and placed in the data dictionary.
[0032] The data dictionary is an array that contains various types of table information, such as table names, column information, and schema information, etc. Each type has a hash bucket inside, and each hash bucket has a doubly linked list. The list elements are the metadata content of the table, and each list element has a reference counter.
[0033] When the target metadata corresponding to the target data is found in the data dictionary, the target metadata is accessed, the reference count of the target metadata is incremented by 1, the cache address of the target metadata is referenced, and the target metadata is moved to the head of the doubly linked list. When the access ends and the target metadata is no longer accessed, the reference counter of the target metadata is decremented by 1.
[0034] It should be noted that implementing a reference count mechanism for metadata in the data dictionary, where the reference count is incremented during access and decremented during release, can effectively judge the access frequency of data and ensure that metadata with a low usage frequency or no longer in use can be recycled in a timely manner to implement a more reasonable cache eviction algorithm.
[0035] S120. If the reference count of the stored metadata is reduced to zero and there is no need to release the occupied memory of the data dictionary, the stored metadata is retained in the data dictionary.
[0036] In this embodiment, the occupied memory of the data dictionary comes from the occupied memory space of the stored metadata. If there is no need to release the occupied memory of the data dictionary, the following two situations may occur. First, during the current data access process, the remaining memory of the data dictionary is sufficient to store new metadata. Second, during the current data access process, the metadata to be accessed has been stored in the memory of the data dictionary and there is no need to store new metadata. It can be understood that if the above two situations occur, there is no need to release the occupied memory of the data dictionary.
[0037] It should be noted that in the existing data dictionary management method of the database, after accessing the metadata, it will be cached in the memory context of the database session. When the reference count of the metadata is 0, it means that the data is no longer accessed, and the metadata will be released from the memory of the data dictionary. However, when accessing again, since the metadata is not in the data dictionary, it is necessary to rescan the system tables of the database and apply for memory in the data dictionary again to store the metadata of the data, which reduces the access efficiency of the data dictionary.
[0038] However, in this embodiment, when the reference count of the metadata is reduced to 0, the metadata is not immediately deleted from the data dictionary, but is temporarily retained in the memory of the data dictionary. Considering that it is very likely to continue accessing the metadata in the future. Therefore, in this solution, the metadata with the reference count reduced to 0 is temporarily retained in the memory of the data dictionary so that when accessing next time, it is not necessary to rescan the system tables in the database again, nor to apply for memory in the data dictionary again for the corresponding metadata. Therefore, this embodiment can greatly improve the access efficiency of the data dictionary by temporarily retaining the metadata with the reference count of 0 in the data dictionary.
[0039] The embodiment of the present invention discloses a method for managing a data dictionary of a database. For the stored metadata in the data dictionary, if indexing is performed based on the stored metadata, the reference count of the stored metadata is increased by a preset value. If the indexing based on the stored metadata ends, the reference count of the stored metadata is decreased by a preset value. If the reference count of the stored metadata is reduced to zero and there is no need to release the occupied memory of the data dictionary, the stored metadata is retained in the data dictionary. The technical solution of the embodiment of the present invention implements a reference counting mechanism for metadata in the data dictionary. However, when the reference count of the stored metadata is reduced to zero and the memory of the data dictionary is sufficient, instead of deleting the stored metadata with a zero reference count, the stored metadata is temporarily retained in the data dictionary, so as to reduce the database system scanning time and the memory application time of the data dictionary during subsequent access to the same stored metadata, effectively shortening the data dictionary response time, improving the access efficiency of the data dictionary, and at the same time avoiding the waste of memory resources of the data dictionary and improving the resource utilization rate of the data dictionary.
[0040] Embodiment 2
[0041] Figure 2 The flowchart of a method for managing a data dictionary of a database provided by the second embodiment of the present invention is further specified on the basis of the above embodiment. This embodiment is applicable to the situation of managing a data dictionary of a database. This method can be executed by a data dictionary management device of the database. The data dictionary management device of the database can be implemented in the form of hardware and / or software, and the data dictionary management device of the database can be configured in any electronic device with network communication and computing capabilities. As Figure 2 shown, the method includes:
[0042] S210. When there is no stored metadata in the retrieved data dictionary that matches the target metadata, detect whether the memory of the data dictionary meets the storage condition for storing the target metadata.
[0043] In this embodiment, the target metadata is used to represent the metadata associated with the data to be accessed in the database, and the target metadata records the structure and attribute information of the data to be accessed.
[0044] It should be noted that during the access process of the database to the data to be accessed, if there is no stored metadata in the retrieved data dictionary that matches the target metadata, it means that the target metadata associated with the data to be accessed has not been created in the data dictionary.
[0045] Further, during the process of accessing the data to be accessed in the database, if it is determined that the target metadata associated with the data to be accessed does not exist in the data dictionary, the target metadata needs to be saved to the data dictionary to access the data to be accessed through the data dictionary.
[0046] Further, after determining the requirement to save the target metadata to the data dictionary, it is possible to determine whether the memory of the data dictionary meets the storage condition for storing the target metadata by comparing the remaining memory space in the data dictionary with the required memory for storing the target metadata.
[0047] In this embodiment, by detecting whether the memory of the data dictionary meets the storage condition for storing the target metadata, different operations on the data dictionary are performed during the data access process.
[0048] As an optional but non-limiting implementation, when it is retrieved that there is no stored metadata in the data dictionary that matches the target metadata, detecting whether the memory of the data dictionary meets the storage condition for storing the target metadata includes, but is not limited to, the following steps:
[0049] When it is retrieved that there is no stored metadata in the data dictionary that matches the target metadata, determine the required memory for storing the target metadata; accumulate the required memory on the basis of the memory occupied by the stored metadata in the data dictionary to obtain the first memory; compare the first memory with the second memory; the second memory is the preset memory threshold of the data dictionary.
[0050] In this embodiment, the first memory is used to represent the updated occupied memory after storing the target metadata in the data dictionary, that is, the latest occupied memory of the stored metadata in the data dictionary. The second memory is the preset memory threshold of the data dictionary, and the second memory can be understood as the maximum memory of the data dictionary.
[0051] The database uses dynamic memory in the data dictionary management process of the database. Among them, linked lists of memory blocks of various sizes applied are recorded. When obtaining the occupied space of the data dictionary, it is necessary to traverse the linked list of memory blocks to calculate the occupied memory of the data dictionary. When this method is frequently called, the access efficiency of the data dictionary will be reduced.
[0052] In the solution of the present invention, to improve the efficiency of obtaining the occupied memory of the data dictionary, a new occupied memory field is added to the structure of the data dictionary. The occupied memory field is used to record the occupied memory of the data stored in the data dictionary. By reading the occupied memory field, the occupied memory of the data dictionary can be directly obtained to quickly check whether it is necessary to release the memory occupied by the data dictionary. Frequent execution of the traversal process of each memory block linked list and the numerical calculation process is avoided, and the access efficiency of the data dictionary is improved.
[0053] It should be noted that during the process of accessing data to be accessed in the database, if it is determined that the target metadata associated with the data to be accessed does not exist in the data dictionary, it is necessary to further determine whether the memory of the data dictionary meets the storage conditions for storing the target metadata, so as to store the target metadata.
[0054] Specifically, first determine the required memory for storing the target metadata in the data dictionary. Further, quickly obtain the memory occupied by the metadata already stored in the data dictionary through the occupied memory field. Based on the memory occupied by the metadata already stored in the data dictionary, accumulate the required memory for storing the target metadata in the data dictionary to obtain the first memory.
[0055] In the solution of the present invention, a parameter for representing the second memory can be configured in the database, and the second memory is compared with the first memory to detect whether the data dictionary needs to release the metadata already stored.
[0056] S220. If it is satisfied, save the target metadata to the data dictionary as the metadata already stored.
[0057] In this embodiment, if it is further detected that the memory of the data dictionary can meet the storage conditions for storing the target metadata, it can indicate that the remaining memory space of the data dictionary is greater than the required memory for storing the target metadata, and there is no need to release the occupied memory of the data dictionary. The target metadata can be directly stored in the data dictionary and saved to the data dictionary. The saved target metadata is the metadata already stored in the data dictionary.
[0058] As an optional but non-limiting implementation, if it is satisfied, saving the target metadata to the data dictionary as the metadata already stored includes:
[0059] If it is determined that the first memory is less than the second memory, save the target metadata to the data dictionary.
[0060] In this embodiment, the storage condition that the memory of the data dictionary can meet the storage conditions for storing the target metadata can also be that the first memory is less than the second memory, and the sum of the memory occupied by the metadata already stored in the data dictionary and the required memory for storing the target metadata in the data dictionary is less than the preset memory threshold of the data dictionary. It can be understood that if the maximum memory of the data dictionary is greater than the occupied memory after saving the target metadata to the data dictionary, the target metadata can be directly saved to the data dictionary.
[0061] S230. If it is not satisfied, after releasing the occupied memory of the data dictionary, save the target metadata to the data dictionary as the metadata already stored.
[0062] In this embodiment, if it is further detected that the memory of the data dictionary does not meet the storage condition for storing the target metadata, it means that the remaining memory space of the data dictionary is smaller than the required memory for storing the target metadata. After releasing the occupied memory of the data dictionary, the target metadata needs to be stored again.
[0063] As an optional but non-limiting implementation, if not satisfied, after releasing the occupied memory of the data dictionary, the target metadata is saved to the data dictionary as the stored metadata, and the following steps are also included but not limited to:
[0064] If it is determined that the first memory is greater than or equal to the second memory, it is determined that there is a need to release the occupied memory of the data dictionary; the metadata to be released is determined from the stored metadata in the data dictionary, the metadata to be released is released, and the target metadata is saved to the data dictionary.
[0065] In this embodiment, the metadata to be released is the metadata to be released from the data dictionary, which is used to release the occupied memory of the data stored in the data dictionary and expand the remaining memory space of the data dictionary.
[0066] It should be noted that the situation where the memory of the data dictionary does not meet the storage condition for storing the target metadata can also be that the first memory is greater than or equal to the second memory, and the required memory for storing the target metadata in the data dictionary is accumulated on the basis of the occupied memory of the stored metadata in the data dictionary, which is greater than or equal to the preset memory threshold of the data dictionary. It can be understood that if the maximum memory of the data dictionary is smaller than the occupied memory after saving the target metadata to the data dictionary, the occupied memory of the data dictionary needs to be released before saving the target metadata to the data dictionary.
[0067] Further, in the case where it is determined that the occupied memory of the data dictionary needs to be released, the metadata to be released is determined from the stored metadata in the data dictionary, and the metadata to be released is released to provide more memory for saving the target metadata to the data dictionary.
[0068] In practical applications, a data elimination strategy can be set according to dimensions such as the data size, reference count, or access frequency of the stored metadata. The data to be released is determined according to the data elimination strategy, and the occupied memory of the metadata to be released is released. Among them, the elimination strategy can be understood as the rule or logic for determining the metadata to be released according to the set rules.
[0069] In this embodiment, by determining the metadata to be released from the stored metadata in the data dictionary and releasing the metadata to be released, the target metadata is saved to the data dictionary to avoid memory leakage of the data dictionary.
[0070] As an optional but non-limiting implementation, determining the metadata to be released from the stored metadata in the data dictionary includes, but is not limited to, the following steps:
[0071] Traverse the reference counts of the stored metadata in sequence from the tail of the doubly linked list in the data dictionary; if it is determined that the reference count is the first data, then use the stored metadata corresponding to the first data as the data to be released;
[0072] The method further includes:
[0073] If it is determined that the reference count is the second data, then move the stored metadata corresponding to the second data to the head of the doubly linked list; the reference count of the first data is 0, and the reference count of the second data is non-zero.
[0074] In this embodiment, the first data is metadata with a reference count of 0, and the second data is metadata with a non-zero reference count.
[0075] It should be noted that when the reference count of the stored metadata in the data dictionary is 0, it means that the current session does not reference this metadata, and thus this metadata can be deleted from the data dictionary.
[0076] Specifically, traverse and search for the metadata to be released in sequence from the tail of the doubly linked list in the data dictionary. When the first data in the data dictionary is found, the corresponding first data can be deleted from the doubly linked list, and the memory occupied by the first data can be released from the memory. When the second data in the data dictionary is found, the corresponding second data is moved to the head of the doubly linked list, so that the metadata with a low access frequency remains at the tail of the list, improving the determination efficiency of the metadata to be released.
[0077] This embodiment gives priority to retaining the metadata with a high access frequency, making the limited memory of the data dictionary play the greatest role and improving the access efficiency of the data dictionary.
[0078] As an optional but non-limiting implementation, the method further includes, but is not limited to, the following steps:
[0079] If the target metadata is saved to the data dictionary, then on the basis of the memory occupied by the stored metadata before the target metadata is not saved in the data dictionary, accumulate the required memory for saving the target metadata to update the memory occupied by the stored metadata; if there is a need to release the memory occupied by the data dictionary and the metadata to be released is released, then on the basis of the memory occupied by the stored metadata in the data dictionary, subtract the memory occupied by the metadata to be released to update the memory occupied by the stored metadata.
[0080] It should be noted that in this embodiment, both the storage process of the target metadata and the release process of the metadata to be released are accompanied by a dynamic update process of the memory occupied by the stored data in the data dictionary.
[0081] Specifically, in the storage process of the target metadata, after saving the target metadata to the data dictionary, it is necessary to accumulate the required memory for saving the target metadata on the basis of the memory occupied by the stored metadata before the target metadata is not saved in the data dictionary, so as to update the memory occupied by the stored metadata.
[0082] Specifically, in the release process of the metadata to be released, after releasing the metadata to be released, it is necessary to subtract the memory occupied by the metadata to be released from the memory occupied by the stored metadata in the data dictionary, so as to update the memory occupied by the stored metadata.
[0083] See Figure 3 The figure shows the flowchart of saving the target metadata to the data dictionary. When it is determined that the stored metadata in the data dictionary does not match the target metadata, prepare to insert the target metadata into the data. Accumulate according to the required memory for storing the target metadata and the memory occupied by the stored metadata in the data dictionary to obtain the accumulated memory. Then, detect whether the accumulated memory exceeds the maximum memory of the data dictionary. If the accumulated memory does not exceed the maximum memory, store the target metadata in the data dictionary. Otherwise, if the accumulated memory exceeds the maximum memory, it is necessary to release the memory. Further, traverse from the tail of the doubly linked list in turn, determine the metadata with a reference count of 0 as the data to be released and release it, and move the metadata with a reference count not equal to 0 to the head of the doubly linked list. Then, after performing the memory release operation of the data dictionary, store the target metadata in the data dictionary.
[0084] In this embodiment, by dynamically updating the memory occupied by the stored data in the data dictionary during the storage process of the target metadata and the release process of the metadata to be released, the memory occupied by the data dictionary can be accurately managed, which helps to improve the resource utilization rate of the data dictionary and avoid memory overflow. It can determine the memory occupied by the stored data in real time and perform numerical calculations, metadata storage, or metadata release, improving the access efficiency of the data dictionary.
[0085] In the technical solution of the embodiment of the present invention, when it is determined that there is no stored metadata in the data dictionary that matches the target metadata, the memory of the data dictionary is further detected to see if it meets the storage condition for storing the target metadata. If the memory of the data dictionary can meet the storage condition for storing the target metadata, it means that the remaining memory space of the data dictionary is larger than the required memory for storing the target metadata, and there is no need to release the occupied memory of the data dictionary. The target metadata can be directly stored in the data dictionary; if the memory of the data dictionary does not meet the storage condition for storing the target metadata, it means that the remaining memory space of the data dictionary is smaller than the required memory for storing the target metadata, and the occupied memory of the data dictionary needs to be released before storing the target metadata. Through the technical solution of this embodiment, in response to the mechanism of not deleting the stored metadata with a reference count of zero, data storage of the target metadata is achieved according to different situations, improving the access efficiency of the data dictionary.
[0086] Embodiment III
[0087] Figure 4 FIG. is a schematic structural diagram of a data dictionary management device for a database provided in Embodiment III of the present invention. This embodiment is applicable to the data dictionary management of a database. The data dictionary management device of this database can be implemented in the form of hardware and / or software, and the data dictionary management device of this database can be configured in any electronic device with network communication and computing capabilities. As Figure 4 shown, the device includes:
[0088] A count modification module, configured to, for the stored metadata in the data dictionary, if indexing is performed based on the stored metadata, increase the reference count of the stored metadata by a preset value, and if the indexing based on the stored metadata ends, decrease the reference count of the stored metadata by a preset value;
[0089] A data retention module, configured to retain the stored metadata in the data dictionary if the reference count of the stored metadata is reduced to zero and there is no need to release the occupied memory of the data dictionary.
[0090] As an optional but non-limiting implementation, the method further includes:
[0091] When it is detected that there is no stored metadata in the data dictionary that matches the target metadata, detect whether the memory of the data dictionary meets the storage condition for storing the target metadata;
[0092] If it is satisfied, save the target metadata to the data dictionary as stored metadata;
[0093] If not satisfied, after releasing the occupied memory of the data dictionary, save the target metadata to the data dictionary as the stored metadata.
[0094] As an optional but non-limiting implementation, in the case where there is no stored metadata in the retrieval data dictionary that matches the target metadata, detect whether the memory of the data dictionary meets the storage condition for storing the target metadata, including:
[0095] In the case where there is no stored metadata in the retrieval data dictionary that matches the target metadata, determine the required memory for storing the target metadata;
[0096] Accumulate the required memory on the basis of the memory occupied by the stored metadata in the data dictionary to obtain the first memory;
[0097] Compare the first memory with the second memory; the second memory is the preset memory threshold of the data dictionary.
[0098] As an optional but non-limiting implementation, if satisfied, save the target metadata to the data dictionary as the stored metadata, including:
[0099] If it is determined that the first memory is less than the second memory, save the target metadata to the data dictionary.
[0100] As an optional but non-limiting implementation, if not satisfied, after releasing the occupied memory of the data dictionary, saving the target metadata to the data dictionary as the stored metadata further includes:
[0101] If it is determined that the first memory is greater than or equal to the second memory, determine that there is a need to release the occupied memory of the data dictionary;
[0102] Determine the metadata to be released from the stored metadata of the data dictionary, release the metadata to be released, and save the target metadata to the data dictionary.
[0103] As an optional but non-limiting implementation, determining the metadata to be released from the stored metadata of the data dictionary includes:
[0104] Traverse the reference counts of the stored metadata in sequence from the tail of the doubly linked list of the data dictionary;
[0105] If it is determined that the reference count is the first data, use the stored metadata corresponding to the first data as the data to be released;
[0106] The method further includes:
[0107] If it is determined that the reference count is the second data, move the stored metadata corresponding to the second data to the head of the doubly linked list; the reference count of the first data is 0, and the reference count of the second data is non-zero.
[0108] As an optional but non-limiting implementation, the method further includes:
[0109] If the target metadata is saved to the data dictionary, based on the memory occupied by the stored metadata before the target metadata is not saved in the data dictionary, accumulate the required memory for saving the target metadata to update the memory occupied by the stored metadata;
[0110] If there is a need to release the memory occupied by the data dictionary and the metadata to be released is released, based on the memory occupied by the stored metadata in the data dictionary, subtract the memory occupied by the metadata to be released to update the memory occupied by the stored metadata.
[0111] An embodiment of the present invention discloses a method for managing a data dictionary of a database. The method includes: for the stored metadata in the data dictionary, if indexing is performed based on the stored metadata, increase the reference count of the stored metadata by a preset value; if the indexing based on the stored metadata ends, reduce the reference count of the stored metadata by a preset value; if the reference count of the stored metadata is reduced to zero and there is no need to release the memory occupied by the data dictionary, retain the stored metadata in the data dictionary. The technical solution of the embodiment of the present invention, by implementing a reference count mechanism for metadata in the data dictionary, but when the reference count of the stored metadata is reduced to zero and the memory of the data dictionary is sufficient, instead of deleting the stored metadata with a zero reference count, the stored metadata is temporarily retained in the data dictionary, so as to reduce the database system scanning time and the memory application time of the data dictionary during subsequent access to the same stored metadata, effectively shortening the data dictionary response time, improving the access efficiency of the data dictionary, and at the same time avoiding waste of memory resources of the data dictionary and improving the resource utilization rate of the data dictionary.
[0112] The data dictionary management device of the database provided by the embodiment of the present invention can execute the data dictionary management method of any embodiment of the present invention, and has corresponding functional modules and beneficial effects for executing the method.
[0113] Embodiment 4
[0114] Figure 5FIG. 0 shows a schematic structural diagram of an electronic device 10 that can be used to implement an embodiment of the present invention. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or claimed herein.
[0115] As Figure 5 shown, the electronic device 10 includes at least one processor 11, and a memory communicatively connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc. The memory stores a computer program executable by the at least one processor. The processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 into the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0116] Multiple components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a magnetic disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc., which allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0117] The processor 11 can be various general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as the data dictionary management method of the database.
[0118] In some embodiments, the data dictionary management method of the database can be implemented as a computer program tangibly embodied in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed onto the electronic device 10 via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by the processor 11, one or more steps of the data dictionary management method of the database described above can be performed. Alternatively, in other embodiments, the processor 11 can be configured to execute the data dictionary management method of the database in any other suitable way (e.g., by means of firmware).
[0119] In particular, according to embodiments of the present invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of the present invention include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program including program code for performing the methods shown in the flowcharts. In such an embodiment, the computer program can be downloaded and installed from a network via communication unit 19, or installed from storage unit 18, or installed from ROM 12. When the computer program is executed by the processor 11, the above-described functions defined in the methods of the embodiments of the present invention are performed.
[0120] The various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuitry, integrated circuit systems, field programmable gate arrays (FPGA), application specific integrated circuits (ASIC), application specific standard products (ASSP), system-on-a-chip (SOC), complex programmable logic devices (CPLD), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include: implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, the programmable processor can be a dedicated or general-purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit the data and instructions to the storage system, the at least one input device, and the at least one output device.
[0121] A computer program for implementing the method of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general purpose computer, a special purpose computer, or other programmable data processing apparatus, such that the computer programs, when executed by the processor, cause the functions / operations specified in the flowchart and / or block diagram to be implemented. The computer program may be executed entirely on the machine, partly on the machine, as a stand-alone software package partly on the machine and partly on a remote machine, or entirely on the remote machine or server.
[0122] In the context of the present invention, a computer-readable storage medium may be a tangible medium that can contain or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. The computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. Alternatively, the computer-readable storage medium may be a machine-readable signal medium. More specific examples of the machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0123] In order to provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the electronic device. Other kinds of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0124] The systems and techniques described herein can be implemented in a computing system including backend components (e.g., as a data server), or a computing system including middleware components (e.g., an application server), or a computing system including frontend components (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described herein), or a computing system including any combination of such backend components, middleware components, or frontend components. The components of the system can be interconnected to each other by digital data communication in any form or medium (e.g., a communication network). Examples of communication networks include: local area network (LAN), wide area network (WAN), blockchain network, and the Internet.
[0125] A computing system can include a client and a server. The client and the server are generally remote from each other and typically interact through a communication network. The client-server relationship is created by computer programs running on respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or a cloud host, which is a host product in the cloud computing service system and solves the defects of difficult management and weak business scalability existing in traditional physical hosts and VPS services.
[0126] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps recited in the present invention can be executed in parallel, sequentially, or in a different order, as long as the desired results of the technical solution of the present invention can be achieved, and no limitation is imposed herein.
[0127] The above specific embodiments do not constitute a limitation on the protection scope of the present invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention shall be included within the protection scope of the present invention.
Claims
1. A method for managing a data dictionary of a database, characterized in that Including: For the stored metadata in the data dictionary, if indexing is based on the stored metadata, increase the reference count of the stored metadata by a preset value. If the indexing based on the stored metadata ends, decrease the reference count of the stored metadata by a preset value; If the reference count of the stored metadata is reduced to zero and there is no need to release the occupied memory of the data dictionary, retain the stored metadata in the data dictionary.
2. The method according to claim 1, wherein The method further includes: When there is no stored metadata in the data dictionary that matches the target metadata, detect whether the memory of the data dictionary meets the storage condition for storing the target metadata; If it meets the condition, save the target metadata to the data dictionary as stored metadata; If it does not meet the condition, after releasing the occupied memory of the data dictionary, save the target metadata to the data dictionary as stored metadata.
3. The method according to claim 2, wherein When there is no stored metadata in the data dictionary that matches the target metadata, detecting whether the memory of the data dictionary meets the storage condition for storing the target metadata includes: When there is no stored metadata in the data dictionary that matches the target metadata, determine the required memory for storing the target metadata; Accumulate the required memory on the basis of the memory occupied by the stored metadata in the data dictionary to obtain the first memory; Compare the first memory with the second memory; the second memory is the preset memory threshold of the data dictionary.
4. The method according to claim 3, wherein If it meets the condition, saving the target metadata to the data dictionary as stored metadata includes: If it is determined that the first memory is less than the second memory, save the target metadata to the data dictionary.
5. The method according to claim 3, characterized in that, If it does not meet the condition, after releasing the occupied memory of the data dictionary, saving the target metadata to the data dictionary as stored metadata further includes: If it is determined that the first memory is greater than or equal to the second memory, determine that there is a need to release the occupied memory of the data dictionary; Determine the metadata to be released from the stored metadata in the data dictionary, release the metadata to be released, and save the target metadata to the data dictionary.
6. The method according to claim 4, characterized in that, Determining the metadata to be released from the stored metadata in the data dictionary includes: Traverse the reference counts of the stored metadata in sequence from the tail of the doubly linked list in the data dictionary; If it is determined that the reference count is the first data, use the stored metadata corresponding to the first data as the data to be released; The method further includes: If it is determined that the reference count is the second data, move the stored metadata corresponding to the second data to the head of the doubly linked list; the reference count of the first data is 0, and the reference count of the second data is non-zero.
7. The method according to any one of claims 2-5, characterized in that The method further includes: If the target metadata is saved to the data dictionary, accumulate the required memory for saving the target metadata on the basis of the memory occupied by the stored metadata before the target metadata is not saved in the data dictionary, so as to update the memory occupied by the stored metadata; If there is a need to release the occupied memory of the data dictionary and release the metadata to be released, then, based on the occupied memory of the stored metadata in the data dictionary, subtract the occupied memory of the metadata to be released to update the occupied memory of the stored metadata.
8. A data dictionary management device for a database, characterized in that, Including: A count modification module, configured to, for the stored metadata in the data dictionary, if indexing is performed based on the stored metadata, increase the reference count of the stored metadata by a preset value, and if the indexing based on the stored metadata ends, decrease the reference count of the stored metadata by a preset value; A data retention module, configured to retain the stored metadata in the data dictionary if the reference count of the stored metadata is reduced to zero and there is no need to release the occupied memory of the data dictionary.
9. An electronic device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the data dictionary management method of the database as described in any one of claims 1-7.
10. A storage medium storing computer-executable instructions, characterized in that, The computer-executable instructions are used to execute the data dictionary management method of the database as described in any one of claims 1-7 when executed by a computer processor.
Citation Information
Patent Citations
Metadata management method, system, device and computer-readable storage medium
CN109213699A
Method and device for managing storage system, and computer program product
CN111475100A
Method and device for constructing metadata tag library
CN113360496A
Metadata access method and device, equipment and storage medium
CN116821058A
Data dictionary management method and device
CN117807097A