Database operation method and device
By constructing the corresponding relationship between metadata and entity objects and the second-level cache of entity objects and execution plans, the performance bottleneck and data inconsistency problems caused by external microservices in big data scenarios are solved, and data consistency and rapid recovery capabilities are achieved. promote.
Patent Information
- Application Number
- CN202410822271.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-24
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2044-06-24
AI Technical Summary
In big data scenarios, existing technologies face performance bottlenecks and data inconsistencies caused by external microservices when processing massive data, diverse data sources, and mixed queries of heterogeneous data, and lack the ability to quickly recover.
By constructing the corresponding relationship between metadata and entity objects and the second-level cache between entity objects and execution plans, local cache queries are implemented to avoid dependence on external services, ensure data consistency, and perform local cache queries when metadata changes. Updated to ensure fast recovery.
It effectively avoids external service performance bottlenecks, ensures data consistency and fast recovery capabilities, and improves the performance and availability of data services through local cache queries.
Smart Images

Figure CN118690068A
Abstract
Description
Technical Field
[0001] Embodiments of the present disclosure relate to the field of computer technology, and in particular to a database operation method and device. Background Art
[0002] At present, big data has gradually become one of the basic infrastructures for the production and development of various enterprises. For data services in BI (Business Intelligence) scenarios based on big data, it is often necessary to deal with massive data processing, diverse data sources, and mixed queries of heterogeneous data.
[0003] Currently, it is usually implemented by directly relying on external microservices, or the data service itself holds the corresponding metadata cache. However, external microservices may cause data service performance bottlenecks, and caches are prone to data inconsistency risks and lack of rapid recovery capabilities when data changes. Summary of the invention
[0004] The embodiments of the present disclosure provide a database operation method and device.
[0005] In a first aspect, an embodiment of the present disclosure provides a database operation method, the method comprising: in response to receiving a database operation request, determining metadata contained in the database operation request; searching for an entity object corresponding to the metadata from a pre-built first cache, wherein the first cache is used to store the correspondence between the metadata and the entity object, and the entity object is obtained based on encapsulation of entities corresponding to the metadata with a dependency relationship; searching for an execution plan corresponding to the entity object from a pre-built second cache, wherein the second cache is used to store the correspondence between the entity object and the execution plan; and executing the corresponding database operation according to the execution plan.
[0006] In a second aspect, an embodiment of the present disclosure provides a database operation device, which includes: a determination unit, configured to determine metadata contained in a database operation request in response to receiving the database operation request; a search unit, configured to search for an entity object corresponding to the metadata from a pre-built first cache, wherein the first cache is used to store the correspondence between the metadata and the entity object, and the entity object is obtained based on encapsulation of entities corresponding to the metadata with a dependency relationship; search for an execution plan corresponding to the entity object from a pre-built second cache, wherein the second cache is used to store the correspondence between the entity object and the execution plan; and an execution unit, configured to execute the corresponding database operation according to the execution plan.
[0007] In a third aspect, an embodiment of the present disclosure provides an electronic device, comprising: one or more processors; a storage device for storing one or more programs; when the one or more programs are executed by one or more processors, the one or more processors implement the method described in any implementation manner in the first aspect.
[0008] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable medium having a computer program stored thereon, which, when executed by a processor, implements the method described in any implementation manner in the first aspect.
[0009] The database operation method and device provided by the embodiments of the present disclosure change the data structure of metadata flowing between systems, so that metadata is no longer circulated as a single entity, but related entities are encapsulated into an entity object for circulation, thereby ensuring data consistency. At the same time, the secondary cache that homogeneously builds and maintains the corresponding relationship between metadata and entity objects, as well as the corresponding relationship between entity objects and execution plans, can avoid dependence on external services through local cache queries, and avoid external services becoming performance bottlenecks. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] Other features, objects and advantages of the present disclosure will become more apparent from the detailed description of non-limiting embodiments made with reference to the following drawings:
[0011] Figure 1 is an exemplary system architecture diagram in which an embodiment of the present disclosure may be applied;
[0012] Figure 2 is a flowchart of an embodiment of a database operation method according to the present disclosure;
[0013] Figure 3a is a schematic diagram of data flow in the database operation method according to the present disclosure;
[0014] Figure 3b-3c It is a schematic diagram of the existing data flow method;
[0015] Figure 4 is a schematic diagram of initializing the first cache;
[0016] Figure 5 It is a schematic diagram of data recovery operation;
[0017] Figure 6 is a structural schematic diagram of an embodiment of a database operation device according to the present disclosure;
[0018] Figure 7 It is a schematic diagram of the structure of an electronic device suitable for implementing the embodiments of the present disclosure. DETAILED DESCRIPTION
[0019] The present disclosure is further described in detail below in conjunction with the accompanying drawings and embodiments. It is understood that the specific embodiments described herein are only used to explain the relevant invention, rather than to limit the invention. It is also necessary to explain that, for ease of description, only the parts related to the relevant invention are shown in the accompanying drawings.
[0020] It should be noted that in the technical solution of the present invention, the data collection / collection, update, analysis, use, transmission, storage and other aspects involved are in compliance with the provisions of relevant laws and regulations, are used for legal and reasonable purposes, are not shared, disclosed or sold outside of these legal uses, and are subject to supervision and management by national regulatory authorities. Necessary measures should be taken to selectively block the use or access of data to prevent illegal access to such data, ensure that persons with access to data comply with the provisions of relevant laws and regulations, and ensure data security. In addition, once the data is no longer needed, the risk should be minimized by limiting or even prohibiting data collection and / or deleting the data.
[0021] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present disclosure may be combined with each other. The present disclosure will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0022] Figure 1 An exemplary architecture 100 is shown to which an embodiment of a database operating method or a database operating apparatus of the present disclosure can be applied.
[0023] like Figure 1 As shown, the system architecture 100 may include a data service end 101, an external service end 102, and a terminal device 103. The data service end 101, the external service end 102, and the terminal device 103 may be connected to each other through various connection types such as wired or wireless communication links or optical fiber cables.
[0024] The data server 101 can provide data support services for users, mainly used for storing, processing and analyzing data, etc., to meet various database operation requirements of users. A layer of metadata center can be abstracted in the data server 101 to implement functions such as cache construction and cache version management. The external server 102 can provide the data server 101 with various metadata required for database operations.
[0025] Various client applications can be installed on the terminal device 103. For example, browser applications, search applications, database applications, etc. The terminal device 103 can be hardware or software. When the terminal device 103 is hardware, it can be various electronic devices, including but not limited to smart phones, tablet computers, e-book readers, laptop computers, desktop computers, etc. When the terminal device 103 is software, it can be installed in the electronic devices listed above. It can be implemented as multiple software or software modules (for example, multiple software or software modules for providing distributed services), or it can be implemented as a single software or software module. No specific limitation is made here.
[0026] The data service end 101 and the external service end 102 can be hardware or software. When the data service end 101 and the external service end 102 are hardware, they can be implemented as a distributed server cluster consisting of multiple servers, or as a single server. When the data service end 101 and the external service end 102 are software, they can be implemented as multiple software or software modules (for example, multiple software or software modules for providing distributed services), or they can be implemented as a single software or software module. No specific limitation is made here.
[0027] It should be noted that the database operation method provided in the embodiments of the present disclosure is generally executed by the data service end 101 , and accordingly, the database operation device is generally disposed in the data service end 101 .
[0028] It should be understood that Figure 1 The number of data service terminals, external service terminals and terminal devices in the embodiment is only for illustration. Any number of data service terminals, external service terminals and terminal devices may be provided according to implementation requirements.
[0029] Continue to refer Figure 2 , which shows a process 200 of an embodiment of a database operation method according to the present disclosure. The database operation method comprises the following steps:
[0030] Step 201: In response to receiving a database operation request, determine metadata included in the database operation request.
[0031] In this embodiment, the database operation request can be used to request to perform various database operations on the database, including but not limited to data reading, writing, updating, modifying or deleting.
[0032] Metadata is data about data, mainly used to describe various data attribute information. For example, taking the BI scenario as an example, the metadata in this scenario includes but is not limited to indicator definition metadata, dimension definition metadata, and indicator implementation metadata.
[0033] Among them, indicator definition metadata is usually used to describe the Chinese and English names of indicators and the calculation caliber, etc. For example, "transaction order amount" means "the order amount that has been paid and excluding the specified type of amount".
[0034] Dimension definition metadata is usually used to describe the Chinese and English names of dimensions and dimension value information. For example, the specific dimension value of "province" is "Hebei" instead of "Hebei Province".
[0035] Metric implementation metadata is usually used to represent the specific information of the metric execution layer. For example, which engine's database table supports the query of this metric, which can be used as a decision-making basis for data service dependency.
[0036] Specifically, the user can send a database operation request through the terminal device used according to actual needs. After receiving the database operation request, the metadata included in the database operation request can be determined through various existing metadata analysis methods (such as indicator dependency analysis, etc.).
[0037] Step 202: Search for the entity object corresponding to the metadata from the pre-built first cache.
[0038] In this embodiment, the entity object can be obtained by encapsulating entities corresponding to metadata with dependencies. The entities corresponding to the metadata can be regarded as descriptions of the metadata in a database, such as a table in a database. Entities corresponding to different metadata may have data dependencies, and these entities with dependencies can be encapsulated into one entity object.
[0039] The first cache can be used to locally cache the correspondence between metadata and entity objects. Specifically, the correspondence between metadata and entity objects can be pre-set according to actual business scenarios, and the first cache can be pre-built.
[0040] Step 203: Search the execution plan corresponding to the entity object from the pre-built second cache.
[0041] In this embodiment, the execution plan may be a specific execution method and steps for the database operation. The second cache may locally cache the correspondence between the entity object and the execution plan. Specifically, the correspondence between the entity object and the execution plan may be pre-set according to the actual business scenario, and the second cache may be pre-built.
[0042] Step 204: Execute corresponding database operations according to the execution plan.
[0043] In this embodiment, after the execution plan is obtained, the database operation can be performed according to the steps indicated by the execution plan, thereby completing the response to the database operation request.
[0044] The method provided by the above embodiment of the present disclosure stores the metadata required for database operations in a local cache, thereby avoiding performance bottlenecks caused by reliance on external services. At the same time, according to the correlation between metadata implementations, the relevant metadata entities are integrated into an entity object, and a secondary cache is constructed based on the entity object, which can ensure the data consistency of database operations.
[0045] In some optional implementations of this embodiment, in response to receiving a metadata change message from a database, the first cache and the second cache are updated accordingly.
[0046] The metadata change message may indicate that a metadata change event exists. After receiving the metadata change message, the first cache and the second cache may be updated accordingly to ensure that the latest metadata is cached.
[0047] Optionally, metadata change messages can be received through a message queue (MQ). In this case, messages can be stored and transmitted between different modules or systems (such as between the above-mentioned execution subject and external services) through a message queue, which helps to improve the high availability of data services.
[0048] Optionally, in response to receiving a metadata change message from a database, a new entity object from the database is pulled according to the metadata change message, and the second cache is incrementally updated using the new entity object, and in response to determining that the second cache update is complete, the first cache is incrementally updated.
[0049] Specifically, the metadata change message may indicate that there is changed metadata, so that the encapsulated entity object corresponding to the entity with changed metadata, i.e., the new entity object, may be pulled from the dependent external service according to the metadata change message, and then the second cache may be incrementally updated using the obtained new entity object. After determining that the second cache has been updated, the first cache may be incrementally updated accordingly according to the second cache.
[0050] Optionally, in response to determining that the second cache update is completed, a new entity object is pulled from the database, and metadata corresponding to the new entity object is analyzed, and the first cache is incrementally updated using the metadata corresponding to the new entity object.
[0051] Specifically, after the second cache is updated, the entity objects with changes may be first pulled from the second cache, and then metadata corresponding to these entity objects may be analyzed, thereby using the metadata obtained by the analysis to perform corresponding incremental updates on the first cache.
[0052] Since cache changes do not take effect immediately, there may be a risk of data inconsistency if data is pulled when the second cache update is not complete. Therefore, updating the first cache after the second cache update is complete helps ensure data consistency.
[0053] Optionally, the first cache and the second cache may also be updated in full at a scheduled time.
[0054] Since incremental updates themselves have certain risks of data inconsistency, etc., combining them with scheduled full updates can eliminate the potential risks of incremental updates.
[0055] In some optional implementations of this embodiment, version information of the second cache may be set, and the second cache and its corresponding version information may be persisted.
[0056] The version information can be used to record the second cache at different time points. The representation of the version information can be flexibly set. At the same time, the second cache and its version information can be persistently stored so that when problems such as data inconsistency occur, the data service can be quickly restored by pulling a specific version of the cache data.
[0057] Optionally, in response to detecting a data failure, at least one of the following data recovery operations is performed: using a storage snapshot of the second cache as a new second cache, and restoring specified metadata to a target version.
[0058] Among them, data failures may include various problems such as data inconsistency. The specified metadata may be determined according to the actual application scenario. The target version may also be flexibly set according to actual needs, such as the target version may be the most recent correct version.
[0059] By using the storage snapshot of the second cache in a timely manner, or restoring specific metadata to the correct version, the overall availability of the data service can be quickly guaranteed, which helps to improve the stability of the data service.
[0060] Optionally, a metadata center can be abstracted (such as Figure 1 As shown) to realize the storage and other functions of the above-mentioned second cache, which can be flexibly designed according to actual application requirements.
[0061] like Figure 3aAs shown, it shows a schematic diagram of the data flow in the database operation method of the present invention. External services can provide various types of metadata such as indicator definitions and dimension definitions. The metadata center can hold the above-mentioned second cache for the data service end to pull and use according to demand. When the metadata changes, the external service can notify the metadata center through the message queue to pull the new entity object to update the second cache. After the second cache is updated, the metadata center can send a cache ready notification to the data service end, so that the data service end pulls and parses the metadata from the metadata center to update the first cache. At the same time, the data service end can change the routing logic of querying metadata from relying on external services to relying on local cache.
[0062] like Figure 3b-3c As shown in FIG, a schematic diagram of the existing data flow method is given. Figure 3b As shown in the figure, the routing logic of data services usually directly depends on external services. In this way, when there are too many metadata dependencies, the availability of data services is more likely to be affected by a single external service. For example, many external services are based on centralized storage such as databases, so when the service scale grows to a certain level, it is difficult to improve performance through optimization. For another example, the number of instances deployed by a single external service is usually small, and resources such as processors, memory, and thread pools are more likely to become performance bottlenecks. For another example, the performance of the external service itself may vary, and there is a risk of service downtime.
[0063] like Figure 3c As shown in Figure 1, some data services themselves hold caches of corresponding metadata. However, this approach usually builds passive caches according to metadata corresponding entities, which may not guarantee data consistency. Moreover, in the event of a failure, due to the lack of effective organization in this cache approach, it is difficult to quickly roll back to a correct version, that is, the ability to quickly recover is poor.
[0064] By comparison Figure 3a-3c It can be seen that the method provided by the above-mentioned embodiment of the present disclosure fundamentally changes the data structure of metadata circulation, so as to solve the data consistency risk problem and data service performance bottleneck problem existing in the prior art. Specifically, metadata is no longer circulated according to a single entity, but the related entities are encapsulated into an entity object for operation to ensure transaction consistency. In addition, by abstracting a layer of metadata center to hold the cache of entity objects, when the metadata changes, the data service end can be notified in time to update the local cache. At the same time, the metadata center can also maintain the version information of the entity object, so that it can quickly roll back to the correct version in the event of a data failure, ensuring the rapid recovery capability of the data service. And obviously, the data service no longer relies on external services, but builds a local cache by pulling entity objects, so that the overall horizontal expansion can be easily achieved by expanding the instance.
[0065] Continue to refer Figure 4 , which shows a schematic diagram of initializing the first cache. Figure 4 As shown, after the database system is started, you can first obtain the metadata types to be loaded, such as a list of IDs (identifiers) of all types of metadata. Then you can traverse each metadata type in turn. For each type, you can first obtain all metadata IDs of this type from the metadata center, and then split them into pieces according to needs (such as paging processing, etc.), and then you can get the metadata details of each piece from the metadata center. The metadata details can correspond to the above-mentioned execution plan. After that, you can build a second cache of entity objects corresponding to all metadata of this type and the corresponding execution plan, and then build a first cache of entity objects of this type and the corresponding metadata. After the initialization is completed, the local cache of the data server takes effect and can provide various data services.
[0066] Among them, in the process of obtaining metadata ID and metadata details, a waiting or retry mechanism can be adopted according to the actual situation to ensure overall stability. In addition, when metadata changes, the metadata center can notify the data server to update the local cache through broadcasting and other means.
[0067] Reference below Figure 5 , which shows a schematic diagram of data recovery operation. Figure 5 As shown, after receiving the metadata change message, the metadata center can pull the entity object of the metadata from the external service and generate the version information of the second cache according to each update date. At the same time, backup and historical version persistent storage can be performed to record different version information and caches at different time nodes.
[0068] After the second cache is updated, the metadata center may send a cache readiness notification to the data server, and after receiving the cache readiness notification, the data server may pull the latest entity object and analyze the corresponding latest metadata to update the first cache.
[0069] When data inconsistency and other failures occur, if there is a problem with the metadata center itself, you can directly switch to the cache snapshot held locally on the data server. At this time, the data in the cache snapshot may contain errors or be a version from a long time ago, but this method can quickly ensure the availability of the overall data service.
[0070] If the metadata center is fine, but a certain entity object has a problem, you can choose to update the specified entity object to a correct version. If the metadata center is fine, and you cannot determine which metadata has a problem, or there are problems such as large-scale metadata inconsistencies, you can batch pull metadata at a specified time point to replace the local first cache.
[0071] Different data recovery operations can be used in different scenarios to ensure that data can be quickly recovered in the event of a data failure and to ensure the stability of data services.
[0072] Taking the query routing logic as an example, after receiving a database operation request, it usually includes stages such as protocol conversion, indicator dependency parsing, table search, execution plan construction, SQL (Structured Query Language) generation and SQL execution. Among them, the construction of the execution plan and the previous stages rely on metadata queries. The method provided by the above embodiment of the present disclosure changes the flow structure and caching method of metadata, etc., to ensure that the required metadata can be obtained through local caching, avoiding dependence on external services, so that when the user scale increases, it can be easily expanded horizontally by expanding the examples, avoiding the dependence on external services to form a performance bottleneck. At the same time, by saving stable snapshots of the local cache of metadata and other methods, combined with pulling historical versions of metadata, data can be quickly recovered in the event of data failure.
[0073] Further references Figure 6 As an implementation of the methods shown in the above figures, the present disclosure provides an embodiment of a database operation device. Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0074] like Figure 6 As shown, the database operation device 600 provided in this embodiment includes a determination unit 601, a search unit 602 and an execution unit 603. The determination unit 601 is configured to determine the metadata contained in the database operation request in response to receiving the database operation request; the search unit 602 is configured to search for the entity object corresponding to the metadata from the pre-built first cache, wherein the first cache is used to store the correspondence between the metadata and the entity object, and the entity object is obtained based on the encapsulation of the entity corresponding to the metadata with the dependency relationship; the execution plan corresponding to the entity object is searched from the pre-built second cache, wherein the second cache is used to store the correspondence between the entity object and the execution plan; the execution unit 603 is configured to execute the corresponding database operation according to the execution plan.
[0075] In some optional implementations of the present embodiment, the above-mentioned database operation device 600 also includes: an update unit (not shown in the figure) is configured to: in response to receiving a metadata change message from the database, pull a new entity object from the database according to the metadata change message, and use the new entity object to incrementally update the second cache; in response to determining that the update of the second cache is completed, incrementally update the first cache.
[0076] In some optional implementations of this embodiment, the above-mentioned database operation device 600 also includes: a storage unit (not shown in the figure) is configured to: set version information of the second cache; and persist the second cache and the version information.
[0077] In some optional implementations of this embodiment, the updating unit is further configured to: regularly update the first cache and the second cache in full.
[0078] In some optional implementations of this embodiment, the metadata change message is received through a message queue.
[0079] In some optional implementations of this embodiment, the above-mentioned update unit is further configured to: in response to determining that the second cache update is completed, pull the new entity object from the database, and analyze the metadata corresponding to the new entity object, and use the metadata corresponding to the new entity object to incrementally update the first cache.
[0080] In some optional implementations of this embodiment, the above-mentioned database operation device 600 also includes: a recovery unit (not shown in the figure) is configured to: in response to detecting a data failure, perform at least one of the following data recovery operations: use the storage snapshot of the second cache as a new second cache; restore the specified metadata to the target version.
[0081] The device provided by the above-mentioned embodiment of the present disclosure determines the metadata contained in the database operation request in response to receiving the database operation request through the determination unit; the search unit searches for the entity object corresponding to the metadata from the pre-built first cache, wherein the first cache is used to store the correspondence between the metadata and the entity object, and the entity object is obtained based on the entity encapsulation corresponding to the metadata with the dependency relationship; searches for the execution plan corresponding to the entity object from the pre-built second cache, wherein the second cache is used to store the correspondence between the entity object and the execution plan; the execution unit executes the corresponding database operation according to the execution plan. By changing the data structure of the metadata flowing between the systems, the metadata is no longer circulated as a single entity, but the related entities are encapsulated into an entity object for circulation, thereby ensuring data consistency. At the same time, isomorphically constructing and maintaining the corresponding relationship between the metadata and the entity object, as well as the corresponding relationship between the entity object and the execution plan, the secondary cache can avoid dependence on external services through local cache queries, and avoid external services from being called performance bottlenecks.
[0082] Reference below Figure 7 , which shows an electronic device (eg, Figure 1 A structural diagram of the data service end) 700. Figure 7The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0083] like Figure 7 As shown, the electronic device 700 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 701, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 702 or a program loaded from a storage device 708 into a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the electronic device 700 are also stored. The processing device 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.
[0084] Typically, the following devices may be connected to the I / O interface 705: an input device 706 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 707 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 708 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 709. The communication device 709 may allow the electronic device 700 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 7 The electronic device 700 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead. Figure 7 Each block shown in the figure may represent one device, or may represent multiple devices as required.
[0085] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device 709, or installed from a storage device 708, or installed from a ROM 702. When the computer program is executed by the processing device 701, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.
[0086] It should be noted that the computer-readable medium described in the embodiments of the present disclosure may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, 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 disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the embodiments of the present disclosure, the computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, device or device. In the embodiments of the present disclosure, the computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0087] The computer-readable medium may be included in the electronic device; or it may exist independently without being installed in the electronic device. The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device: in response to receiving a database operation request, determines the metadata included in the database operation request; searches for the entity object corresponding to the metadata from a pre-built first cache, wherein the first cache is used to store the correspondence between the metadata and the entity object, and the entity object is obtained based on the entity encapsulation corresponding to the metadata with a dependency relationship; searches for the execution plan corresponding to the entity object from a pre-built second cache, wherein the second cache is used to store the correspondence between the entity object and the execution plan; and executes the corresponding database operation according to the execution plan.
[0088] Computer program code for performing the operations of embodiments of the present disclosure may be written in one or more programming languages or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on a user's computer, partially on a user's computer, as a separate software package, partially on a user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0089] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0090] The units involved in the embodiments described in the present disclosure may be implemented by software or by hardware. The units described may also be provided in a processor, for example, may be described as: a processor including a determination unit, a search unit, and an execution unit. The names of these units do not constitute limitations on the units themselves in certain circumstances, for example, the determination unit may also be described as "a unit that determines metadata contained in a database operation request in response to receiving the database operation request".
[0091] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of the invention involved in the embodiments of the present disclosure is not limited to the technical solutions formed by a specific combination of the above-mentioned technical features, but should also cover other technical solutions formed by any combination of the above-mentioned technical features or their equivalent features without departing from the above-mentioned inventive concept. For example, the above-mentioned features are replaced with the technical features with similar functions disclosed in the embodiments of the present disclosure (but not limited to) to form a technical solution.
Claims
1. A database operation method, comprising: In response to receiving a database operation request, determining metadata included in the database operation request; Searching for an entity object corresponding to the metadata from a pre-built first cache, wherein the first cache is used to store a correspondence between the metadata and the entity object, and the entity object is obtained based on encapsulation of entities corresponding to the metadata that have a dependency relationship; Searching for an execution plan corresponding to the entity object from a pre-built second cache, wherein the second cache is used to store a corresponding relationship between the entity object and the execution plan; Execute corresponding database operations according to the execution plan.
2. The method according to claim 1, wherein: The method further comprises: In response to receiving a metadata change message from a database, pulling a new entity object from the database according to the metadata change message, and incrementally updating the second cache using the new entity object; In response to determining that the second cache update is complete, the first cache is incrementally updated.
3. The method according to claim 2, wherein: The method further comprises: Setting the version information of the second cache; The second cache and version information are persisted.
4. The method according to claim 2, wherein: The method further comprises: The first cache and the second cache are fully updated regularly.
5. The method according to claim 2, wherein: The metadata change message is received through a message queue.
6. The method according to claim 2, wherein: In response to determining that the update of the second cache is completed, incrementally updating the first cache includes: In response to determining that the second cache update is complete, a new entity object from the database is pulled, metadata corresponding to the new entity object is analyzed, and the first cache is incrementally updated using the metadata corresponding to the new entity object.
7. The method according to claim 3, wherein: The method further comprises: In response to detecting a data failure, performing at least one of the following data recovery operations: using the storage snapshot of the second cache as a new second cache; Restores the specified metadata to the target version.
8. A database operation device, wherein: The device comprises: a determining unit, configured to, in response to receiving a database operation request, determine metadata included in the database operation request; A search unit is configured to search for an entity object corresponding to the metadata from a pre-built first cache, wherein the first cache is used to store a correspondence between the metadata and the entity object, and the entity object is obtained based on encapsulation of entities corresponding to the metadata with a dependency relationship; and search for an execution plan corresponding to the entity object from a pre-built second cache, wherein the second cache is used to store a correspondence between the entity object and the execution plan; The execution unit is configured to execute corresponding database operations according to the execution plan.
9. An electronic device, comprising: one or more processors; a storage device having one or more programs stored thereon; When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 7.
10. A computer readable medium having a computer program stored thereon, wherein: When the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Getting dependency metadata using statement execution plans
CN102243646A
Executive plan search method, and executive plan storage method and apparatus
CN106897343A
WFS service-oriented space query result cache method
CN107622115A
Data processing method, device and equipment and storage medium
CN111506603A
Query processing method and device, database system, electronic equipment and storage medium
CN113076330A
