Data query method and device, electronic device and readable storage medium
Through the collaborative work of the first search engine and the second search engine, the active transaction ID is obtained by using the global transaction manager to realize cross-engine consistency query of OLTP and OLAP data, solving the global consistency problem during distributed data storage in the prior art, and improving the accuracy and consistency of data access.
Patent Information
- Application Number
- CN202211716599.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-29
- Publication Date
- 2025-08-22
- Estimated Expiration
- 2042-12-29
AI Technical Summary
In the prior art, OLTP and OLAP have problems in the process of service docking and use of OLTP and OLAP have high data access complexity, low data timeliness and consistency, and the data does not have global consistency in the distributed database.
Through the collaborative work of the first search engine and the second search engine, the SQL type is determined and parsed, a multi-version concurrent control prompt is generated, and the active transaction ID is obtained using the global transaction manager to realize data consistency query across the engine.
It solves the problem that there is no global consistency in data storage, improves the accuracy and consistency of data access, and reduces business complexity.
Smart Images

Figure CN116226275B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of database technology, and in particular to a data query method and device, an electronic device, and a readable storage medium. Background Art
[0002] Database and big data technologies are used to meet the business scenarios of online transaction processing (OLTP) and online analytical processing (OLAP), respectively. As the flexibility of business implementation increases, the data access process becomes more and more complex. When performing complex queries, it is necessary to ensure the transactional characteristics of data query and update. The current OLTP and OLAP have the following disadvantages in the process of business docking: when accessing data, different databases must be connected for different SQL types, which increases the complexity of the business and reduces the accuracy of judgment; the corresponding databases of OLTP and OLAP need to be synchronized, which reduces the timeliness and consistency of the data; under a distributed database, the data of the OLTP engine and the data of the OLAP engine cannot be seen by each other and do not have global consistency. The data processing methods in the existing technology have the technical problem of not having global consistency when data is distributedly stored. Summary of the Invention
[0003] The purpose of the embodiments of the present application is to provide a data query method and device, an electronic device, and a readable storage medium, which solve the technical problem of the lack of global consistency in distributed data storage in the prior art. The specific technical solution is as follows:
[0004] In a first aspect of the implementation of the present application, a data query method is first provided, the method comprising: a first search engine determining a type of structured query language (SQL); if the SQL is an SQL associated with the first search engine, the first search engine parses the SQL and queries target data corresponding to the parsed result from a data node; wherein the target data is used to represent global consistency data of a distributed database associated with the first search engine; if the SQL is an SQL associated with a second search engine, the first search engine generates a multi-version concurrency control hint; the first search engine forwards the SQL and the multi-version concurrency control hint to the second search engine; the second search engine obtains an active transaction ID based on a global transaction manager, and the second search engine forwards the active transaction ID and the multi-version concurrency control hint to the data node; the second search engine parses the SQL and queries target data corresponding to the parsed result from the data node; wherein the target data is used to represent global consistency data of the distributed database associated with the second search engine; the first search engine and the second search engine are search engines of different types.
[0005] In a second aspect of the implementation of the present application, a data query method is also provided, which is applied to a data node. The method includes: when a first search engine determines that the SQL is an SQL associated with the first search engine based on the type of the structured query language SQL, the data node determines target data based on the SQL sent by the first search engine; the data node sends the target data to the first search engine; wherein the target data is used to represent the global consistency data of the distributed database associated with the first search engine; when the first search engine determines that the SQL is an SQL associated with a second search engine based on the type of the structured query language SQL, the data node determines the target data based on the multi-version concurrency control hint sent by the second search engine, the active transaction ID obtained by the second search engine based on the global transaction manager, and the SQL sent by the second search engine; the data node sends the target data to the second search engine; wherein the first search engine and the second search engine are search engines of different types; wherein the target data is used to represent the global consistency data of the distributed database associated with the second search engine.
[0006] In a third aspect of the implementation of the present application, a data query device is also provided, the device comprising: a determination module, configured for a first search engine to determine a type of structured query language (SQL); a first processing module, configured for, when the SQL is SQL associated with the first search engine, the first search engine to parse the SQL and query target data corresponding to the parsing result from a data node; wherein the target data is used to represent global consistency data of a distributed database associated with the first search engine; a second processing module, configured for, when the SQL is SQL associated with a second search engine, the first search engine to generate a multi-version concurrency control hint; the first search engine forwards the SQL and the multi-version concurrency control hint to the second search engine; the second search engine obtains an active transaction ID based on a global transaction manager, and the second search engine forwards the active transaction ID and the multi-version concurrency control hint to the data node; the second search engine parses the SQL and queries target data corresponding to the parsing result from the data node; wherein the target data is used to represent global consistency data of the distributed database associated with the second search engine; the first search engine and the second search engine are search engines of different types.
[0007] In a fourth aspect of the implementation of the present application, a data query device is also provided, which is applied to a data node, and the device includes: a third processing module, which is used to determine the target data based on the SQL sent by the first search engine when the first search engine determines that the SQL is associated with the first search engine based on the type of the structured query language SQL; the data node sends the target data to the first search engine; wherein the target data is used to represent the global consistency data of the distributed database associated with the first search engine; a fourth processing module, which is used to determine the target data based on the multi-version concurrency control hint sent by the second search engine, the active transaction ID obtained by the second search engine based on the global transaction manager, and the SQL sent by the second search engine when the first search engine determines that the SQL is associated with the second search engine based on the type of the structured query language SQL; the data node sends the target data to the second search engine; wherein the first search engine and the second search engine are search engines of different types; wherein the target data is used to represent the global consistency data of the distributed database associated with the second search engine.
[0008] In the fifth aspect of the implementation of the present application, an electronic device is also provided, including a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; the memory is used to store computer programs; and the processor is used to implement the data query method described in the first aspect or the second aspect when executing the program stored in the memory.
[0009] In the sixth aspect of the implementation of the present application, a computer-readable storage medium is further provided, wherein the computer-readable storage medium stores instructions, which, when executed on a computer, enable the computer to execute the data query method described in the first or second aspect above.
[0010] The data query method and device provided in the embodiments of the present application determine the type of structured query language SQL through a first search engine; when the SQL is SQL associated with the first search engine, the first search engine parses the SQL and queries target data corresponding to the parsed result from a data node; wherein the target data is used to represent the global consistency data of the distributed database associated with the first search engine; when the SQL is SQL associated with a second search engine, the first search engine generates a multi-version concurrency control hint; the first search engine forwards the SQL and the multi-version concurrency control hint to the second search engine; the second search engine obtains an active transaction ID based on a global transaction manager, and forwards the active transaction ID and the multi-version concurrency control hint to the data node; the second search engine parses the SQL and queries target data corresponding to the parsed result from the data node; wherein the target data is used to represent the global consistency data of the distributed database associated with the second search engine; the first search engine and the second search engine are search engines of different types; that is, global consistency data is obtained based on the active transaction ID obtained from the global transaction manager, thereby solving the technical problem in the prior art of lack of global consistency when data is distributedly stored. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art.
[0012] Figure 1 This is one of the flow charts of the data query method in the embodiment of this application;
[0013] Figure 2 This is a flowchart of a first exemplary method for querying data in an embodiment of the present application;
[0014] Figure 3 This is a flow chart of a second exemplary method for querying data in an embodiment of the present application;
[0015] Figure 4 This is the second flow chart of the data query method in the embodiment of this application;
[0016] Figure 5 This is a flowchart of a third exemplary method for querying data in an embodiment of the present application;
[0017] Figure 6This is a flowchart of a fourth exemplary method for querying data in an embodiment of the present application;
[0018] Figure 7 This is the third flow chart of the data query method in the embodiment of this application;
[0019] Figure 8 This is the fourth flow chart of the data query method in the embodiment of this application;
[0020] Figure 9 This is the fifth flow chart of the data query method in the embodiment of this application;
[0021] Figure 10 This is the sixth flow chart of the data query method in the embodiment of this application;
[0022] Figure 11 This is one of the structural diagrams of the data query device in the embodiment of the present application;
[0023] Figure 12 This is the second structural diagram of the data query device in the embodiment of the present application;
[0024] Figure 13 This is the third structural diagram of the data query device in the embodiment of the present application;
[0025] Figure 14 This is the fourth structural diagram of the data query device in the embodiment of the present application;
[0026] Figure 15 This is the fifth structural diagram of the data query device in the embodiment of the present application;
[0027] Figure 16 This is the sixth structural diagram of the data query device in the embodiment of the present application;
[0028] Figure 17 This is a schematic diagram of the structure of an electronic device in an embodiment of the present application. DETAILED DESCRIPTION
[0029] To make the purpose, technical solutions, and advantages of the embodiments of this application more clear, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0030] In the following description, the suffixes such as "module" and "unit" used to represent elements are only used to facilitate the description of this application and have no specific meaning. Therefore, "module" and "component" can be used interchangeably.
[0031] The following will describe the technical solution in the embodiment of the present application in conjunction with the accompanying drawings in the embodiment of the present application. The embodiment of the present application provides a data query method, such as Figure 1 As shown, the method includes the following steps:
[0032] Step 102: The first search engine determines the type of structured query language SQL;
[0033] It should be noted that the first search engine is used to represent a search engine that interacts with the terminal for information. The first search engine is an external interface under multiple search engines. The first search engine can be an OLTP search engine or an OLAP search engine.
[0034] Step 104: If the SQL is associated with the first search engine, the first search engine parses the SQL and queries the data node for target data corresponding to the parsed result; wherein the target data is used to represent the globally consistent data of the distributed database associated with the first search engine;
[0035] Among them, it should be noted that OLAP is the main application of data warehouse systems, mainly for decision makers and senior managers, supports complex analytical operations, focuses on decision support, and provides intuitive and easy-to-understand query results; OLAP is a type of software technology that enables analysts, managers or executives to access information quickly, consistently and interactively from multiple angles, thereby gaining a deeper understanding of the data; OLTP is the main application of traditional relational databases, oriented to operators and low-level managers, and is mainly used for basic and daily transaction processing, such as banking transactions.
[0036] Step 106: When the SQL is associated with the second search engine, the first search engine generates a multi-version concurrency control hint; the first search engine forwards the SQL and the multi-version concurrency control hint to the second search engine; the second search engine obtains the active transaction ID based on the global transaction manager, and the second search engine forwards the active transaction ID and the multi-version concurrency control hint to the data node; the second search engine parses the SQL and queries the data node for target data corresponding to the parsing result; wherein the target data is used to represent the global consistency data of the distributed database associated with the second search engine; the first search engine and the second search engine are different types of search engines.
[0037] It should be noted that, in the first example, when the SQL is a complex query SQL and the first search engine is an OLTP search engine, Figure 2As shown, since the search engine used to process the SQL is an OLAP search engine, the OLTP search engine generates a multi-version concurrency control hint and forwards the multi-version concurrency control hint (MVCC hint) and the complex query SQL to the OLAP search engine. The OLAP search engine obtains the active transaction ID based on the global transaction manager (GTM). The OLAP search engine forwards the active transaction ID and the multi-version concurrency control hint to the data node. The OLAP search engine parses the complex query SQL and queries the target data corresponding to the parsing result from the data node.
[0038] The search engine used to process the SQL is determined based on the type of SQL. In the second example, Figure 3 As shown, when processing OLTP and / or OLAP transactions, if the SQL is an online transaction processing SQL and the first search engine is an OLTP search engine, since the search engine used to process the online transaction processing SQL is the OLTP search engine, the OLTP search engine parses the online transaction processing SQL and queries the target data corresponding to the parsed result from the corresponding data node. If the SQL is a complex query SQL and the first search engine is an OLTP search engine, since the search engine used to process the SQL is the OLAP search engine, the OLTP search engine forwards the complex query SQL to the OLAP search engine. The OLAP search engine obtains the active transaction ID based on the GTM, parses the complex query SQL, and queries the target data corresponding to the parsed result from the corresponding data node.
[0039] Through steps 102 to 106 of the embodiment of the present application, the first search engine determines the type of structured query language SQL; if the SQL is associated with the first search engine, the first search engine parses the SQL and queries the data node for target data corresponding to the parsed result; wherein the target data is used to represent the global consistency data of the distributed database associated with the first search engine; if the SQL is associated with the second search engine, the first search engine generates a multi-version concurrency control hint; the first search engine forwards the SQL and the multi-version concurrency control hint to the second search engine; the second search engine obtains the active transaction ID based on the global transaction manager, and forwards the active transaction ID and the multi-version concurrency control hint to the data node; the second search engine parses the SQL and queries the data node for target data corresponding to the parsed result; wherein the target data is used to represent the global consistency data of the distributed database associated with the second search engine; the first search engine and the second search engine are different types of search engines; that is, global consistency data is obtained based on the active transaction ID obtained from the global transaction manager, thereby solving the technical problem of the lack of global consistency when data is distributedly stored in the prior art.
[0040] In an optional implementation manner of the embodiment of the present application, the data query method provided in the embodiment of the present application is applied to the query of data within a transaction, such as Figure 4 Shown, including:
[0041] Step 402: The first search engine determines the user identification number ID and SQL type of the transaction, and sends the user ID to the data node;
[0042] It should be noted that when the data query method provided in the embodiment of the present application is applied to the query of data within a transaction, the data updated by the first search engine is visible to the query of the second search engine, that is, the data within the transaction is consistent; the user ID is used to identify the transaction; at the beginning of the transaction, the first search engine determines the user identity identification number ID of the transaction and sends it to the data node.
[0043] Step 404: If the SQL is associated with the first search engine, the first search engine parses the SQL and queries the data node for target data corresponding to the parsed result; the target data refers to the globally consistent data in the distributed database associated with the first search engine at a first moment; the first moment refers to the moment when the user ID is generated;
[0044] It should be noted that the data node associates the SQL in the transaction with the issued user ID, and obtains the data snapshot at the first moment according to the user ID, that is, the globally consistent data of the distributed database associated with the first search engine at the first moment.
[0045] Step 406: When the SQL is associated with the second search engine, the first search engine generates a multi-version concurrency control hint; the first search engine forwards the SQL and the multi-version concurrency control hint to the second search engine; the second search engine obtains the active transaction ID based on the global transaction manager, and the second search engine forwards the active transaction ID and the multi-version concurrency control hint to the data node; the second search engine parses the SQL and queries the target data corresponding to the parsing result from the data node; wherein the target data refers to the globally consistent data of the distributed database associated with the second search engine at the first moment; the first search engine and the second search engine are different types of search engines.
[0046] It should be noted that, in the third example, when the SQL is a complex query SQL and the first search engine is an OLTP search engine, Figure 5 As shown, since the search engine used to process the SQL is an OLAP search engine, the OLTP search engine generates a user ID "session id" and a multi-version concurrency control hint, the OLTP search engine sends the user ID to the data node DB, the OLTP search engine forwards the multi-version concurrency control hint and the complex query SQL to the OLAP search engine, the OLAP search engine obtains the active transaction ID based on the global transaction manager, the OLAP search engine forwards the active transaction ID and the multi-version concurrency control hint to the data node, the OLAP search engine parses the complex query SQL and queries the target data corresponding to the parsing result from the data node, wherein the target data refers to the data node associating the complex query SQL with the user ID "session id", and obtaining a data snapshot at the first moment according to the user ID "session id", that is, the global consistency data of the distributed database associated with the first search engine at the moment when the "session id" is generated.
[0047] In the fourth example, the process in which the OLTP update statement within the transaction is visible to the OLAP search engine, such as Figure 6As shown, when the SQL is a complex query SQL and the first search engine is an OLTP search engine, since the search engine used to process the SQL is an OLAP search engine, after the client establishes a link with the OLTP search engine, the OLTP search engine generates a user ID and sends the user ID "session id" to the data node DB. After the transaction is started (Start Transaction), the OLTP search engine generates an "MVCC hint" and "session id" and forwards the "session id" to the DB. The "MVCC hint" and the complex query SQL are forwarded to the OLAP search engine, and the OLAP search engine parses the complex query SQL, successfully completes the transaction commit, and queries the target data corresponding to the parsing result from the DB. Based on the "session id", the DB returns a data snapshot of the same transaction to the OLAP search engine, so that the statements updated by OLTP in the transaction are visible to the OLAP search engine.
[0048] It can be seen that the data query method provided in the embodiment of the present application uses the user ID used to identify the transaction to make the same transaction data snapshot visible across different search engines, that is, the data updated by the first search engine in the transaction is visible to the second search engine query, thereby ensuring data consistency within the transaction.
[0049] The data query method provided in the embodiment of the present application is as follows: Figure 7 Shown, including:
[0050] Step 702: If the SQL is the SQL associated with the first search engine, the first search engine receives the target data returned by the data node and sends the target data to a terminal corresponding to the first search engine;
[0051] It should be noted that the terminal refers to a client associated with the first search engine.
[0052] Step 704: In the case that the SQL is the SQL associated with the second search engine, the first search engine receives the target data returned by the data node, and sends the target data to the terminal through the second search engine.
[0053] It can be seen that the data query method provided in the embodiment of the present application can implement SQL query based on the first search engine obtaining SQL from the client and sending the target data returned by the data node to the client.
[0054] The present application embodiment provides a data query method, which is applied to a data node, such as Figure 8 Shown, including:
[0055] Step 802: When the first search engine determines, based on the type of the structured query language SQL, that the SQL is associated with the first search engine, the data node determines target data based on the SQL sent by the first search engine; the data node sends the target data to the first search engine; wherein the target data is used to represent globally consistent data of the distributed database associated with the first search engine;
[0056] Step 804: When the first search engine determines that the SQL is associated with the second search engine based on the type of the structured query language SQL, the data node determines the target data based on the multi-version concurrency control hint sent by the second search engine, the active transaction ID obtained by the second search engine based on the global transaction manager, and the SQL sent by the second search engine; the data node sends the target data to the second search engine; wherein the first search engine and the second search engine are search engines of different types; the target data is used to represent the global consistency data of the distributed database associated with the second search engine.
[0057] It should be noted that the data node obtains local and global consistency data snapshots based on the multi-version concurrency control prompt sent by the second search engine, the active transaction ID obtained by the second search engine based on the global transaction manager, and the SQL sent by the second search engine, according to the active transaction ID list and MVCC function.
[0058] It can be seen that the data query method data node provided in the embodiment of the present application can determine the global consistency data snapshot based on the active transaction ID list and the MVCC function to achieve global consistency of the data.
[0059] The data query method provided in the embodiment of the present application is applied to a data node, such as Figure 9 As shown, in the case of queries applied to data within a transaction, including:
[0060] Step 902: When the first search engine determines, based on the type of the structured query language SQL, that the SQL is associated with the first search engine, the data node determines target data based on the user identification number ID of the transaction determined by the first search engine and the SQL; the data node sends the target data to the first search engine; the target data refers to globally consistent data in the distributed database associated with the first search engine at a first moment; the first moment refers to the moment when the first search engine generates the user ID;
[0061] It should be noted that the data node associates the SQL in the transaction with the issued user ID, and obtains the data snapshot at the first moment according to the user ID, that is, the global consistency data of the distributed database associated with the first search engine at the first moment.
[0062] Step 904: When the first search engine determines that the SQL is associated with the second search engine based on the type of the structured query language SQL, the data node determines the target data based on the user identity identification number ID of the transaction determined by the first search engine, the multi-version concurrency control prompt sent by the second search engine, the active transaction ID obtained by the second search engine based on the global transaction manager, and the SQL sent by the second search engine; the data node sends the target data to the second search engine; wherein the target data refers to the globally consistent data of the distributed database associated with the second search engine at a first moment; the first moment refers to the moment when the first search engine generates the user ID; and the first search engine and the second search engine are different types of search engines.
[0063] It should be noted that, in the third example above, when the SQL is a complex query SQL and the first search engine is an OLTP search engine, Figure 5 As shown, since the search engine used to process the SQL is an OLAP search engine, the data node DB associates the complex query SQL with the user ID "sessionid" based on the user ID sent by the OLTP search engine, the active transaction ID and multi-version concurrency control prompt sent by the OLAP search engine, and the complex query SQL parsed by the OLAP search engine, and obtains the data snapshot at the first moment according to the user ID "sessionid", that is, the global consistency data of the distributed database associated with the first search engine at the moment when the "sessionid" is generated.
[0064] It can be seen that the data query method data node provided by the embodiment of the present application can establish an association relationship between SQL and user ID to determine the global consistency data snapshot of the distributed database associated with the first search engine at the time when the user ID is generated, thereby achieving global consistency of data.
[0065] In an optional implementation manner of the embodiment of the present application, the data query method provided by the embodiment of the present application is as follows: Figure 10 As shown, it may further include:
[0066] Step 1002: When the first search engine determines that the SQL is associated with the first search engine based on the type of the structured query language SQL, the data node sends the target data to a terminal corresponding to the first search engine through the first search engine;
[0067] Step 1004: When the first search engine determines that the SQL is associated with the second search engine based on the type of the structured query language SQL, the data node sends the target data to the terminal through the second search engine and the first search engine.
[0068] It should be noted that the data node may return globally consistent data to the user terminal based on the first search engine and the second search engine.
[0069] It can be seen that the data query method provided in the embodiment of the present application can obtain globally consistent data based on the active transaction ID obtained from the global transaction manager, thereby solving the technical problem in the prior art that data does not have global consistency when stored in a distributed manner.
[0070] The present application embodiment provides a data query device, such as Figure 11 As shown, the device includes:
[0071] Determining module 1102, configured for the first search engine to determine the type of structured query language SQL;
[0072] A first processing module 1004 is configured to, if the SQL is associated with the first search engine, parse the SQL and query the data node for target data corresponding to the parsed result; wherein the target data is used to represent globally consistent data of the distributed database associated with the first search engine;
[0073] The second processing module 1106 is configured to: when the SQL is associated with the second search engine, generate a multi-version concurrency control hint by the first search engine; forward the SQL and the multi-version concurrency control hint to the second search engine; obtain the active transaction ID based on the global transaction manager, and forward the active transaction ID and the multi-version concurrency control hint to the data node; parse the SQL and query the data node for target data corresponding to the parsing result; the target data is used to represent the global consistency data of the distributed database associated with the second search engine; the first search engine and the second search engine are different types of search engines.
[0074] In a data query device provided by an embodiment of the present application, a first search engine determines a type of structured query language (SQL) through a determination module; a first processing module parses the SQL and queries target data corresponding to the parsed result from a data node when the SQL is associated with the first search engine; wherein the target data is used to represent global consistency data of a distributed database associated with the first search engine; a second processing module generates a multi-version concurrency control hint when the SQL is associated with a second search engine; the first search engine forwards the SQL and the multi-version concurrency control hint to the second search engine; the second search engine obtains an active transaction ID based on a global transaction manager, and forwards the active transaction ID and the multi-version concurrency control hint to the data node; the second search engine parses the SQL and queries target data corresponding to the parsed result from the data node; wherein the target data is used to represent global consistency data of a distributed database associated with the second search engine; the first search engine and the second search engine are different types of search engines; that is, global consistency data is obtained based on the active transaction ID obtained from the global transaction manager, thereby solving the technical problem of the lack of global consistency when data is distributedly stored in the prior art.
[0075] The data query device provided in the embodiment of the present application is applied to query data within a transaction, such as Figure 12 As shown, the device includes:
[0076] The third processing module 1202 is used for the first search engine to determine the user identification number ID and SQL type of the transaction, and send the user ID to the data node;
[0077] The fourth processing module 1204 is configured to, if the SQL is associated with the first search engine, parse the SQL and query the data node for target data corresponding to the parsed result; wherein the target data refers to globally consistent data in the distributed database associated with the first search engine at a first moment; and the first moment refers to the moment when the user ID is generated.
[0078] The fifth processing module 1206 is configured to cause the first search engine to generate a multi-version concurrency control hint when the SQL is associated with the second search engine; the first search engine forwards the SQL and the multi-version concurrency control hint to the second search engine; the second search engine obtains an active transaction ID based on the global transaction manager, and forwards the active transaction ID and the multi-version concurrency control hint to the data node; the second search engine parses the SQL and queries the data node for target data corresponding to the parsed result; the target data refers to the globally consistent data of the distributed database associated with the second search engine at the first moment; the first search engine and the second search engine are different types of search engines.
[0079] The data query device provided in the embodiment of the present application is as follows: Figure 13 As shown, the device includes:
[0080] The sixth processing module 1302 is configured to, when the SQL is the SQL associated with the first search engine, cause the first search engine to receive the target data returned by the data node and send the target data to a terminal corresponding to the first search engine;
[0081] The seventh processing module 1304 is configured to, when the SQL is the SQL associated with the second search engine, cause the first search engine to receive the target data returned by the data node and send the target data to the terminal through the second search engine.
[0082] The embodiment of the present application provides a data query device, which is applied to a data node, such as Figure 14 As shown, the device includes:
[0083] An eighth processing module 1402 is configured to, when the first search engine determines based on the type of the structured query language SQL that the SQL is associated with the first search engine, cause the data node to determine target data based on the SQL sent by the first search engine; and send the target data to the first search engine; wherein the target data is used to represent globally consistent data of the distributed database associated with the first search engine.
[0084] A ninth processing module 1404 is configured to: when the first search engine determines based on the type of structured query language SQL that the SQL is associated with the second search engine, the data node determines target data based on the multi-version concurrency control hint sent by the second search engine, the active transaction ID obtained by the second search engine based on the global transaction manager, and the SQL sent by the second search engine; the data node sends the target data to the second search engine; wherein the first search engine and the second search engine are search engines of different types; and wherein the target data is used to represent global consistency data of the distributed database associated with the second search engine.
[0085] The embodiment of the present application provides a data query device, which is applied to a data node, such as Figure 15 As shown, when the device is applied to query data within a transaction, it includes:
[0086] A tenth processing module 1502 is configured to, when the first search engine determines based on the type of the structured query language SQL that the SQL is associated with the first search engine, cause the data node to determine target data based on the user identification number (ID) of the transaction determined by the first search engine and the SQL; and send the target data to the first search engine; wherein the target data refers to globally consistent data in the distributed database associated with the first search engine at a first moment; and the first moment refers to the moment when the first search engine generates the user ID.
[0087] The eleventh processing module 1504 is configured to, when the first search engine determines based on the type of structured query language SQL that the SQL is associated with the second search engine, cause the data node to determine target data based on the user identity identification number ID of the transaction determined by the first search engine, the multi-version concurrency control hint sent by the second search engine, the active transaction ID obtained by the second search engine based on the global transaction manager, and the SQL sent by the second search engine; the data node to send the target data to the second search engine; wherein the target data refers to the globally consistent data of the distributed database associated with the second search engine at a first moment; the first moment refers to the moment when the first search engine generates the user ID; and the first search engine and the second search engine are search engines of different types.
[0088] The embodiment of the present application provides a data query device, which is applied to a data node, such as Figure 16 As shown, the device includes:
[0089] The twelfth processing module 1602 is configured to, when the first search engine determines based on the type of the structured query language SQL that the SQL is associated with the first search engine, cause the data node to send the target data to a terminal corresponding to the first search engine through the first search engine;
[0090] The thirteenth processing module 1604 is configured to, when the first search engine determines that the SQL is associated with the second search engine based on the type of the structured query language SQL, cause the data node to send the target data to the terminal through the second search engine and the first search engine.
[0091] The present application also provides an electronic device, such as Figure 17As shown, it includes a processor 1701, a communication interface 1702, a memory 1703 and a communication bus 1704, wherein the processor 1701, the communication interface 1702, and the memory 1703 communicate with each other through the communication bus 1704.
[0092] Memory 1703, used for storing computer programs;
[0093] Processor 1701 is used to execute the program stored in memory 1703 to implement Figure 1 or Figure 8 The method steps in Figure 1 or Figure 8 The method and steps are the same as in , and will not be repeated here.
[0094] The communication bus mentioned in the above terminal can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 17 Only one thick line is used in the diagram, but this does not mean that there is only one bus or one type of bus.
[0095] The communication interface is used for communication between the above terminal and other devices.
[0096] The memory may include random access memory (RAM) or non-volatile memory, such as at least one disk storage. Alternatively, the memory may be at least one storage device located away from the processor.
[0097] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, and discrete hardware components.
[0098] In another embodiment provided by the present application, a computer-readable storage medium is also provided, in which instructions are stored. When the computer-readable storage medium is run on a computer, the computer executes the data query method described in any of the above embodiments.
[0099] In another embodiment provided by the present application, a computer program product including instructions is also provided, which, when executed on a computer, enables the computer to execute the data query method described in any one of the above embodiments.
[0100] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) method. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrations. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)).
[0101] It should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or device comprising the element.
[0102] Each embodiment in this specification is described in a related manner. Similar portions between the embodiments can be referenced to each other. Each embodiment focuses on the differences from other embodiments. In particular, the system embodiments are described briefly because they are generally similar to the method embodiments. For related portions, reference can be made to the description of the method embodiments.
[0103] The above description is only a preferred embodiment of the present application and is not intended to limit the scope of protection of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application are included in the scope of protection of the present application.
Claims
1. A data query method, characterized in that: include: The first search engine determines the type of structured query language SQL; In a case where the SQL is the SQL associated with the first search engine, the first search engine parses the SQL and queries the data node for target data corresponding to the parsing result; wherein the target data is used to represent the global consistency data of the distributed database associated with the first search engine; In a case where the SQL is associated with a second search engine, the first search engine generates a multi-version concurrency control hint; the first search engine forwards the SQL and the multi-version concurrency control hint to the second search engine; the second search engine obtains an active transaction ID based on a global transaction manager, and the second search engine forwards the active transaction ID and the multi-version concurrency control hint to the data node; the second search engine parses the SQL and queries the data node for the target data corresponding to the parsing result; wherein the target data is used to represent the global consistency data of the distributed database associated with the second search engine; the first search engine and the second search engine are different types of search engines.
2. The query method according to claim 1, characterized in that: Queries applied to data within a transaction include: The first search engine determines the user identification number ID of the transaction and the type of the SQL, and sends the user ID to the data node; In a case where the SQL is SQL associated with the first search engine, the first search engine parses the SQL and queries the data node for the target data corresponding to the parsed result; wherein the target data refers to globally consistent data in the distributed database associated with the first search engine at a first moment; and the first moment refers to the moment when the user ID is generated; In a case where the SQL is associated with the second search engine, the first search engine generates the multi-version concurrency control hint; the first search engine forwards the SQL and the multi-version concurrency control hint to the second search engine; the second search engine obtains the active transaction ID based on the global transaction manager, and the second search engine forwards the active transaction ID and the multi-version concurrency control hint to the data node; the second search engine parses the SQL and queries the data node for the target data corresponding to the parsing result; wherein the target data refers to the globally consistent data of the distributed database associated with the second search engine at the first moment; the first search engine and the second search engine are different types of search engines.
3. The query method according to claim 1, characterized in that: The query method further includes: In a case where the SQL is the SQL associated with the first search engine, the first search engine receives the target data returned by the data node, and sends the target data to a terminal corresponding to the first search engine; In a case where the SQL is an SQL associated with a second search engine, the first search engine receives the target data returned by the data node, and sends the target data to the terminal through the second search engine.
4. A data query method, applied to a data node, characterized in that: include: When the first search engine determines that the SQL is associated with the first search engine based on the type of the structured query language SQL, the data node determines target data based on the SQL sent by the first search engine; the data node sends the target data to the first search engine; wherein the target data is used to represent the global consistency data of the distributed database associated with the first search engine; In a case where the first search engine determines, based on the type of structured query language SQL, that the SQL is associated with the second search engine, the data node determines the target data based on the multi-version concurrency control hint sent by the second search engine, the active transaction ID obtained by the second search engine based on the global transaction manager, and the SQL sent by the second search engine; the data node sends the target data to the second search engine; wherein the first search engine and the second search engine are search engines of different types; and the target data is used to represent the global consistency data of the distributed database associated with the second search engine.
5. The query method according to claim 4, characterized in that: Queries applied to data within a transaction include: When the first search engine determines, based on the type of structured query language SQL, that the SQL is associated with the first search engine, the data node determines target data based on the user identification number ID of the transaction determined by the first search engine and the SQL; the data node sends the target data to the first search engine; wherein the target data refers to globally consistent data in the distributed database associated with the first search engine at a first moment; the first moment refers to the moment when the first search engine generates the user ID; In a case where the first search engine determines, based on the type of structured query language SQL, that the SQL is associated with the second search engine, the data node determines the target data based on the user identity identification number ID of the transaction determined by the first search engine, the multi-version concurrency control hint sent by the second search engine, the active transaction ID obtained by the second search engine based on the global transaction manager, and the SQL sent by the second search engine; the data node sends the target data to the second search engine; wherein the target data refers to the globally consistent data of the distributed database associated with the second search engine at the first moment; the first moment refers to the moment when the first search engine generates the user ID; and the first search engine and the second search engine are different types of search engines.
6. The query method according to claim 4, characterized in that: The query method further includes: When the first search engine determines that the SQL is an SQL associated with the first search engine based on the type of the structured query language SQL, the data node sends the target data to a terminal corresponding to the first search engine through the first search engine; When the first search engine determines that the SQL is SQL associated with the second search engine based on the type of structured query language SQL, the data node sends the target data to the terminal through the second search engine and the first search engine.
7. A data query device, characterized in that: include: A determination module, configured for the first search engine to determine a type of structured query language SQL; a first processing module configured to, when the SQL is the SQL associated with the first search engine, parse the SQL and query target data corresponding to the parsing result from a data node; wherein the target data is used to represent globally consistent data of a distributed database associated with the first search engine; The second processing module is configured to: when the SQL is an SQL associated with a second search engine, cause the first search engine to generate a multi-version concurrency control hint; the first search engine forwards the SQL and the multi-version concurrency control hint to the second search engine; the second search engine obtains an active transaction ID based on a global transaction manager, and forwards the active transaction ID and the multi-version concurrency control hint to the data node; the second search engine parses the SQL and queries the data node for the target data corresponding to the parsing result; wherein the target data is used to represent the global consistency data of the distributed database associated with the second search engine; and the first search engine and the second search engine are different types of search engines.
8. A data query device, applied to a data node, characterized in that: include: an eighth processing module, configured to, when the first search engine determines based on the type of structured query language SQL that the SQL is associated with the first search engine, cause the data node to determine target data based on the SQL sent by the first search engine; and send the target data to the first search engine; wherein the target data is used to represent globally consistent data of the distributed database associated with the first search engine; A ninth processing module is configured to, when the first search engine determines based on the type of structured query language SQL that the SQL is associated with the second search engine, cause the data node to determine the target data based on the multi-version concurrency control hint sent by the second search engine, the active transaction ID obtained by the second search engine based on the global transaction manager, and the SQL sent by the second search engine; the data node to send the target data to the second search engine; wherein the first search engine and the second search engine are search engines of different types; and wherein the target data is used to represent the global consistency data of the distributed database associated with the second search engine.
9. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; Memory for storing computer programs; A processor, configured to implement the method steps described in any one of claims 1-3 or 4-6 when executing a program stored in a memory.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method steps as described in any one of claims 1-3 or 4-6 are implemented.
Citation Information
Patent Citations
Transaction processing method, device and system in distributed database and storage medium
CN109522098A
Method, device and equipment for consistency of multiple copies read by database and medium
CN112527900A