Method and system for implementing real-time query service based on SQL query statement
By generating an SQL execution plan that only targets query data rows, the problem of the traditional SQL query execution mode being too slow in real-time online services is solved, and faster response speed and higher query efficiency are achieved.
Patent Information
- Application Number
- CN202110220002.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-02-26
- Publication Date
- 2025-04-01
- Estimated Expiration
- 2041-02-26
AI Technical Summary
The traditional SQL query execution mode cannot meet the performance requirements in real-time online services because it is processed for full data, resulting in too slow calculation speed and inability to query data in real time.
By receiving request triplets sent by the client, the SQL query statement is parsed and the execution plan is generated for query data rows only, including table spelling operations, projection operations and window operations, and only query data rows are calculated, thereby real-time query service.
This method can provide query results with faster response speed, meet the performance requirements of real-time online services, reduce the calculation of full data, and improve query efficiency.
Smart Images

Figure CN112925801B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to a method and system for realizing real-time query service based on SQL query statements. Background Art
[0002] SQL query statements are the most widely used way to describe querying and processing data to obtain statistical results / calculation results. The execution logic of traditional SQL query statements can be summarized as follows:
[0003] 1. Parse the SQL query statement string and generate an execution plan;
[0004] 2. Verify the execution plan to verify that all data tables associated with the query exist in the database; and
[0005] 3. Run the execution plan, calculate and return the results.
[0006] However, the above execution mode is not suitable for the common needs in the field of AI and feature computing: that is, real-time calculation of query results in online services. The technical problems existing in the prior art are:
[0007] First, the traditional SQL query execution mode processes data in batches. One execution will calculate the entire amount of data in the data table related to the execution plan. However, real-time online services only need to obtain information related to the data row of interest. For example, only a single row of data in the data table needs to be calculated.
[0008] Secondly, since the traditional SQL query execution mode is performed on the entire data, the calculation speed of the traditional SQL query execution mode is too slow and cannot meet the performance requirements of real-time online services. It is difficult for real-time online services to use traditional SQL query execution engines to achieve real-time data query calculations. Summary of the invention
[0009] The purpose of the present invention is to provide a method and system for implementing real-time query services based on SQL query statements. More specifically, to provide an execution mode of SQL query statements that can meet the performance requirements of real-time online services with a faster response speed.
[0010] According to one or more aspects of the present invention, the present invention provides a method for implementing a real-time query service based on an SQL query statement, characterized in that the method comprises: receiving a request triple sent by a client; parsing the SQL query statement and generating an execution plan for executing the SQL query statement only for the query data row based on the query data row and the queried data table; running the execution plan to obtain a query result, and returning the query result to the client. The request triple comprises: an SQL query statement, a query data row, and an identifier of the queried data table.
[0011] In an exemplary embodiment according to the inventive concept, the execution plan may include a table-joining operation, a left table of the table-joining operation is the queried data table, and the table-joining operation is performed only on the queried data rows.
[0012] In an exemplary embodiment according to the inventive concept, the execution plan may further include a projection operation, the input of the projection operation is the queried data table, and the projection operation is performed only on the query data rows.
[0013] In an exemplary embodiment according to the inventive concept, the execution plan may further include a window operation, the input of the window operation is the queried data table, and the window operation is performed only on the queried data rows.
[0014] In an exemplary embodiment according to the inventive concept, the queried data table at least includes a predetermined request data table in a database.
[0015] In an exemplary embodiment according to the inventive concept, the method may further include: after the step of generating the execution plan, verifying the execution plan to verify that all data tables associated with the query exist in the database.
[0016] According to one or more aspects of the present invention, the present invention provides a system for implementing real-time query services based on SQL query statements, characterized in that the system includes: a receiving unit, receiving a request triplet sent by a client; an execution plan generating unit, parsing the SQL query statement and generating an execution plan for executing the SQL query statement only for the query data row based on the query data row and the queried data table; and an execution unit, running the execution plan to obtain a query result and returning the query result to the client, wherein the request triplet includes: an SQL query statement, a query data row, and an identifier of the queried data table.
[0017] In an exemplary embodiment according to the inventive concept, the system further includes: a verification unit, which verifies the execution plan to verify that all data tables associated with the query exist in the database.
[0018] Another aspect of the present invention provides a computer-readable storage medium storing instructions, wherein when the instructions are executed by at least one computing device, the at least one computing device is prompted to execute the method of implementing real-time query services based on SQL query statements as described above.
[0019] Another aspect of the present invention provides a system comprising at least one computing device and at least one storage device storing instructions, wherein the instructions, when executed by the at least one computing device, prompt the at least one computing device to execute the method for implementing real-time query services based on SQL query statements as described above.
[0020] According to one or more aspects of the present invention, a method and system for implementing real-time query services based on SQL query statements generates an execution plan for executing the SQL query statement only for the query data rows based on the query data rows and the queried data table. In this execution mode, since the execution plan only performs calculations / statistics on the query data rows instead of the entire data, the query results can be provided at a faster response speed. On the other hand, since information only related to the query data rows of interest is provided, the query results provided by the method and system can meet the performance requirements of real-time online services. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] These and / or other aspects and advantages of the present disclosure will become more clear and easier to understand from the following detailed description of the embodiments of the present disclosure in conjunction with the accompanying drawings, in which:
[0022] Figure 1 is a flowchart illustrating a method for implementing a real-time query service based on a SQL query statement according to an exemplary embodiment of the present disclosure;
[0023] Figure 2 It is a schematic diagram of an example of an execution plan generated based on a traditional SQL query statement;
[0024] Figure 3 is a schematic diagram of an example of a table puzzle operation according to an exemplary embodiment of the present disclosure;
[0025] Figure 4 is a schematic diagram of an example of a projection operation according to an exemplary embodiment of the present disclosure;
[0026] Figure 5 is a schematic diagram of an example of a window operation according to an exemplary embodiment of the present disclosure;
[0027] Figure 6 is a block diagram illustrating a system for implementing a real-time query service based on a SQL query statement according to an exemplary embodiment of the present disclosure; and
[0028] Figure 7is a diagram showing the use of an exemplary embodiment according to the present disclosure Figure 6 Schematic diagram of the environment in which the system implements real-time query services based on SQL query statements. DETAILED DESCRIPTION
[0029] Embodiments of the present invention are described in detail below with reference to the accompanying drawings. Examples of the embodiments are shown in the accompanying drawings, wherein the same reference numerals refer to the same components throughout. The embodiments will be described below with reference to the accompanying drawings in order to explain the present invention.
[0030] Figure 1 is a flowchart illustrating a method for implementing a real-time query service based on a SQL query statement according to an exemplary embodiment of the present disclosure.
[0031] Reference Figure 1 In step S10, a request triplet sent by a client is received, wherein the request triplet includes: an SQL query statement, a query data row, and an identifier of a queried data table.
[0032] In an example embodiment, the query data row may be the latest data row in the queried data table. For example, the queried data table may be a transaction record table, and the query data row may be the latest row generated in the transaction record table. Figures 3 to 5 Provide a detailed description.
[0033] In step S20, the SQL query statement is parsed and based on the query data row and the queried data table, an execution plan for executing the SQL query statement only for the query data row is generated. The execution plan includes a table splicing operation, a projection operation and a window operation. According to an example embodiment of the present invention, an execution plan for executing the SQL query statement only for the query data row can be referred to as an execution plan in a request mode. Specifically, in the description below, unless otherwise specified, a table splicing operation means a table splicing operation in a request mode, a projection operation means a projection operation in a request mode, and a window operation means a window operation in a request mode.
[0034] In step S30, the execution plan is run to obtain query results, and the query results are returned to the client.
[0035] For ease of description, the following scenario is assumed:
[0036] The client sends a query request to the server to query the number of distinct users in the same city within three days related to the query data row (e.g., distinct_count). The server executes the SQL query statement for the data row and returns the calculation result R. The pseudo code can have the following form:
[0037]
[0038] Among them, trade_table is the transaction record table, user_table is the user information table, user_id is the user identification code, user_name is the user name, city is the user's city, and time is the time when the transaction occurred.
[0039] It should be noted that the examples here are only for convenience of explanation and are not intended to limit the present invention.
[0040] Figure 2 The following is a schematic diagram of an example of an execution plan generated based on a traditional SQL query statement.
[0041] Reference Figure 2 ,In a traditional SQL query statement, the generated ,execution plan may include traditional window operations, traditional table ,splitting operations and traditional projection operations that are executed ,sequentially.
[0042] Specifically, in the window operation, the data row with serial number 90010 is inserted into the transaction record table TT, and the transaction records related to each transaction record within three days are counted, and the transaction records within three days for serial number 90010 are returned. The result is passed to the traditional table splicing operation to be performed later.
[0043] In the table joining operation, the transaction record table is the left table (corresponding to the Left join statement). According to the user_id in the transaction record table and the user information table, the table joining operation is performed on the two tables. The result with user_id, transaction time, user name, and city is obtained, and it is passed to the traditional projection operation to be performed later.
[0044] In the projection operation, the projection operation is performed on each transaction record. For example, the projection operation calculation of the unique count of user names in Beijing is performed on the serial number 90010, and the result is that the number of different users in the same city is 3 (that is, users C, A, and F), and the result is returned to the client.
[0045] It should be pointed out that the execution order of the execution plan generated for the traditional SQL query statement is only for defining the expected calculation result, and the calculation execution process can be changed arbitrarily according to the actual situation.
[0046] For convenience of illustration, Figure 2Only the table splicing operation and projection operation corresponding to the serial number 90010 are shown. Those skilled in the art will understand that in the execution result of the traditional SQL query statement, for each row in the transaction record table, there is a data (i.e., data column) representing the "number of different users in the same city within three days" of the current transaction row. However, the client does not pay attention to the data of "the number of different users in the same city within three days" of all rows in the transaction record table. In this usage scenario, because the client only needs the results related to the query data row (for example, the data row with the serial number of 90010 as the latest data row), the server only needs to return the data of "the number of different users in the same city within three days" of the data row with the serial number of 90010. In this case, the calculation for all rows in the transaction record table will result in a waste of computing resources, and therefore fail to meet the needs of high-performance online services.
[0047] In the actual execution process, because the traditional execution calculates all the data in the request data table each time, the overall performance overhead is too large. Therefore, the execution plan needs to be adapted to meet the needs of high-performance online services.
[0048] According to an exemplary embodiment of the present invention, among the data tables related to the SQL query statement, there is and only one data table that is used as a "request data table", and the other data tables are all non-request data tables. As an example, the request data table may be a data table frequently requested by the client. The request data table may be a data table in a database defined externally. For example, the request data table may be a data table defined when the database is formed. In other embodiments, a data table in the database may be selected as the request data table before the SQL query statement.
[0049] Continue to refer to the above example of "querying the number of different users in the same city within three days related to the query data row".
[0050] First follow Figure 1 Step S10 is shown as executing to receive a request triplet sent by the client, wherein the request triplet includes: an SQL query statement, a query data row, and an identifier of a transaction record table TT.
[0051] In step S20, the SQL query statement is parsed and based on the query data row and the queried data table, an execution plan for executing the SQL query statement only for the query data row is generated.
[0052] According to an exemplary embodiment of the present invention, in the request mode of generating an execution plan only for the query data row, the expected result is the same as the calculation result of the traditional execution mode, and the execution plan including the table splicing operation, the projection operation and the window operation is referenced as follows Figures 3 to 5Description of the adaptation.
[0053] Figure 3 is a schematic diagram of an example of a puzzle operation according to an exemplary embodiment of the present disclosure.
[0054] The left table of the table splicing operation is the queried data table, and the table splicing operation is performed only on the queried data row. In an embodiment, the queried data table includes at least a request data table and a non-request data table. If the left table of the table splicing operation is the request data table, the table splicing operation is performed only on the queried data row, and the request data table itself in the database is not operated and calculated.
[0055] Specifically, refer to Figure 3 As shown, the data row with serial number 90010 is the query data row, the transaction record table TT is the request data table, and the user information table UT is the non-request data table. In the table splicing operation, only the query data row including the serial number 90010 is spliced, thereby generating a single row of data including the serial number, user_id, transaction time, user name and city.
[0056] Figure 4 is a schematic diagram of an example of a projection operation according to an exemplary embodiment of the present disclosure.
[0057] The input of the projection operation is the queried data table, and the projection operation is performed only on the query data row. In an embodiment, the queried data table at least includes a request data table. If the input table of the projection operation is the request data table, the projection operation is performed only on the requested row, and no operation calculation is performed on the request data table itself in the database.
[0058] Specifically, refer to Figure 4 As shown, the data row with serial number 90010 is the query data row, and the table including serial number, user_id, transaction time, user name and city is the request data table. The projection operation (i.e., the number of different users in the same city, unique count calculation) is performed only for the data row with serial number 90010, and the result is that the number of different users in the same city is 3 (i.e., users C, A, and F).
[0059] Figure 5 is a diagram of an example of a window operation according to an exemplary embodiment of the present disclosure.
[0060] The input of the window operation is the queried data table, and the window operation is performed only on the query data row. In an embodiment, the queried data table includes at least a request data table. If the queried data table is a request data table, the window operation is performed only on a single row of the request, and the request data table data in the database will use the window condition to filter the window data of the row, and no other operation calculation will be performed.
[0061] Specifically, refer to Figure 5 As shown, the data row with serial number 90010 is the query data row, and the transaction record table is the request data table. The window operation is performed only on the data row with serial number 90010 (i.e., transactions within three days), and the result of transactions within three days for the query data row is obtained.
[0062] According to the above example, after completing the adaptation of the execution plan, refer to Figure 1 In step S30 shown in the figure, the execution plan is run to obtain the query result, and the query result is returned to the client. It should be noted that the execution order of the execution plan generated for the SQL query statement in the request mode is only for defining the expected calculation result, and the execution calculation process can be the same as or different from the execution order of the execution plan generated by the traditional SQL query statement according to the actual situation.
[0063] also, Figures 3 to 5 The request data table shown in does not include the query data row with serial number 90010, and the query data row with serial number 90010 is not counted in the returned query result. The above examples are only examples. According to actual needs, the query data row as the latest data row can be inserted into the queried data table (for example, the request data table) before or after the query. In addition, the query data row with serial number 90010 can be counted in the query result to obtain the same query result as the SQL query statement in the traditional mode; or, the query data row with serial number 90010 can be excluded as needed.
[0064] It should be noted that the examples here are only for convenience of explanation, and are not intended to limit the present invention. For example, the transaction record table may also include conventional bank flow content, such as transaction time, transaction location, currency type, amount, transfer-out account, transfer-in account, etc. The user information table may also include information such as age, occupation, total transaction amount in the past three months, and average transaction amount within a week. The features in the above user information table can be used as features for bank abnormal transaction detection, and used for prediction or judgment of anti-money laundering and anti-fraud. In such a usage scenario, the query of features in the user-related information table needs to meet the performance requirements of real-time online services, such as fast response speed and high query frequency. For each newly generated transaction record, a method for bank abnormal transaction detection can be executed, which requires obtaining information such as age, occupation, total transaction amount in the past three months, and average transaction amount within a week in the user information table, and constructing a user portrait with the above user information, so as to realize the judgment of abnormal transactions through a pre-trained machine learning model.
[0065] When using the adapted request mode, because the execution plan of the SQL query statement is only executed for the query data row, rather than for the entire table data, it may have a faster calculation speed and a shorter response time. Therefore, the features in the above user information table can be fed back to the client at a faster speed, thereby realizing real-time query service.
[0066] Figure 6 is a block diagram showing a system 10 for implementing a real-time query service based on a SQL query statement according to an exemplary embodiment of the present disclosure.
[0067] According to one or more aspects of the present invention, the present invention provides a system 10 for implementing real-time query services based on SQL query statements. The system 10 includes: a receiving unit 110 , an execution plan generating unit 120 and an executing unit 130 .
[0068] The receiving unit 110 is used to receive a request triplet sent by a client. The request triplet includes: an SQL query statement, a query data row, and an identifier of a queried data table. The receiving unit 110 can be configured to perform a reference Figure 1 The method described in step S10 in , so redundant description is omitted here.
[0069] The execution plan generation unit 120 parses the SQL query statement and generates an execution plan for executing the SQL query statement only for the query data row based on the query data row and the queried data table. The execution plan generation unit 120 may be configured to execute the reference Figure 1 The method described in step S20 in , so redundant description is omitted here.
[0070] The execution unit 130 executes the execution plan to obtain the query result, and returns the query result to the client. The execution unit 130 can be configured to execute the reference Figure 1 The method described in step S30 in , so redundant description is omitted here.
[0071] Figure 7 is a diagram showing the use of an exemplary embodiment according to the present disclosure Figure 6 Schematic diagram of the environment in which the system implements real-time query services based on SQL query statements.
[0072] Figure 7 The environment shown may include a system 10 for implementing a real-time query service based on a SQL query statement, a network 20, and user terminals 30 and 40. Here, it should be noted that the user terminal 30 and the user terminal 40 may refer to a plurality of terminals, respectively.
[0073] Among them, the system 10 can be the above reference Figure 4The described system 10 can be deployed on an entity's IT facility or on an entity's IT facility that specifically provides real-time query services based on SQL query statements. The network 20 may include routing, switches, servers, cloud servers, etc. The user terminals 30 and 40 may include any type of electronic product that can access the network 20, such as a cellular phone, a smart phone, a tablet computer, a wearable device, a personal digital assistant (PDA), a portable multimedia player (PMP), a digital camera, a music player, a portable game console, a navigation system, a digital television, a 3D television, a personal computer (PC), a home appliance, a laptop computer, etc. The user terminals 30 and 40 may also be desktop computers, workstation computers, or servers. The user terminals 30 and 40 access the network 20 and / or the server in the network 20 through an Ethernet protocol, a protocol based on an Internet protocol (IP), a protocol based on a transmission control protocol (TCP), a protocol based on a user datagram protocol (UDP), a protocol based on a remote direct memory access (RDMA) protocol, and a protocol based on an NVMe-oF protocol, or a combination thereof.
[0074] Furthermore, the user terminal 30 may be a client and upload data to the network 20 and / or a server in the network 20 to form a table in the database. The user terminal 40 may issue an SQL query request to the network 20 and / or a server in the network 20, and then the network 20 and / or a server in the network 20 forwards the SQL query request to the system 10, and / or the user terminal 40 may directly issue an SQL query request to the system 10.
[0075] After receiving the SQL query request, the system 10 can issue an SQL query request based on the table stored in the database of the system 10, the network 20 and / or the server in the network 20 and the user terminal 40, and Figure 1 , Figures 3 to 5 The method described above gives the query result. The system 10 can display the query result to the user terminal 40 through the network 20 directly or through a third party. The method for implementing real-time query service based on SQL query statements can be the same as that described above. Figure 1 , Figures 3 to 5 The described method is the same and will not be repeated here.
[0076] The various units included in the system 10 for implementing real-time query services based on SQL query statements according to an exemplary embodiment of the present invention can be configured as software, hardware, firmware, or any combination of the above items to perform specific functions. For example, these devices may correspond to dedicated integrated circuits, pure software codes, or modules combining software and hardware. In addition, one or more functions implemented by these devices may also be uniformly executed by components in physical entity devices (e.g., processors, clients, or servers, etc.).
[0077] In an exemplary embodiment of the present invention, a computing device for implementing a real-time query service based on an SQL query statement is also proposed. The computing device can be deployed in a server or a client, or can be deployed on a node device in a distributed network environment. In addition, the computing device can be a PC, a tablet device, a personal digital assistant, a smart phone, a web application, or other device capable of executing the above instruction set.
[0078] Here, the computing device is not necessarily a single computing device, but may be any device or circuit collection that can execute the above instructions (or instruction sets) individually or jointly. The computing device may also be part of an integrated control system or system manager, or may be configured as a portable electronic device that is interconnected with a local or remote (e.g., via wireless transmission) interface.
[0079] In the computing device, the processor may include a central processing unit (CPU), a graphics processing unit (GPU), a programmable logic device, a dedicated processor system, a microcontroller or a microprocessor. By way of example and not limitation, the processor may also include an analog processor, a digital processor, a microprocessor, a multi-core processor, a processor array, a network processor, etc.
[0080] According to the exemplary embodiment of the present invention, some operations described in the method for implementing real-time query service based on SQL query statements can be implemented by software, some operations can be implemented by hardware, and in addition, these operations can also be implemented by a combination of software and hardware.
[0081] The processor may execute instructions or codes stored in one of the storage components, which may also store data. Instructions and data may also be sent and received over a network via a network interface device, which may employ any known transmission protocol.
[0082] The storage component may be integrated with the processor, for example, RAM or flash memory is arranged within an integrated circuit microprocessor, etc. In addition, the storage component may include a separate device, such as an external disk drive, a storage array, or any other storage device that can be used by a database system. The storage component and the processor may be operatively coupled, or may communicate with each other, such as through an I / O port, a network connection, etc., so that the processor can read files stored in the storage component.
[0083] In addition, the computing device may also include a video display (such as a liquid crystal display) and a user interaction interface (such as a keyboard, a mouse, a touch input device, etc.) All components of the computing device may be connected to each other via a bus and / or a network.
[0084] The operations involved in the method for implementing real-time query services based on SQL query statements according to an exemplary embodiment of the present invention can be described as various interconnected or coupled function blocks or function diagrams. However, these function blocks or function diagrams can be equally integrated into a single logical device or operated according to non-exact boundaries.
[0085] For example, as described above, a system is provided comprising at least one computing device and at least one storage device storing instructions, wherein the instructions, when executed by the at least one computing device, cause the at least one computing device to perform as described in reference to Figure 1 , Figures 3 to 5 Describe the steps.
[0086] That is, the above-mentioned computing device can be used to execute Figure 1 , Figures 3 to 5 The method for implementing real-time query service based on SQL query statement is shown in FIG. Figure 1 , Figures 3 to 5 The method for implementing real-time query service based on SQL query statements has been introduced in detail, and the present invention will not repeat this part.
[0087] Optionally, the system and computing device for implementing real-time query services based on SQL query statements can be integrated into the server of the platform (e.g., a bank). In addition, it can also be integrated into a third-party server to provide users with real-time query results, which are then displayed to users by the platform (e.g., an API interface provided by a third-party server).
[0088] It should be understood that the method for implementing a real-time query service based on an SQL query statement according to an exemplary embodiment of the present invention can be implemented by a program recorded on a computer-readable medium. For example, according to an exemplary embodiment of the present invention, a computer-readable medium storing instructions can be provided, wherein when the instructions are executed by at least one computing device, the at least one computing device is prompted to execute as described in reference to Figure 1 , Figures 3 to 5 Describe the steps.
[0089] The computer program in the computer-readable medium can be run in an environment deployed in a computer device such as a client, a host, an agent device, a server, etc. It should be noted that the computer program can also be used to perform additional steps in addition to the above steps or perform more specific processing when performing the above steps. The contents of these additional steps and further processing have been referred to in Figure 1 , Figures 3 to 5 The description has been made, and will not be repeated here to avoid repetition.
[0090] It should be noted that the system for implementing real-time query services based on SQL query statements according to an exemplary embodiment of the present invention can completely rely on the operation of computer programs to implement corresponding functions, that is, each device corresponds to each step in the functional architecture of the computer program, so that the entire system is called through a special software package (for example, lib library) to implement the corresponding functions.
[0091] On the other hand, the various units included in the system for implementing real-time query services based on SQL query statements according to an exemplary embodiment of the present invention may also be implemented by hardware, software, firmware, middleware, microcode, or any combination thereof. When implemented by software, firmware, middleware, or microcode, the program code or code segment for performing the corresponding operation may be stored in a computer-readable medium such as a storage medium, so that the processor can perform the corresponding operation by reading and running the corresponding program code or code segment.
[0092] The above describes various exemplary embodiments of the present invention, it should be understood that the above description is only exemplary, not exhaustive, and the present invention is not limited to the disclosed exemplary embodiments. Without departing from the scope and spirit of the present invention, many modifications and changes are obvious to those of ordinary skill in the art. Therefore, the scope of protection of the present invention should be based on the scope of the claims.
Claims
1. A method for implementing real-time query service based on SQL query statements, characterized in that: The method includes: Receive a request triplet sent by a client; wherein the request triplet includes: an SQL query statement, a query data row, and an identifier of a queried data table, the query data row is a data row in a queried data table, the queried data table includes a non-request data table and a request data table, and the access frequency of the request data table is higher than the access frequency of the non-request data table; Parsing the SQL query statement and generating an execution plan for executing the SQL query statement only for the query data row based on the query data row and the queried data table; and Run the execution plan to obtain query results, and return the query results to the client. The execution plan includes a table splicing operation. If the left table of the table splicing operation is the request data table and the query data row is a data row of the request data table, the table splicing operation is only performed on the query data row to generate a corresponding single row of data.
2. The method according to claim 1, wherein: The execution plan also includes a projection operation, If the input of the projection operation is the request data table and the query data row is a data row of the request data table, the projection operation is performed only on the query data row.
3. The method according to claim 1, wherein: The execution plan also includes window operations, If the input of the window operation is the request data table and the query data row is a data row of the request data table, the window operation is performed only on the query data row.
4. The method according to any one of claims 1 to 3, wherein: The method further comprises: after the step of generating the execution plan, checking the execution plan to verify that all data tables associated with the query exist in the database.
5. A system for implementing real-time query services based on SQL query statements, characterized in that: The system includes: A receiving unit receives a request triplet sent by a client; wherein the request triplet includes: an SQL query statement, a query data row, and an identifier of a queried data table, the query data row is a data row in a queried data table, the queried data table includes a non-request data table and a request data table, and the access frequency of the request data table is higher than the access frequency of the non-request data table; an execution plan generating unit, which parses the SQL query statement and generates an execution plan for executing the SQL query statement only for the query data row based on the query data row and the queried data table; and An execution unit runs the execution plan to obtain a query result, and returns the query result to the client. The execution plan includes a table splicing operation. If the left table of the table splicing operation is the request data table and the query data row is a data row of the request data table, the table splicing operation is performed on the query data row to generate a corresponding single row of data.
6. The system according to claim 5, wherein: The execution plan also includes a projection operation, If the input of the projection operation is the request data table and the query data row is a data row of the request data table, the projection operation is performed only on the query data row.
7. The system according to claim 5, wherein: The execution plan also includes window operations, If the input of the window operation is the request data table and the query data row is a data row of the request data table, the window operation is performed only on the query data row.
8. The system according to any one of claims 5 to 7, wherein: The system further comprises: a verification unit, which verifies the execution plan to verify that all data tables associated with the query exist in the database.
9. A system comprising at least one computing device and at least one storage device storing instructions, wherein: When the instructions are executed by the at least one computing device, the at least one computing device is prompted to execute the method for implementing a real-time query service based on a SQL query statement as claimed in any one of claims 1 to 4.
10. A computer-readable storage medium storing instructions, wherein: When the instructions are executed by at least one computing device, the at least one computing device is prompted to execute the method for implementing real-time query services based on SQL query statements as claimed in any one of claims 1 to 4.
Citation Information
Patent Citations
Data query optimization method and device
CN107168977A