A data query method and device, a terminal device, and a storage medium

By obtaining business scenario information from the data query method and dynamically selecting SQL query statements, the problem of inflexible query methods in existing technologies is solved, and more efficient and universal data query is achieved.

CN115422222BActive Publication Date: 2026-06-26HANGZHOU QULIAN TECHNOLOGY CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
HANGZHOU QULIAN TECHNOLOGY CO LTD
Filing Date
2022-08-19
Publication Date
2026-06-26

AI Technical Summary

Technical Problem

Existing data query methods are not flexible enough, have low practicality, lack universality, and cannot dynamically adjust SQL query statements according to different business scenarios.

Method used

By obtaining business scenario information from the data query request, the most suitable target SQL query statement is selected from multiple preset SQL query statements based on this information and executed to obtain the corresponding data.

Benefits of technology

It improves the flexibility and practicality of data querying, enabling the selection of the most suitable SQL query statement according to different business scenarios, achieving optimization for business systems, and possessing universality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115422222B_ABST
    Figure CN115422222B_ABST
Patent Text Reader

Abstract

The application is suitable for the technical field of computers, and provides a data query method and device, terminal equipment and computer readable storage medium, the method comprises the following steps: obtaining a data query request, the data query request carries business scenario information; according to the business scenario information, a target SQL query statement is selected from a plurality of preset SQL query statements; the target SQL query statement is executed to obtain the data corresponding to the business scenario information. According to the method, the most suitable SQL query statement can be selected from a plurality of preset SQL query statements according to the business scenario information carried by the data query request, that is, different business scenarios can execute different SQL query statements, so that the flexibility and practicability of data query are improved, and the method is optimized for a business system and has universality.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of computer technology, and in particular relates to a data query method, apparatus, terminal device and computer-readable storage medium. Background Technology

[0002] The interaction process between most systems and databases can be summarized as follows: the system generates a Structured Query Language (SQL) statement to be executed, and then uses a database connection to execute the statement, thereby achieving the purpose of querying the corresponding data.

[0003] Existing data query methods typically optimize the database, such as adding indexes to the chain name fields of various linked lists to speed up data retrieval. However, once the system is running normally, the generated generic SQL statement remains unchanged; that is, for the same business logic, the generic SQL statement executed by the database connection does not change. In other words, when running the same system under different requirements within the same business logic, the same database operations will be performed under different requirements—the database will execute the same generic SQL statement in every case. Therefore, existing technologies suffer from inflexibility, low practicality, and a lack of universality. Summary of the Invention

[0004] This application provides a data query method, apparatus, terminal device, and computer-readable storage medium, which can solve the problems of insufficient flexibility, low practicality, and lack of universality in the prior art.

[0005] In a first aspect, embodiments of this application provide a data query method, including:

[0006] Obtain a data query request, wherein the data query request carries business scenario information;

[0007] Based on the business scenario information, select the target SQL query statement from multiple preset SQL query statements;

[0008] Execute the target SQL query to obtain the data corresponding to the business scenario information.

[0009] Optionally, selecting the target SQL query statement from multiple preset SQL query statements based on the business scenario information includes:

[0010] Obtain preset target parameters associated with the business scenario information;

[0011] Based on the target parameters, the target SQL query statement is selected from the plurality of preset SQL query statements.

[0012] Optionally, selecting the target SQL query statement from the plurality of preset SQL query statements based on the target parameter includes:

[0013] Based on the target parameters, select each candidate SQL query statement from the plurality of preset SQL query statements;

[0014] Detect the current value of the target parameter;

[0015] Based on the current value, determine the score corresponding to each of the candidate SQL query statements;

[0016] The candidate SQL query statement with the highest score is selected from all the candidate SQL query statements and used as the target SQL query statement.

[0017] Optionally, selecting the candidate SQL query statement with the highest score from the candidate SQL query statements as the target SQL query statement includes:

[0018] If the number of candidate SQL queries with the highest score exceeds one, then the number of times each candidate SQL query with the highest score is executed and the response time are counted within the first historical time period.

[0019] The target SQL query statement is selected from the candidate SQL query statements with the highest scores based on the number of times each statement is executed and the response time.

[0020] Optionally, each of the target parameters is pre-associated with at least one SQL operation statement. Before determining the score corresponding to each of the candidate SQL query statements based on the current value, the method further includes:

[0021] Execute the target SQL operation statement associated with each of the target parameters respectively;

[0022] The current value of each target parameter is updated based on the execution result of the target SQL operation statement associated with each target parameter.

[0023] Optionally, the data query request also carries user configuration information, and obtaining the preset target parameters associated with the business scenario information includes:

[0024] The target parameters are determined based on the user configuration information and the business scenario information.

[0025] Optionally, obtaining the preset target parameters associated with the business scenario information includes:

[0026] The response time of all historical SQL query statements executed within the business scenario indicated by the business scenario information during the second historical time period is statistically analyzed, as well as the number of occurrences of the historical parameters corresponding to each historical SQL query statement.

[0027] The target parameter is determined based on the response time of all historical SQL query statements and the number of occurrences of the historical parameters corresponding to each historical SQL query statement.

[0028] Secondly, embodiments of this application provide a data query device, including:

[0029] The first acquisition unit is used to acquire a data query request, wherein the data query request carries business scenario information;

[0030] The first selection unit is used to select a target SQL query statement from multiple preset SQL query statements based on the business scenario information.

[0031] The first execution unit is used to execute the target SQL query statement to obtain the data corresponding to the business scenario information.

[0032] Thirdly, embodiments of this application provide a terminal device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the data query method as described in any one of the first aspects above.

[0033] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the data query method as described in any one of the first aspects above.

[0034] Fifthly, embodiments of this application provide a computer program product that, when run on a terminal device, enables the terminal device to execute the data query method described in any one of the first aspects.

[0035] The beneficial effects of the embodiments of this application compared with the prior art are:

[0036] This application provides a data query method that involves obtaining a data query request carrying business scenario information; selecting a target SQL query statement from multiple preset SQL query statements based on the business scenario information; and executing the target SQL query statement to obtain data corresponding to the business scenario information. Compared to existing technologies that use the same SQL query statement for different needs under the same business, this application combines specific business scenario information and selects a target SQL query statement from multiple preset SQL query statements based on different business scenario information. In other words, the most suitable SQL query statement can be flexibly selected for execution based on different business scenario information, meaning different SQL query statements can be executed for different business scenarios. This improves the flexibility and practicality of data querying, and the method is optimized for business systems, making it universally applicable. Attached Figure Description

[0037] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0038] Figure 1 This is a flowchart illustrating the implementation of a data query method provided in an embodiment of this application;

[0039] Figure 2 This is a flowchart illustrating the implementation of a data query method provided in another embodiment of this application;

[0040] Figure 3 This is a flowchart illustrating the implementation of a data query method provided in another embodiment of this application;

[0041] Figure 4 This is a flowchart illustrating the implementation of a data query method provided in another embodiment of this application;

[0042] Figure 5 This is a flowchart illustrating the implementation of a data query method provided in another embodiment of this application;

[0043] Figure 6 This is a flowchart illustrating the implementation of a data query method provided in another embodiment of this application;

[0044] Figure 7 This is a schematic diagram of the structure of a data query device provided in an embodiment of this application;

[0045] Figure 8 This is a schematic diagram of the structure of a terminal device provided in an embodiment of this application. Detailed Implementation

[0046] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods have been omitted so as not to obscure the description of this application with unnecessary detail.

[0047] It should be understood that, when used in this application specification and the appended claims, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or a collection thereof.

[0048] It should also be understood that the term “and / or” as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.

[0049] As used in this application specification and the appended claims, the term "if" may be interpreted, depending on the context, as "when," "once," "in response to determination," or "in response to detection." Similarly, the phrase "if determined" or "if detected [the described condition or event]" may be interpreted, depending on the context, as meaning "once determined," "in response to determination," "once detected [the described condition or event]," or "in response to detection [the described condition or event]."

[0050] Furthermore, in the description of this application and the appended claims, the terms "first," "second," "third," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.

[0051] References to "one embodiment" or "some embodiments" as described in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.

[0052] Please see Figure 1 , Figure 1This is a flowchart illustrating the implementation of a data query method according to an embodiment of this application. In this embodiment, the data query method is executed by a terminal device.

[0053] like Figure 1 As shown, a data query method provided in one embodiment of this application may include S101 to S103, which are described in detail below:

[0054] In S101, a data query request is obtained, which carries business scenario information.

[0055] In this embodiment of the application, the terminal device detecting a data query request can be achieved by detecting a preset operation. The preset operation can be set according to actual needs and is not limited here. For example, the preset operation can be a user clicking a preset control. That is, if the terminal device detects that a user clicks a preset control on the terminal device, or clicks a preset control in a related application (APP) within the terminal device, it considers that a preset operation has been detected, i.e., a data query request has been detected.

[0056] It should be noted that data query requests carry business scenario information. This business scenario information describes the actual needs of this data query request. For example, suppose a data query request is for chain list information. Typically, chain list information includes, but is not limited to, chain name, number of available nodes, total number of nodes, number of contracts, and driver information. However, for this particular query of chain list information, the user does not need to obtain contract-related information. Therefore, the business scenario information carried in this data query request only includes: chain name, number of available nodes, total number of nodes, and driver information.

[0057] In S102, a target SQL query statement is selected from multiple preset SQL query statements based on the business scenario information.

[0058] In this embodiment of the application, after the terminal device receives a data query request, it can extract business scenario information from the data query request.

[0059] In practical applications, terminal devices pre-store a large number of preset SQL query statements, and each business has multiple preset SQL query statements corresponding to it. However, different preset SQL query statements can not completely meet the actual needs of the same business, resulting in different query times, i.e., different query efficiencies.

[0060] Based on this, in the embodiments of this application, the terminal device can select the target SQL query statement from multiple preset SQL query statements based on the business scenario information extracted from the data query request, that is, the SQL query statement that meets the actual needs of this data query.

[0061] In S103, the target SQL query statement is executed to obtain the data corresponding to the business scenario information.

[0062] In this embodiment of the application, after the terminal device selects the target SQL query statement, it can execute the target SQL query statement, thereby obtaining data corresponding to the business scenario information.

[0063] As can be seen from the above, the data query method provided in this application involves obtaining a data query request carrying business scenario information; selecting a target SQL query statement from multiple preset SQL query statements based on the business scenario information; and executing the target SQL query statement to obtain the data corresponding to the business scenario information. Compared with the prior art, which uses the same SQL query statement for different needs under the same business, this application combines specific business scenario information and selects a target SQL query statement from multiple preset SQL query statements based on different business scenario information. In other words, the most suitable SQL query statement can be flexibly selected for execution based on different business scenario information, meaning different SQL query statements can be executed for different business scenarios. This improves the flexibility and practicality of data querying, and the method is optimized for business systems and has universality.

[0064] Please see Figure 2 , Figure 2 This is another data query method provided in this application. Relative to... Figure 1 In the corresponding embodiment, the data query method provided in this embodiment may specifically include S201 to S202, as detailed below:

[0065] In S201, a preset target parameter associated with the business scenario information is obtained.

[0066] In this embodiment, the preset target parameters associated with the business scenario information can be set according to actual needs, and are not limited here. The target parameters describe the influence factors on acquiring data corresponding to the business scenario information. There can be one or more target parameters.

[0067] For example, assuming the business scenario information carried in this data query request includes: chain name, number of available nodes, total number of nodes, and driving information, the target parameter associated with this business scenario information can be set to: the number of contracts with an OK status for each chain and the number of chain lists.

[0068] In one implementation of this embodiment, the terminal device can obtain preset target parameters associated with business scenario information in real time from a server with which it is wirelessly / wiredly connected. The server can be a desktop computer, a computer, or other similar device.

[0069] In one embodiment of this application, to improve user experience, the data query request also carries user configuration information. This user configuration information is used to characterize at least one influencing factor set by the user sending the data query request to obtain data corresponding to business scenario information.

[0070] Based on this, in this embodiment, the terminal device can determine the target parameters according to user configuration information and business scenario information.

[0071] Specifically, terminal devices can identify influencing factors that exist in both user configuration information and business scenario information as target parameters.

[0072] In S202, the target SQL query statement is selected from the plurality of preset SQL query statements according to the target parameters.

[0073] In this embodiment, the terminal device can select a target SQL query statement from multiple preset SQL query statements based on the target parameters. This target SQL query statement is the one that meets the actual needs of the data query.

[0074] In one embodiment of this application, the terminal device can specifically be configured as follows: Figure 3 The implementation steps S202 shown in S301 to S304 are detailed below:

[0075] In S301, each candidate SQL query statement is selected from the plurality of preset SQL query statements according to the target parameters.

[0076] In S302, the current value of the target parameter is detected.

[0077] In S303, the score corresponding to each candidate SQL query statement is determined based on the current value.

[0078] In S304, the candidate SQL query statement with the highest score is selected from the candidate SQL query statements and used as the target SQL query statement.

[0079] It should be noted that candidate SQL query statements refer to the SQL query statements that can be executed under the target parameters.

[0080] In one implementation of this embodiment, the terminal device can detect the current value of the target parameter in real time through a server with which it is wirelessly / wiredly connected.

[0081] In another implementation of this embodiment, after determining the target parameter, the terminal device can execute SQL operation statements related to the target parameter to obtain the current value of the target parameter.

[0082] In this embodiment, since each candidate SQL query statement has its corresponding preset calculation rule, for any candidate SQL query statement, the terminal device can calculate the score corresponding to the candidate SQL query statement based on the current value of the target parameter and the preset calculation rule corresponding to the candidate SQL query statement.

[0083] It should be noted that the type of preset calculation rule can be set according to actual needs, and there are no restrictions here. For example, the type of preset calculation rule can be a simple mathematical expression, such as addition, subtraction, multiplication, and division; or it can be a function, such as... Among them, S i f represents the score of the i-th candidate SQL query statement. i (·) represents the function that calculates the score of the i-th candidate SQL query statement, X i Let x represent the set of target parameters for the i-th candidate SQL query statement. j This represents the current value of the j-th target parameter; it can also be a conditional statement, such as if(value1<100&&value0.sum()<100)return 100else return 0}, (that is, if the sum of the value of value1 and all the quantities in value0 is less than 100, then return 100 points, otherwise return 0 points), where value0 represents the current value of the first target parameter and value1 represents the current value of the second target parameter.

[0084] Based on this, after obtaining the score corresponding to each candidate SQL query statement, the terminal device can select the candidate SQL query statement with the highest score from all candidate SQL query statements as the target SQL query statement.

[0085] For example, taking a preset calculation rule as the judgment statement and two target parameters as an example, steps S303 to S304 will be explained in detail:

[0086] Assuming there are three candidate SQL queries, the default calculation rule for the first candidate SQL query could be: `if(value1<100&&value0.sum()<100)return 100else return 0}` (meaning if the sum of the values ​​in `value1` and `value0` is less than 100, then return 100 points; otherwise, return 0 points). The default calculation rule for the second candidate SQL query could be: `if(value1<100&&value0.sum()>100)return 100else return 0` (meaning if the value in `value1` is less than 100 but the sum of the values ​​in `value0` is greater than 100, then return 100 points; otherwise, return 0 points). The default calculation rule for the third candidate SQL query could be: `if(value1>100&&value0.sum()>100)return 100else return`. 0 (that is, if the sum of the value of value1 and all the quantities in value0 is greater than 100, then return 100 points, otherwise return 0 points); the current value of the first target parameter value0 = 1000, the current value of the second target parameter value1 = 1, then the score corresponding to the first candidate SQL query statement is: 0, the score corresponding to the second candidate SQL query statement is: 0, the score corresponding to the third candidate SQL query statement can be: 100, therefore, the terminal device can determine the third candidate SQL query statement as the target SQL query statement.

[0087] In this embodiment, the candidate SQL query statement with the highest score can be one or more.

[0088] In one embodiment of this application, when there are multiple candidate SQL query statements with the highest scores, the terminal device can determine the one with the highest query priority as the target SQL query statement based on the query priority of the candidate SQL query statements.

[0089] In another embodiment of this application, when there are multiple candidate SQL query statements with the highest scores, step S304 can be further implemented as follows: Figure 4 The implementations of S401 to S402 shown are described in detail below:

[0090] In S401, if the number of candidate SQL query statements with the highest score exceeds one, the number of times each candidate SQL query statement with the highest score is executed and the response time are counted within the first historical time period.

[0091] In S402, the target SQL query statement is selected from the candidate SQL query statements with the highest scores based on the number of times each candidate SQL query statement with the highest score is executed and the response time.

[0092] In this embodiment, the first historical time period can be determined according to actual needs, and no restriction is imposed here.

[0093] Response time describes the time from the execution of an SQL query to the retrieval of the data.

[0094] In this embodiment, after obtaining the number of times each candidate SQL query statement with the highest score was executed and the response time within the first historical time period, the terminal device can select the target SQL query statement from each candidate SQL query statement with the highest score based on the number of times each candidate SQL query statement was executed and the response time.

[0095] In one implementation of this embodiment, after obtaining the number of times each candidate SQL query with the highest score was executed and the response time within a first historical time period, the terminal device, for each candidate SQL query with the highest score, imports the number of times each candidate SQL query with the highest score was executed and the response time into a first preset formula to calculate the selection value corresponding to the candidate SQL query with the highest score.

[0096] In one embodiment of this application, the first preset formula is specifically:

[0097] R k =ω k1 N k +ω k2 t k ;

[0098] Among them, R k N represents the selected value of the k-th candidate SQL query with the highest score. k t represents the number of times the k-th highest-rated candidate SQL query statement is executed. k ω represents the response time of the k-th highest-rated candidate SQL query. k1 ω represents the weighting coefficient corresponding to the number of times the k-th highest-scoring candidate SQL query statement was executed. k2 This represents the weighting coefficient corresponding to the response time of the k-th highest-scoring candidate SQL query.

[0099] In this embodiment, the terminal device obtains the selection value corresponding to each candidate SQL query statement with the highest score, and determines the candidate SQL query statement with the highest score and the largest selection value as the target SQL query statement.

[0100] As can be seen from the above, the data query method provided in this embodiment, after obtaining a data query request, can acquire preset target parameters associated with business scenario information, and select a target SQL query statement from multiple preset SQL query statements based on these target parameters. The data query method provided in this embodiment can improve the accuracy of the selected target SQL query statement, thereby improving the accuracy of the data query.

[0101] Please see Figure 5 , Figure 5 This is another embodiment of the data query method provided in this application. Compared to... Figure 3 In a corresponding embodiment, the data query method provided in this embodiment may further include S501 to S502 before S303, as detailed below:

[0102] In S501, the target SQL operation statement associated with each of the target parameters is executed respectively.

[0103] In S502, the current value of each target parameter is updated according to the execution result of the target SQL operation statement associated with each target parameter.

[0104] In this embodiment, at least one SQL operation statement associated with each target parameter is used to obtain the current value of each target parameter.

[0105] In one implementation of this embodiment, for any target parameter, when the SQL operation statement associated with the target parameter is one, the terminal device can directly determine the associated SQL operation statement as the target SQL operation statement of the target parameter.

[0106] In another implementation of this embodiment, for any target parameter, when there are multiple SQL operation statements associated with the target parameter, the terminal device can determine the target SQL operation statement for the target parameter based on preset conditions. These preset conditions can be determined according to actual needs and are not limited here.

[0107] In one embodiment of this application, the preset condition may be: randomly selecting an SQL operation statement as the target SQL operation statement. Therefore, the terminal device can randomly select one associated SQL operation statement from among the multiple SQL operation statements associated with the target parameter as the target SQL operation statement for that target parameter.

[0108] In another embodiment of this application, to improve the accuracy of subsequent updates to the current value of the target parameter, a preset condition may be: all SQL operation statements are identified as target SQL operation statements. Therefore, the terminal device can identify multiple SQL operation statements associated with the target parameter as the target SQL operation statements for that target parameter.

[0109] In this embodiment, the terminal device can sequentially execute multiple SQL operation statements associated with the target parameter, obtain multiple execution results, and update the current value of the target parameter based on the multiple execution results.

[0110] In practical applications, since the current value of each target parameter changes dynamically in real time, in order to obtain the latest current value of each target parameter, the terminal device can execute the target SQL operation statement associated with each target parameter based on a preset time interval, thereby obtaining the latest current value of each target parameter. The preset time interval can be determined according to actual needs and is not limited here; for example, the preset time interval can be 10 minutes.

[0111] In one embodiment of this application, the terminal device can obtain the latest current value of each target parameter through a server connected to it via wireless / wired communication based on a preset time interval.

[0112] It should be noted that the execution result of the target SQL operation statement associated with each target parameter refers to the current value of the target parameter associated with each target SQL operation statement after its execution. Therefore, the terminal device can update the current value of each target parameter based on the execution result of the target SQL operation statement associated with each target parameter.

[0113] When a target parameter is associated with multiple target SQL operation statements, the terminal device can obtain multiple execution results for that target parameter and update the current value of the target parameter based on the execution result that appears most frequently.

[0114] As can be seen from the above, the data query method provided in this embodiment, since each target parameter is pre-associated with at least one SQL operation statement, can execute the target SQL operation statement associated with each target parameter before scoring each candidate SQL query statement. Then, based on the execution results of the target SQL operation statements associated with each target parameter, the current value of each target parameter is updated. Finally, the score corresponding to each candidate SQL query statement can be determined based on the updated current value of each target parameter. The data query method provided in this embodiment can improve the calculation accuracy of the score corresponding to each candidate SQL query statement, thereby improving the accuracy of the selected target SQL query statement, and ultimately improving the data query efficiency and accuracy.

[0115] Please see Figure 6 , Figure 6 This is yet another embodiment of the data query method provided in this application. Compared to... Figure 2 In the corresponding embodiment, the data query method provided in this embodiment may specifically include S601 to S602, as detailed below:

[0116] In S601, the response time of all historical SQL query statements executed under the business scenario pointed to by the business scenario information within the second historical time period is counted, as well as the number of times the historical parameters corresponding to each historical SQL query statement appear.

[0117] In S602, the target parameter is determined based on the response time of all historical SQL query statements and the number of occurrences of the historical parameters corresponding to each historical SQL query statement.

[0118] In this embodiment, the second historical time period can be determined according to actual needs, and there is no limitation here. It should be noted that the second historical time period can be the same as or different from the first historical time period.

[0119] Response time describes the time from the execution of an SQL query to the retrieval of the data.

[0120] Once the terminal device obtains the response time of all historical SQL query statements and the number of occurrences of the historical parameters corresponding to each historical SQL query statement within the second historical time period, it can determine the target parameters based on the response time of all historical SQL query statements and the number of occurrences of the historical parameters corresponding to each historical SQL query statement.

[0121] Specifically, in some possible embodiments, after obtaining the response time of all historical SQL query statements within the second historical time period and the number of occurrences of the historical parameters corresponding to each historical SQL query statement, the terminal device, for each historical SQL query statement, imports the response time of the historical SQL query statement and the number of occurrences of the corresponding historical parameters into a second preset formula to calculate the score of the historical parameters corresponding to the historical SQL query statement.

[0122] In one embodiment of this application, the second preset formula is specifically as follows:

[0123] M h =ω h1 f h +ω h2 t h ;

[0124] Among them, M h f represents the score of the historical parameter corresponding to the h-th historical SQL query statement. h t represents the number of times the historical parameter corresponding to the h-th historical SQL query statement appears. h ω represents the response time of the h-th historical SQL query. h1 ω represents the weighting coefficient corresponding to the occurrence count of the historical parameter for the h-th historical SQL query statement. h2 This represents the weighting coefficient corresponding to the response time of the h-th historical SQL query.

[0125] In this embodiment, the terminal device obtains the score value of the historical parameter corresponding to each historical SQL query statement, and determines the historical parameter corresponding to the SQL query statement with the largest score value as the target parameter.

[0126] As can be seen from the above, the data query method provided in this embodiment can accurately determine the target parameter by statistically analyzing the response time of all historical SQL query statements executed in the business scenario pointed to by the business scenario information within the second historical time period, as well as the number of times the historical parameters corresponding to each historical SQL query statement appear; and then, based on the response time of all historical SQL query statements and the number of times the historical parameters corresponding to each historical SQL query statement appear, the target parameter can be accurately determined, thereby further improving the selection accuracy of the target SQL query statement.

[0127] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.

[0128] Corresponding to the data query method described in the above embodiments, Figure 7This diagram illustrates a structural block diagram of a data query device according to an embodiment of this application. For ease of explanation, only the parts relevant to the embodiment of this application are shown. (Refer to...) Figure 7 The data query device 700 includes: a first acquisition unit 71, a first selection unit 72, and a first execution unit 73. Wherein:

[0129] The first acquisition unit 71 is used to acquire a data query request, which carries business scenario information.

[0130] The first selection unit 72 is used to select a target SQL query statement from multiple preset SQL query statements based on the business scenario information.

[0131] The first execution unit 73 is used to execute the target SQL query statement to obtain the data corresponding to the business scenario information.

[0132] In one embodiment of this application, the first selection unit 72 specifically includes: a second acquisition unit and a second selection unit. Wherein:

[0133] The second acquisition unit is used to acquire preset target parameters associated with the business scenario information.

[0134] The second selection unit is used to select the target SQL query statement from the plurality of preset SQL query statements according to the target parameters.

[0135] In one embodiment of this application, the second selection unit specifically includes: a third selection unit, a detection unit, a first determination unit, and a fourth selection unit. Wherein:

[0136] The third selection unit is used to select each candidate SQL query statement from the plurality of preset SQL query statements according to the target parameters.

[0137] The detection unit is used to detect the current value of the target parameter.

[0138] The first determining unit is used to determine the score corresponding to each of the candidate SQL query statements based on the current value.

[0139] The fourth selection unit is used to select the candidate SQL query statement with the highest score from the candidate SQL query statements, and use it as the target SQL query statement.

[0140] In one embodiment of this application, the fourth selection unit specifically includes: a first statistical unit and a fifth selection unit. Wherein:

[0141] The first statistical unit is used to count the number of times each of the highest-scoring candidate SQL query statements was executed and the response time within a first historical time period if the number of such statements exceeds one.

[0142] The fifth selection unit is used to select the target SQL query statement from the candidate SQL query statements with the highest scores based on the number of times each candidate SQL query statement with the highest score is executed and the response time.

[0143] In one embodiment of this application, each target parameter is pre-associated with at least one SQL operation statement, and the data query device 700 further includes: a second execution unit and an update unit. Wherein:

[0144] The second execution unit is used to execute the target SQL operation statement associated with each of the target parameters respectively.

[0145] The update unit is used to update the current value of each target parameter according to the execution result of the target SQL operation statement associated with each target parameter.

[0146] In one embodiment of this application, the data query request also carries user configuration information, and the second acquisition unit specifically includes: a third acquisition unit.

[0147] The third acquisition unit is used to determine the target parameters based on the user configuration information and the business scenario information.

[0148] In one embodiment of this application, the second acquisition unit specifically includes: a second statistical unit and a second determination unit. Wherein:

[0149] The second statistical unit is used to count the response time of all historical SQL query statements executed within the business scenario indicated by the business scenario information during the second historical time period, as well as the number of times the historical parameters corresponding to each historical SQL query statement appear.

[0150] The second determining unit is used to determine the target parameter based on the response time of all the historical SQL query statements and the number of times the historical parameters corresponding to each historical SQL query statement appear.

[0151] It should be noted that the information interaction and execution process between the above-mentioned devices / units are based on the same concept as the method embodiments of this application. For details on their specific functions and technical effects, please refer to the method embodiments section, and they will not be repeated here.

[0152] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0153] Figure 8 This is a schematic diagram of the structure of a terminal device provided in an embodiment of this application. Figure 8 As shown, the terminal device 8 of this embodiment includes: at least one processor 80 ( Figure 8 (Only one is shown) a processor, a memory 81, and a computer program 82 stored in the memory 81 and executable on the at least one processor 80, which, when executing the computer program 82, implements the steps in any of the above-described data query method embodiments.

[0154] The terminal device may include, but is not limited to, a processor 80 and a memory 81. Those skilled in the art will understand that... Figure 8 This is merely an example of terminal device 8 and does not constitute a limitation on terminal device 8. It may include more or fewer components than shown in the figure, or combine certain components, or different components, such as input / output devices, network access devices, etc.

[0155] The processor 80 may be a Central Processing Unit (CPU), or it may be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor.

[0156] In some embodiments, the memory 81 may be an internal storage unit of the terminal device 8, such as the RAM of the terminal device 8. In other embodiments, the memory 81 may be an external storage device of the terminal device 8, such as a plug-in hard drive, Smart Media Card (SMC), Secure Digital (SD) card, or Flash Card equipped on the terminal device 8. Furthermore, the memory 81 may include both internal and external storage units of the terminal device 8. The memory 81 is used to store the operating system, applications, bootloader, data, and other programs, such as the program code of the computer program. The memory 81 can also be used to temporarily store data that has been output or will be output.

[0157] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps described in the various method embodiments above.

[0158] This application provides a computer program product that, when run on a terminal device, enables the terminal device to implement the steps described in the various method embodiments above.

[0159] If the integrated unit is implemented as 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, all or part of the processes in the methods of the above embodiments of this application can be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include at least: any entity or device capable of carrying computer program code to a terminal device, a recording medium, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium. Examples include USB flash drives, portable hard drives, magnetic disks, or optical disks. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electrical carrier signals or telecommunication signals.

[0160] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0161] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.

Claims

1. A data query method, characterized in that, include: Obtain a data query request, which carries business scenario information and user configuration information; The user configuration information is used to characterize at least one data influence factor set by the user who sent the data query request, which corresponds to the business scenario information. Based on the business scenario information, a target SQL query statement is selected from multiple preset SQL query statements; the multiple preset SQL query statements correspond to different actual needs in the same business. Execute the target SQL query statement to obtain the data corresponding to the business scenario information; The step of selecting a target SQL query statement from multiple preset SQL query statements based on the business scenario information includes: Obtain preset target parameters associated with the business scenario information; the target parameters are used to describe the influence factors of the data corresponding to the business scenario information, and the target parameters are determined by the user configuration information and the business scenario information; Based on the target parameters, the target SQL query statement is selected from the plurality of preset SQL query statements; The step of selecting the target SQL query statement from the plurality of preset SQL query statements according to the target parameters includes: Based on the target parameters, select each candidate SQL query statement from the plurality of preset SQL query statements; The current value of the target parameter is detected; the current value refers to the execution result of the target SQL operation statement associated with each target parameter, and the current value changes dynamically in real time. Based on the current value, determine the score corresponding to each of the candidate SQL query statements; The candidate SQL query statement with the highest score is selected from all the candidate SQL query statements and used as the target SQL query statement.

2. The data query method as described in claim 1, characterized in that, The step of selecting the candidate SQL query statement with the highest score from the candidate SQL query statements as the target SQL query statement includes: If the number of candidate SQL queries with the highest score exceeds one, then the number of times each candidate SQL query with the highest score is executed and the response time are counted within the first historical time period. The target SQL query statement is selected from the candidate SQL query statements with the highest scores based on the number of times each statement is executed and the response time.

3. The data query method as described in claim 1, characterized in that, Each of the target parameters is pre-associated with at least one SQL operation statement. Before determining the score corresponding to each of the candidate SQL query statements based on the current value, the method further includes: Execute the target SQL operation statement associated with each of the target parameters respectively; The current value of each target parameter is updated based on the execution result of the target SQL operation statement associated with each target parameter.

4. The data query method as described in claim 1, characterized in that, The data query request also carries user configuration information, and the step of obtaining preset target parameters associated with the business scenario information includes: The target parameters are determined based on the user configuration information and the business scenario information.

5. The data query method according to any one of claims 1 to 4, characterized in that, The step of obtaining the preset target parameters associated with the business scenario information includes: The response time of all historical SQL query statements executed within the business scenario indicated by the business scenario information during the second historical time period is statistically analyzed, as well as the number of occurrences of the historical parameters corresponding to each historical SQL query statement. The target parameter is determined based on the response time of all historical SQL query statements and the number of occurrences of the historical parameters corresponding to each historical SQL query statement.

6. A data query device, characterized in that, include: The first acquisition unit is used to acquire a data query request, the data query request carrying business scenario information and user configuration information; The user configuration information is used to characterize at least one data influence factor set by the user who sent the data query request, which corresponds to the business scenario information. The first selection unit is used to select a target SQL query statement from multiple preset SQL query statements based on the business scenario information. The multiple preset SQL query statements correspond to different actual needs in the same business; The first execution unit is used to execute the target SQL query statement to obtain data corresponding to the business scenario information; The first selection unit specifically includes: The second acquisition unit is used to acquire preset target parameters associated with the business scenario information; the target parameters are used to describe the influence factors of the data corresponding to the business scenario information, and the target parameters are determined by the user configuration information and the business scenario information. The second selection unit is used to select the target SQL query statement from the plurality of preset SQL query statements according to the target parameters; The second selection unit specifically includes: The third selection unit is used to select each candidate SQL query statement from the plurality of preset SQL query statements according to the target parameters; The detection unit is used to detect the current value of the target parameter; the current value refers to the execution result of the target SQL operation statement associated with each of the target parameters, and the current value changes dynamically in real time. The first determining unit is used to determine the score corresponding to each of the candidate SQL query statements based on the current value. The fourth selection unit is used to select the candidate SQL query statement with the highest score from the candidate SQL query statements as the target SQL query statement.

7. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the data query method as described in any one of claims 1 to 5.

8. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the data query method as described in any one of claims 1 to 5.