Data query method, device, electronic device, storage medium and program product

By generating and applying filtering content statements and filtering condition statements, pushing down the filtering conditions and processing data according to columns, the problems of high memory usage and low performance in traditional SQL statement filtering methods are solved, and more efficient data query is achieved.

CN119782379APending Publication Date: 2025-04-08CETC JINCANG (BEIJING) TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411936799.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-25
Publication Date
2025-04-08

AI Technical Summary

Technical Problem

In big data processing scenarios, traditional SQL statement filtering methods require global sorting, resulting in high memory usage, reduced performance, and may even cause memory overflow errors.

Method used

By generating filter content statements and filter condition statements, filtering pre-stored SQL statements to be queried, pushing down the filter conditions into the subquery of the window function, avoiding processing a large amount of unnecessary data during the window function execution stage, and grouping them according to the columns to aggregate data processing.

Benefits of technology

It significantly reduces memory usage, improves query speed, avoids system performance degradation and memory overflow errors, and improves overall processing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119782379A_ABST
    Figure CN119782379A_ABST
Patent Text Reader

Abstract

The embodiment of the present application provides a data query method, device, electronic device, storage medium and program product. The method includes: in response to a query instruction, obtaining the filter field and filter condition carried by the query instruction; based on the filter field, generating a corresponding filter content statement according to a preset grammar rule; and based on the filter condition, generating a corresponding filter condition statement according to a preset grammar rule; the filter condition statement includes a subquery statement of a window function; using the filter content statement and the filter condition statement to filter the pre-stored SQL statement to be queried; matching the target SQL statement corresponding to the query instruction from the filtered SQL statement to be queried. The method is used to reduce memory usage and significantly improve query performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a data query method, device, electronic device, storage medium and program product. Background Art

[0002] In the current big data processing scenario, when faced with massive amounts of data, filtering SQL statements becomes particularly complex and resource-intensive. For example, when the SQL statement query requirement is to extract only the rows where ROW_NUMBER is 1 or 2 in each partition defined by the PARTITION BY clause, the traditional method requires global sorting of the entire data set first. This sorting process is not only time-consuming, but also requires a lot of memory resources, because all the data to be processed must be loaded into memory or rely on less efficient external sorting algorithms.

[0003] This global sorting approach may be feasible when processing small-scale data, but its drawbacks become apparent when the amount of data increases dramatically. Excessive memory usage may lead to system performance degradation and even cause memory overflow errors; while the external sorting algorithm significantly prolongs the query response time and reduces the overall processing efficiency. Therefore, how to optimize the query process, reduce memory usage, and increase query speed while ensuring the correctness of the query results is a key issue that needs to be solved in the current field of big data technology. Summary of the invention

[0004] The embodiments of the present application provide a data query method, device, electronic device, storage medium and program product to reduce memory usage and improve query speed.

[0005] In a first aspect, an embodiment of the present application provides a data query method, comprising:

[0006] In response to a query instruction, obtaining a filter field and a filter condition carried by the query instruction;

[0007] Based on the screening field, generating a corresponding screening content statement according to a preset grammar rule; and based on the screening condition, generating a corresponding screening condition statement according to a preset grammar rule; the screening condition statement includes a subquery statement of a window function;

[0008] Using the screening content statement and the screening condition statement, screening the pre-stored SQL statements to be queried;

[0009] The target SQL statement corresponding to the query instruction is matched from the filtered SQL statements to be queried.

[0010] In a possible implementation, the using the screening content statement and the screening condition statement to screen the pre-stored SQL statements to be queried includes:

[0011] Based on the time tag carried by the query instruction, filter out the SQL statements to be queried that match the time period corresponding to the time tag from the pre-stored SQL statements to be queried;

[0012] The filtering content statement and the filtering condition statement are used to filter out the filtered SQL statements to be queried from the SQL statements to be queried that match the time period corresponding to the time tag.

[0013] In a possible implementation, the using the screening content statement and the screening condition statement to screen the pre-stored SQL statements to be queried includes:

[0014] Filter out the SQL statements to be queried that meet the screening content statements from the SQL statements to be queried;

[0015] Using the grouping algorithm corresponding to the screening condition statement, the SQL statements to be queried that meet the screening content statement are grouped;

[0016] For each group of SQL statements to be queried, secondary screening is performed using the grouping screening conditions corresponding to the screening condition statements to obtain screened SQL statements to be queried.

[0017] In a possible implementation, the grouping algorithm includes a sorting algorithm;

[0018] The grouping screening condition includes an arrangement order screening condition;

[0019] After the SQL statements to be queried that meet the screening content statements are grouped by using a preset grouping algorithm, the method further includes:

[0020] Using the sorting algorithm, sort the SQL statements to be queried in each group;

[0021] The method of performing secondary screening on the SQL statements to be queried in each group by using the screening condition statement to obtain the screened SQL statements to be queried includes:

[0022] For each group of SQL statements to be queried, secondary screening is performed using the arrangement order screening condition to obtain screened SQL statements to be queried.

[0023] In a possible implementation, the screening condition includes one of a column structure, an aggregate function, and a window function.

[0024] In a possible implementation, generating a corresponding screening condition statement based on the screening condition according to a preset grammar rule includes:

[0025] Determine whether the screening condition is a single condition or a combined condition; the combined condition includes two or more conditions;

[0026] When the query condition is a single condition, generating a screening condition statement based on the query condition based on the condition structure in the preset grammar rule;

[0027] When the query condition is a combination condition, a screening condition statement based on the query condition is generated based on a condition tree structure in a preset grammar rule.

[0028] In a second aspect, an embodiment of the present application provides a data query device, including:

[0029] An acquisition module, configured to respond to a query instruction and acquire a filter field and a filter condition carried by the query instruction;

[0030] A generating module, configured to generate a corresponding filtering content statement based on the filtering field and according to a preset grammar rule; and to generate a corresponding filtering condition statement based on the filtering condition and according to a preset grammar rule;

[0031] A screening module, used to screen the pre-stored SQL statements to be queried by using the screening content statement and the screening condition statement;

[0032] The matching module is used to match the target SQL statement corresponding to the query instruction from the filtered SQL statements to be queried.

[0033] In a third aspect, an embodiment of the present application provides an electronic device, including: a memory, a processor;

[0034] The memory stores computer-executable instructions;

[0035] The processor executes the computer-executable instructions stored in the memory, so that the processor executes the above first aspect and / or various possible implementations of the first aspect.

[0036] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the first aspect above and / or various possible implementations of the first aspect.

[0037] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the above first aspect and / or various possible implementation methods of the first aspect.

[0038] The data query method, device, electronic device, storage medium and program product provided by the embodiments of the present application can push the filter condition to the subquery of the screening condition when identifying the SQL statement that meets the filter condition, thereby avoiding processing a large amount of unnecessary data during the window function execution stage. When executing the window function, grouping can be performed according to columns to ensure that data in the same group is processed together, so as to achieve processing only the data that meets the filter condition instead of processing all the data in the database. This strategy significantly reduces memory usage because there is no need to store and process all the data, and the query performance can be significantly improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0040] Figure 1 A schematic diagram of a scenario of the data query method provided in this application;

[0041] Figure 2 A flowchart of the data query method provided in this application;

[0042] Figure 3 A schematic diagram of the structure of the data query device provided by this application;

[0043] Figure 4 A schematic diagram of the structure of the electronic device provided in this application.

[0044] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION

[0045] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.

[0046] The data query method provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown, the terminal 102 communicates with the server 104 via the network.

[0047] For example, the data query method is applied to the terminal 102. After receiving the query instruction, the terminal 102 can obtain the filter field and filter condition carried by the query instruction; and further obtain the preset grammar rules from the data storage system of the server 104, and then generate the corresponding filter content statement based on the filter field according to the preset grammar rules; and generate the corresponding filter condition statement based on the filter condition according to the preset grammar rules; and use the filter content statement and the filter condition statement to filter the pre-stored SQL statements to be queried; finally, match the target SQL statement corresponding to the query instruction from the filtered SQL statements to be queried. Among them, the terminal 102 can be, but not limited to, various personal computers, laptops, smart phones, tablet computers, Internet of Things devices and portable wearable devices. The Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart car-mounted devices, etc. Portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. The server 104 can be implemented by an independent server or a server cluster composed of multiple servers. The terminal 102 and the server 104 can be directly or indirectly connected by wired or wireless communication, such as through a network connection.

[0048] For another example, the data query method is applied to the server 104. After receiving the query instruction, the terminal 102 can send the query instruction to the server 104. The server 104 obtains the filter field and filter condition carried by the query instruction based on the query instruction; and further obtains the preset grammar rule from the data storage system, and then generates the corresponding filter content statement based on the filter field according to the preset grammar rule; and generates the corresponding filter condition statement based on the filter condition according to the preset grammar rule; and uses the filter content statement and the filter condition statement to filter the pre-stored SQL statements to be queried; finally, the target SQL statement corresponding to the query instruction is matched from the filtered SQL statements to be queried. It can be understood that the data storage system can be an independent storage device, or the data storage system is located on the server 104, or the data storage system is located on another terminal.

[0049] In one embodiment, a data query method is provided. This embodiment uses the data query method applied to a terminal as an example for illustration. It is understandable that the data query method can also be applied to a server, and can also be applied to a system including a terminal and a server, and is implemented through the interaction between the terminal and the server. Figure 2 As shown, the data query method includes:

[0050] Step 202: In response to the query instruction, obtain the filter fields and filter conditions carried by the query instruction.

[0051] A query instruction refers to an instruction used to obtain specific information stored in a database. A query instruction may include multiple parts, including but not limited to filter fields, filter conditions, sorting requirements, etc.

[0052] Among them, the query instruction can be issued by the staff through the human-computer interaction interface of the terminal. The human-computer interaction interface of the terminal can specifically display the platform interface pre-specified by the service provider for database data recall. The staff can issue a query instruction carrying the filter field and filter condition by inputting the corresponding filter field in the text editing component in the specified platform interface and clicking at least one filter condition in the condition selection component. It should be noted that the user can also change the recall object corresponding to the query instruction by clicking on the pre-integrated virtual component for indicating different databases on the specified platform interface. Alternatively, the query instruction can be automatically generated by the terminal according to the preset recall frequency; specifically, the terminal can automatically generate the query instruction according to the preset query frequency based on the filter field and filter condition pre-set by the staff. In this embodiment, the staff can perform regular inspections on the SQL statements stored in the database through the regularly recalled data.

[0053] The filter field refers to the field name of the information that the staff wants to retrieve and display from the database. The filter condition refers to the conditional expression used by the staff to limit the query results.

[0054] The filtering condition may include one of a column structure, an aggregate function, and a window function. When the filtering condition includes a window function, the window function may include, for example: an OVER clause: used to define the scope of the window, that is, which rows will be included in the window; PARTITION BY: an optional clause, similar to the GROUP BY clause, but not for grouping data but for defining panes (partitions). The rows in each partition are independent of each other and aggregation or other calculations can be applied independently; ORDER BY: can also be used in the OVER clause to ensure that the window function operates in a specific order.

[0055] In this embodiment, the screening condition may be, for example, a window function with row number as a filtering condition.

[0056] As an example, if a staff member wants to query the names and prices of all products with sales exceeding 1,000 yuan in a certain e-commerce database, the staff member can enter the two filter fields "Product Name" and "Price" in the text editing component in the specified platform interface, and click the filter condition "Sales > 1000" in the condition selection component to generate a query instruction with the two filter fields "Product Name" and "Price" and the filter condition "Sales > 1000".

[0057] Step 204: Based on the screening field, generate a corresponding screening content statement according to the preset grammar rules; and based on the screening condition, generate a corresponding screening condition statement according to the preset grammar rules.

[0058] The filter content statement refers to a part of the SQL statement generated based on the filter field, which is used to specify which fields should be included in the query results. Among them, in the SQL statement, the SELECT clause is used to specify the fields that should be included in the query results. For example, the filter content statement can be a SELECT clause generated based on the filter field input by the staff.

[0059] The filter condition statement refers to a part of the SQL statement generated according to the filter condition, which is used to limit the records in the query results. Among them, in the SQL statement, subqueries are used to generate nested SQL, and each subquery contains its own unique query fields and query conditions; the filter condition statement can be, for example, a subquery related statement generated according to the filter condition selected by the staff.

[0060] The preset grammar rules are used to properly convert and format the field names entered by the staff, the conditional expressions selected by the staff, etc.

[0061] Step 206: Use the content screening statement and the condition screening statement to screen the pre-stored SQL statements to be queried.

[0062] The SQL statement to be queried refers to the SQL statement pre-stored in a specific database, which is used to provide data recall for the staff.

[0063] Step 208: Match the target SQL statement corresponding to the query instruction from the filtered SQL statements to be queried.

[0064] Since a specific database may store a large number of SQL statements to be queried, it is necessary to select a statement that best matches the staff's query instruction from these SQL statements to be queried. This process may involve comparison and analysis of multiple aspects such as the statement's syntax, semantics, field names, conditional expressions, etc.

[0065] Once the target SQL statement is found, the terminal can execute it and return the query results to the staff. During the execution process, the terminal will also perform necessary processing and formatting on the query results to ensure that the staff can see clear and accurate data.

[0066] In the above data query method, when the terminal identifies the SQL statement that meets the filtering conditions, the filtering conditions can be pushed down to the subquery of the window function, thereby avoiding processing a large amount of unnecessary data during the window function execution phase. When executing the window function, grouping can be performed according to columns to ensure that data in the same group is processed together, so that only data that meets the filtering conditions is processed instead of processing all data in the database. This strategy significantly reduces memory usage because there is no need to store and process all data, and query performance can be significantly improved.

[0067] In some optional embodiments, step 206 includes:

[0068] Based on the time tag carried by the query instruction, filter out the SQL statements to be queried that match the time period corresponding to the time tag from the pre-stored SQL statements to be queried;

[0069] By using the filtering content statement and the filtering condition statement, the filtered SQL statements to be queried are filtered out from the SQL statements to be queried that match the time period corresponding to the time label.

[0070] The time tag may be composed of at least one of letters, characters or numbers to uniquely identify the corresponding moment or time period. For example, the time tag may be one or more strings representing a time range or a specific time point, such as "2023-01-01 to 2023-01-31", "January 2023", etc.

[0071] The data storage system of the server maintains a database pre-stored with multiple SQL statements to be queried, and these SQL statements to be queried are associated with specific time periods. After receiving the query instruction, the terminal can filter out the SQL statements to be queried that meet the time period corresponding to the time label according to the time label carried by the query instruction and based on the extracted time label, by matching the time condition in the SQL statement to be queried (such as the time range restriction in the WHERE clause).

[0072] The above data query method reduces the amount of data of the SQL statements to be queried in the subsequent screening by setting the time condition, thereby speeding up the query speed, avoiding unnecessary execution and data transmission of the SQL statements to be queried, and reducing resource consumption.

[0073] In some optional embodiments, step 206 includes:

[0074] From the SQL statements to be queried, filter out the SQL statements to be queried that meet the filter content statements;

[0075] Use the grouping algorithm corresponding to the filter condition statement to group the SQL statements to be queried that meet the filter content statement;

[0076] For each group of SQL statements to be queried, secondary screening is performed using the grouping screening conditions corresponding to the screening condition statements to obtain the screened SQL statements to be queried.

[0077] As an example, the terminal may filter out SQL statements to be queried that meet the filtering content statements by matching the SELECT clause in the SQL statements to be queried (ie, the fields to be included in the query results) based on the extracted filtering content statements.

[0078] In one embodiment, the filtering condition may be, for example, a window function with row number as the filtering condition. The grouping algorithm of the window function determines how to group the SQL statement to be queried according to the calculation result of the window function, which usually involves sorting and grouping a field value or a combination of field values ​​in the SQL statement to be queried, such as grouping by attributes such as table name, field name, and query type.

[0079] Furthermore, the terminal can perform secondary screening according to the grouping screening conditions corresponding to the window function, which may involve comparison and analysis of the syntax, semantics, field names, conditional expressions, etc. of the SQL statements to be queried in each group. The terminal screens out SQL statements that meet specific conditions based on the calculation results of the window function (such as ranking, cumulative sum, etc.), thereby realizing customized grouping and sorting of query SQL statements according to the wishes of the staff by selecting appropriate window functions and corresponding grouping algorithms.

[0080] In the above information retrieval method, by applying the filter condition statement, the SQL statement that best meets the user's query requirements can be screened out, thereby improving the precision and accuracy of the query results. At the same time, the use of the filter condition statement also allows the user to perform complex calculations and analysis in the query result set, thereby obtaining richer query results.

[0081] In some optional embodiments, the grouping algorithm includes a sorting algorithm;

[0082] The grouping filter condition corresponds to the sorting order filter condition;

[0083] After step 206, the method further includes:

[0084] Use a sorting algorithm to sort the SQL statements to be queried in each group;

[0085] Step 208 includes:

[0086] For each group of SQL statements to be queried, a secondary screening is performed using the arrangement order screening condition to obtain the screened SQL statements to be queried.

[0087] After step 206, the terminal can sort the SQL statements to be queried in each group based on a sorting algorithm after grouping. The sorting conditions can be varied, such as based on execution time, complexity or custom priority, or according to the sorting conditions specified by the staff (such as ascending or descending order of a certain field), using an appropriate sorting algorithm (such as quick sort, merge sort, etc.) to sort the SQL statements to be queried in each group.

[0088] The sorting order screening condition is used to instruct the terminal to select the top N or bottom N SQL statements to be queried in each group, or to exclude the top N or bottom N SQL statements to be queried.

[0089] The above data query method can reduce the amount of data to be processed and speed up the query speed by gradually screening, grouping and sorting. At the same time, the use of sorting algorithms and sorting order screening conditions also allows the terminal to centrally and efficiently perform complex operations when querying results, avoiding unnecessary execution of SQL statements to be queried and data transmission, and reducing resource consumption; thereby, more accurate and relevant query results can be obtained, and the flexibility and adaptability in the data query process can be improved by customizing sorting algorithms and sorting order screening conditions of different types and complexities.

[0090] In some optional embodiments, step 204 includes:

[0091] Determine whether the screening condition is a single condition or a combined condition; a combined condition includes two or more conditions;

[0092] When the query condition is a single condition, a filter condition statement based on the query condition is generated based on the condition structure in the preset grammar rule;

[0093] When the query condition is a combination condition, a filter condition statement based on the query condition is generated based on the condition tree structure in the preset grammar rule.

[0094] After receiving the query instruction issued by the staff, the terminal can first determine whether the filtering condition carried by the query instruction is a single condition or a combined condition. When the staff clicks a filtering condition in the condition selection component of the specified platform interface, the filtering condition carried by the query instruction is a single condition; when the staff clicks two or more filtering conditions in the condition selection component of the specified platform interface, the filtering condition carried by the query instruction is a combined condition.

[0095] When the query condition is a single condition, the terminal can combine the parsed condition keywords, operators and values ​​into a filter condition statement that conforms to the SQL grammar specification according to the condition structure in the preset grammar rules. For example, for the condition "age>30", the system may generate a filter condition statement such as "WHERE age>30".

[0096] When the query condition is a combination condition, the terminal needs to process a more complex logical structure. This is usually achieved by building a condition tree. The condition tree is a data structure used to represent the logical relationship and each sub-condition in the combination condition. The terminal first identifies the logical operators and sub-conditions in the combination condition, and then recursively builds the condition tree. After building the condition tree, the terminal can convert the condition tree into a filter condition statement that conforms to the SQL syntax specification according to the condition tree structure in the preset syntax rules.

[0097] The above data query method can accurately execute the query request and obtain the correct query result by judging the type of the filter condition and generating the filter condition statement that conforms to the SQL syntax specification; by distinguishing and processing the single condition and the combined condition, when facing the combined condition, the filter condition statement can be generated by constructing the condition tree, so as to efficiently process the complex query condition containing multiple logical relationships and sub-conditions, which helps to reduce the amount of calculation in the query process and improve the query performance.

[0098] It should be understood that, although the steps in the flowcharts involved in the above embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0099] Based on the same inventive concept, the embodiment of the present application also provides a data query device for implementing the data query method involved above. The implementation scheme for solving the problem provided by the data query device is similar to the implementation scheme recorded in the above data query method, so the specific limitations in one or more device embodiments provided below can refer to the limitations on the data query method above, and will not be repeated here.

[0100] In one embodiment, Figure 3 As shown, a data query device 300 is provided, comprising:

[0101] The acquisition module 302 is used to obtain the filter fields and filter conditions carried by the query instruction in response to the query instruction;

[0102] A generation module 304 is used to generate a corresponding content filtering statement based on the filtering field according to the preset grammar rules; and to generate a corresponding filtering condition statement based on the filtering condition according to the preset grammar rules;

[0103] A screening module 306 is used to screen the pre-stored SQL statements to be queried by using a screening content statement and a screening condition statement;

[0104] The matching module 308 is used to match the target SQL statement corresponding to the query instruction from the filtered SQL statements to be queried.

[0105] In some optional embodiments, the screening module 306 is further configured to:

[0106] Based on the time tag carried by the query instruction, filter out the SQL statements to be queried that match the time period corresponding to the time tag from the pre-stored SQL statements to be queried;

[0107] By using the filtering content statement and the filtering condition statement, the filtered SQL statements to be queried are filtered out from the SQL statements to be queried that match the time period corresponding to the time label.

[0108] In some optional embodiments, the screening module 306 is further configured to:

[0109] From the SQL statements to be queried, filter out the SQL statements to be queried that meet the filter content statements;

[0110] Use the grouping algorithm corresponding to the filter condition statement to group the SQL statements to be queried that meet the filter content statement;

[0111] For each group of SQL statements to be queried, secondary screening is performed using the grouping screening conditions corresponding to the screening condition statements to obtain the screened SQL statements to be queried.

[0112] In some optional embodiments, the grouping algorithm includes a sorting algorithm;

[0113] The grouping filter condition includes the sorting order filter condition;

[0114] The screening module 306 is further configured to:

[0115] Use a sorting algorithm to sort the SQL statements to be queried in each group;

[0116] For each group of SQL statements to be queried, a secondary screening is performed using the arrangement order screening condition to obtain the screened SQL statements to be queried.

[0117] In some optional embodiments, the screening condition includes one of a column structure, an aggregate function, and a window function.

[0118] In some optional embodiments, the generating module 304 is further configured to:

[0119] Determine whether the screening condition is a single condition or a combined condition; a combined condition includes two or more conditions;

[0120] When the query condition is a single condition, a filter condition statement based on the query condition is generated based on the condition structure in the preset grammar rule;

[0121] When the query condition is a combination condition, a filter condition statement based on the query condition is generated based on the condition tree structure in the preset grammar rule.

[0122] Each module in the above device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.

[0123] Figure 4 This is a schematic diagram of the structure of the (device subject) provided in this application. Figure 4 As shown, the electronic device 40 provided in this embodiment includes: at least one processor 401 and a memory 402. Optionally, the device 40 also includes a communication component 403. The processor 401, the memory 402 and the communication component 403 are connected via a bus 404.

[0124] In a specific implementation process, at least one processor 401 executes the computer-executable instructions stored in the memory 402, so that at least one processor 401 executes the above method.

[0125] The specific implementation process of the processor 401 can be found in the above method embodiment, and its implementation principle and technical effect are similar, so this embodiment will not be repeated here.

[0126] In the above embodiments, it should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the invention may be directly implemented as being executed by a hardware processor, or may be executed by a combination of hardware and software modules in the processor.

[0127] The memory may include a high-speed memory (Random Access Memory, RAM), and may also include a non-volatile memory (Non-volatile Memory, NVM), such as at least one disk memory.

[0128] The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the bus in the drawings of the present application is not limited to only one bus or one type of bus.

[0129] The present application also provides a computer program product, including a computer program, which implements the above method when executed by a processor.

[0130] The present application also provides a computer-readable storage medium, in which computer-executable instructions are stored. When a processor executes the computer-executable instructions, the above method is implemented.

[0131] The above-mentioned readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. The readable storage medium can be any available medium that can be accessed by a general or special-purpose computer.

[0132] An exemplary readable storage medium is coupled to a processor so that the processor can read information from the readable storage medium and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can be located in an application specific integrated circuit (Application Specific Integrated Circuits, referred to as: ASIC). Of course, the processor and the readable storage medium can also exist in the device as discrete components.

[0133] The division of units is only a logical function division, and there may be other divisions in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interface, device or unit, which can be electrical, mechanical or other forms.

[0134] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0135] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0136] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.

[0137] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.

[0138] Finally, it should be noted that those skilled in the art will readily conceive of other embodiments of the present invention after considering the specification and practicing the invention disclosed herein. The present invention is intended to cover any variations, uses or adaptations of the present invention, which follow the general principles of the present invention and include common knowledge or customary technical means in the art not disclosed by the present invention, are not limited to the precise structure described above and shown in the drawings, and may be modified and changed in various ways without departing from the scope thereof. The scope of the present invention is limited only by the appended claims.

Claims

1. A data query method, characterized in that: include: In response to a query instruction, obtaining a filter field and a filter condition carried by the query instruction; Based on the screening field, generating a corresponding screening content statement according to a preset grammar rule; and based on the screening condition, generating a corresponding screening condition statement according to a preset grammar rule; The screening condition statement includes a subquery statement of a window function; Using the screening content statement and the screening condition statement, screening the pre-stored SQL statements to be queried; The target SQL statement corresponding to the query instruction is matched from the filtered SQL statements to be queried.

2. The method according to claim 1, characterized in that The using the screening content statement and the screening condition statement to screen the pre-stored SQL statement to be queried includes: Based on the time tag carried by the query instruction, filter out the SQL statements to be queried that match the time period corresponding to the time tag from the pre-stored SQL statements to be queried; The filtering content statement and the filtering condition statement are used to filter out the filtered SQL statements to be queried from the SQL statements to be queried that match the time period corresponding to the time tag.

3. The method according to claim 1 or 2, characterized in that: The using the screening content statement and the screening condition statement to screen the pre-stored SQL statement to be queried includes: Filter out the SQL statements to be queried that meet the screening content statements from the SQL statements to be queried; Using the grouping algorithm corresponding to the screening condition statement, the SQL statements to be queried that meet the screening content statement are grouped; For each group of SQL statements to be queried, secondary screening is performed using the grouping screening conditions corresponding to the screening condition statements to obtain screened SQL statements to be queried.

4. The method according to claim 3, characterized in that The grouping algorithm includes a sorting algorithm; The grouping screening condition includes an arrangement order screening condition; After the SQL statements to be queried that meet the screening content statements are grouped by using a preset grouping algorithm, the method further includes: Using the sorting algorithm, sort the SQL statements to be queried in each group; The method of performing secondary screening on the SQL statements to be queried in each group using the grouping screening conditions corresponding to the screening condition statements to obtain the screened SQL statements to be queried includes: For each group of SQL statements to be queried, secondary screening is performed using the arrangement order screening condition to obtain screened SQL statements to be queried.

5. The method according to claim 4, characterized in that The screening condition includes one of a column structure, an aggregate function, and a window function.

6. The method according to claim 5, characterized in that The step of generating a corresponding filtering condition statement based on the filtering condition according to a preset grammar rule includes: Determine whether the screening condition is a single condition or a combined condition; the combined condition includes two or more conditions; When the query condition is a single condition, generating a screening condition statement based on the query condition based on the condition structure in the preset grammar rule; When the query condition is a combination condition, a screening condition statement based on the query condition is generated based on a condition tree structure in a preset grammar rule.

7. A data query device, characterized in that: include: An acquisition module, configured to respond to a query instruction and acquire a filter field and a filter condition carried by the query instruction; A generating module, configured to generate a corresponding filtering content statement based on the filtering field and according to a preset grammar rule; and to generate a corresponding filtering condition statement based on the filtering condition and according to a preset grammar rule; A screening module, used to screen the pre-stored SQL statements to be queried by using the screening content statement and the screening condition statement; The matching module is used to match the target SQL statement corresponding to the query instruction from the filtered SQL statements to be queried.

8. An electronic device, characterized in that: include: Memory, processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory, so that the processor performs the method according to any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 6 when executed by a processor.

10. A computer program product, characterized in that The invention comprises a computer program, which implements the method according to any one of claims 1 to 6 when being executed by a processor.