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

By obtaining and sorting data in the database, determining index columns with the same sort according to preset conditions to determine the target value, the problem of low database query efficiency in the prior art is solved, and more efficient data query is achieved.

CN114064719BActive Publication Date: 2024-12-06CETC JINCANG (BEIJING) TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111342510.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-12
Publication Date
2024-12-06
Estimated Expiration
2041-11-12

AI Technical Summary

Technical Problem

The existing database query technology is inefficient, and all data needs to be traversed and aggregated functions to determine the target value, resulting in large amounts of calculations and low efficiency.

Method used

By obtaining the query request, obtaining at least two data in the database and sorting it, determining the index column with the same sort according to the preset conditions, determining the target value based on the index column, avoiding traversal and comparison of each data and aggregation function.

Benefits of technology

This reduces the amount of calculation, improves the efficiency of data query, and avoids the steps of traversal and aggregation function comparison.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114064719B_ABST
    Figure CN114064719B_ABST
Patent Text Reader

Abstract

The present disclosure relates to the technical field of database query, and provides a data query method, device, electronic device, medium and program product. The method comprises: obtaining a query request, wherein the query request is used to query data in a database; based on the database, obtaining at least two data in the database, and sorting them to obtain a first index column; according to a first preset condition, determining a second index column in the first index column, wherein the data in the second index column has the same sorting as the data in the first index column; based on the query request and the sorting of the data in the second index column, determining a target value in the second index column, wherein the target value is the maximum value of the data in the second index column, and / or the minimum value of the data in the second index column, and the target value is one or more of the at least two data in the database. This method can reduce the amount of calculation and improve the efficiency of data query.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the technical field of database query, and in particular to a data query method, device, electronic device, medium and program product. Background Art

[0002] At present, database systems are widely used in computer application technology. As the amount of data stored in the database increases, the efficiency of data query in the database becomes lower and lower. In the prior art, when querying data in the database, it is necessary to perform a traversal operation on all the data in the database to obtain at least two data in the database, and then call an aggregate function to compare the at least two data in the database to determine the target value in the database.

[0003] However, using the existing technology, it is necessary to traverse each data in the database and call the aggregation function for calculation, which leads to a large amount of calculation when determining the target value in the database and low efficiency. Summary of the invention

[0004] Based on this, it is necessary to provide a data query method, device, electronic device, medium and program product to address the above technical problems.

[0005] The present disclosure provides a data query method, the method comprising:

[0006] Obtaining a query request, wherein the query request is used to query data in a database;

[0007] Based on the database, at least two data in the database are acquired and sorted to obtain a first index column;

[0008] According to a first preset condition, determining a second index column in the first index column, wherein the data in the second index column has the same order as the data in the first index column;

[0009] Based on the query request and the sorting of the data in the second index column, a target value is determined in the second index column, wherein the target value is the maximum value of the data in the second index column and / or the minimum value of the data in the second index column, and the target value is one or more of at least two data in the database.

[0010] In one embodiment, before obtaining at least two data in the database based on the database and sorting them to obtain the first index column, the method further includes:

[0011] Determining whether the query request meets preset conditions, wherein the preset conditions include: the query request is an aggregate query request, and the database queried in the query request is single;

[0012] When the query request meets the preset condition, at least two data in the database are acquired based on the database, and the data are sorted to obtain a first index column.

[0013] In one embodiment, determining a target value in the second index column based on the query request and the order of the data in the second index column includes:

[0014] When the target value is the maximum value of the data in the second index column, determining whether the first parameter of the maximum value function in the query request is the second index column;

[0015] When the first parameter of the maximum value function is the second index column, based on the query request and the sorting of the data in the second index column, the maximum value is determined from the second index column in descending order.

[0016] In one embodiment, the method further comprises:

[0017] When the first parameter of the maximum value function is not the second index column, based on the first index column and the sorting of the data in the first index column, each data in the first index column is traversed in descending order, starting from the first data in the first index column, and each data in the first index column is acquired in sequence;

[0018] According to the first preset condition, a maximum value of the second index column is determined from the first index column.

[0019] In one embodiment, determining a target value in the second index column based on the query request and the order of the data in the second index column includes:

[0020] When the target value is the minimum value of the data in the second index column, determining whether the second parameter of the minimum value function in the query request is the second index column;

[0021] When the second parameter of the minimum function is the second index column, based on the query request and the sorting of the data in the second index column, the minimum value is determined from the second index column in ascending order.

[0022] In one embodiment, the method further comprises:

[0023] When the second parameter of the minimum function is not the second index column, based on the first index column and the sorting of the data in the first index column, each data in the first index column is traversed in ascending order, starting from the first data in the first index column, and each data in the first index column is acquired in sequence;

[0024] According to the first preset condition, a minimum value of the second index column is determined from the first index column.

[0025] The present disclosure provides a data query device, the device comprising:

[0026] A query request acquisition module, used to acquire a query request, wherein the query request is used to query data in a database;

[0027] A first index column acquisition module, used for acquiring at least two data in the database based on the database, and sorting the data to obtain a first index column;

[0028] A second index column determining module, configured to determine a second index column in the first index column according to a first preset condition, wherein the data in the second index column has the same order as the data in the first index column;

[0029] A target value determination module is used to determine a target value in the second index column based on the query request and the order of the data in the second index column, wherein the target value is the maximum value of the data in the second index column and / or the minimum value of the data in the second index column, and the target value is one or more of at least two data in the database.

[0030] An embodiment of the present disclosure provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps of a data query method provided by any embodiment of the present disclosure are implemented.

[0031] An embodiment of the present disclosure provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of a data query method provided by any embodiment of the present disclosure are implemented.

[0032] An embodiment of the present disclosure provides a computer program product. When the computer program product is run on a computer, the computer implements the steps of a data query method provided by any embodiment of the present disclosure.

[0033] The data query method, device, electronic device, medium and program product provided by the embodiments of the present disclosure adopt this method to obtain a query request, wherein the query request is used to query the data in the database; based on the database, at least two data in the database are obtained and sorted to obtain a first index column; according to a first preset condition, a second index column is determined in the first index column, wherein the data in the second index column has the same sort as the data in the first index column; based on the query request and the sort of the data in the second index column, a target value is determined in the second index column, wherein the target value is the maximum value of the data in the second index column, and / or the minimum value of the data in the second index column, and the target value is one or more of the at least two data in the database. In this way, by obtaining multiple data in the database and sorting them to obtain the first index column, further, after determining the second index column in the first index column that has the same sort as the data in the first index column, the target value is determined based on the sort of the data in the second index column and the query request, thereby avoiding the need to traverse each data in the prior art, and then calling the aggregation function to compare at least two data in the database to determine the target value, thereby reducing the amount of calculation and improving the efficiency of data query. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0035] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0036] Figure 1 A flowchart of a data query method provided by an embodiment of the present disclosure;

[0037] Figure 2 A flowchart of another data query method provided by an embodiment of the present disclosure;

[0038] Figure 3 A flowchart of another data query method provided by an embodiment of the present disclosure;

[0039] Figure 4 A flowchart of another data query method provided by an embodiment of the present disclosure;

[0040] Figure 5 A schematic diagram of the structure of a data query device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0041] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features in the embodiments can be combined with each other without conflict.

[0042] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.

[0043] At present, database systems are widely used in computer application technology. As the amount of data stored in the database increases, the efficiency of data query in the database becomes lower and lower. In the prior art, when querying data in the database, it is necessary to perform a traversal operation on all the data in the database to obtain at least two data in the database, and then call an aggregate function to compare the at least two data in the database to determine the target value in the database.

[0044] However, using the existing technology, it is necessary to traverse each data in the database and call the aggregation function for calculation, which leads to a large amount of calculation when determining the target value in the database and low efficiency.

[0045] Therefore, the present disclosure provides a data query method, by obtaining a query request, wherein the query request is used to query data in a database; based on the database, obtaining at least two data in the database and sorting them to obtain a first index column; according to a first preset condition, determining a second index column in the first index column, wherein the data in the second index column has the same sorting as the data in the first index column; based on the query request and the sorting of the data in the second index column, determining a target value in the second index column, wherein the target value is the maximum value of the data in the second index column, and / or the minimum value of the data in the second index column, and the target value is one or more of the at least two data in the database. In this way, by obtaining multiple data in the database and sorting them to obtain the first index column, further, after determining the second index column in the first index column that has the same sorting as the data in the first index column, the target value is determined based on the sorting in the second index column data and the query request, thereby avoiding the need to traverse each data in the prior art, and then calling an aggregate function to compare at least two data in the database to determine the target value, thereby reducing the amount of calculation and improving the efficiency of data query.

[0046] The data query method provided by the present disclosure can be applied to a data query device, which can be various electronic devices such as personal computers, laptops, smart phones, tablet computers and portable wearable devices. Optionally, the device can also be a functional module or functional entity in these electronic devices that can implement the data query method.

[0047] In one embodiment, Figure 1 As shown, Figure 1 A flowchart of a data query method provided in an embodiment of the present disclosure specifically includes the following steps:

[0048] S10: Get a query request.

[0049] The query request is used to query the data in the database. The query request is a statement generated according to the database query and the programming language, such as an SQL statement. For example, the SQL statement is, for example, "select * from Awhere id>10;", but not limited thereto, and the present disclosure does not specifically limit it. The above database is stored on the server, and the database can be stored in the form of a table or in a tree format, but not limited thereto, and the present disclosure does not specifically limit it.

[0050] S12: Based on the database, at least two data in the database are obtained and sorted to obtain a first index column.

[0051] Among them, the first index column is determined by sorting multiple data in the database. It can be sorted in order from large to small, or in order from small to large. The present disclosure does not specifically limit it, and relevant technical personnel in this field can set it according to actual conditions.

[0052] Specifically, for a database stored in a server, multiple data in the database are extracted and sorted, thereby obtaining an ordered first index column.

[0053] Exemplarily, the above-mentioned database is a data table A that stores student names, identifiers corresponding to student names, grades in various subjects, and rankings. Based on the data table A, the identifiers corresponding to the student names in the data table A are extracted. For example, the identifier (identification, id) is "5, 8, 1, 3, 2, 7, 4, 3". The multiple identifiers are sorted in ascending order to obtain the first index column. For example, the current first index column id1 is "1, 2, 3, 3, 4, 5, 7, 8", but is not limited to this. The present disclosure does not specifically limit it.

[0054] S14: Determine a second index column in the first index column according to a first preset condition.

[0055] The data in the second index column has the same order as the data in the first index column. The first preset condition refers to the preset condition set in the first index column to determine the second index column. For example, for the above-mentioned first index column id1 "1, 2, 3, 3, 4, 5, 7, 8", when the first preset condition is "id1>3", that is, a value greater than 3 in the first index column is obtained, thereby determining that the second index column id2 is "4, 5, 7, 8", or when the first preset condition is "id1<5", that is, a value less than 5 in the first index column is obtained, thereby determining that the second index column id2 is "1, 2, 3, 3, 4", but not limited to this, the present disclosure is not specifically limited, and the first preset condition can be set by those skilled in the art according to actual conditions.

[0056] Specifically, the server determines, according to the first preset condition and the first index column, a second index column having the same data order as the data in the first index column.

[0057] S16: Based on the query request and the order of the data in the second index column, determine a target value in the second index column.

[0058] The target value is the maximum value of the data in the second index column, and / or the minimum value of the data in the second index column, and the target value is one or more of at least two data in the database. Exemplarily, if the second index column id2 is "4, 5, 7, 8", the target value is the maximum value of the second index column id2, such as "8", or it can be the minimum value of the second index column id2, such as "4", but it is not limited to this, and the present disclosure does not specifically limit it.

[0059] Specifically, according to the acquired query request and the determined second index column, and in accordance with the order of the data in the second index column, the maximum value of the data in the second index column or the minimum value of the data in the second index column is determined in the second index column.

[0060] Thus, this embodiment obtains a query request, wherein the query request is used to query data in a database; based on the database, obtains at least two data in the database and sorts them to obtain a first index column; according to a first preset condition, determines a second index column in the first index column, wherein the data in the second index column has the same sort as the data in the first index column; based on the query request and the sort of the data in the second index column, determines a target value in the second index column, wherein the target value is the maximum value of the data in the second index column and / or the minimum value of the data in the second index column, and the target value is one or more of the at least two data in the database. Thus, by obtaining multiple data in the database and sorting them to obtain the first index column, further, after determining in the first index column a second index column having the same sort as the data in the first index column, the target value is determined based on the sort of the data in the second index column and the query request, thereby avoiding the need in the prior art to traverse each data, and then call an aggregate function to compare at least two data in the database to determine the target value, thereby reducing the amount of calculation and improving the efficiency of data query.

[0061] Figure 2 A flowchart of another data query method provided by an embodiment of the present disclosure is shown in FIG. Figure 2 is Figure 1 Based on the embodiment shown, further, as Figure 2 As shown: One implementation of S12 is:

[0062] S120: When it is determined that the query request meets the preset condition, based on the database, at least two data in the database are obtained and sorted to obtain a first index column.

[0063] Among them, the preset conditions include: the query request is an aggregate query request, and the database queried in the query request is single. Aggregate query request refers to a query method used for SQL statements, which summarizes data information of multiple rows through aggregate functions in SQL statements, such as min() and max() aggregate functions, and can quickly obtain query results through aggregate query. In addition, the database to be queried in the SQL statement is a single database, that is, each SQL statement can only query one database A when querying. Exemplarily, the SQL statement of the aggregate query request can be "select min (id) from A where id>10;", or it can also be "select min (id), max (id) from A where id>10;", but it is not limited to this, and the present disclosure does not specifically limit it.

[0064] Specifically, when the server determines that the query request input by the user is an aggregate query request and the database to be queried is a single, the server responds to the query request to obtain multiple data in the database, and sorts the multiple data in order from small to large, or from large to small, to obtain the first index column.

[0065] Thus, when performing data query, this embodiment needs to first determine the query request. When it is determined that the query request meets the preset conditions, further data query is performed to determine the target value, thereby improving the query execution speed.

[0066] Figure 3 A flowchart of another data query method provided in an embodiment of the present disclosure is shown below. Figure 3 is Figure 2 Based on the embodiment shown, further, based on the query request and the sorting of the data in the second index column, a possible implementation method for determining the target value in the second index column is described as follows: Figure 3 As shown:

[0067] S161a: When the target value is the maximum value of the data in the second index column.

[0068] S162a: Determine whether the first parameter of the maximum value function in the query request is the second index column.

[0069] Among them, the maximum value function refers to the aggregation function that needs to be called when a query is performed in a query request. The aggregation function can be, for example, the min(a) function for querying the minimum value and the max(b) function for querying the maximum value. The first parameter refers to the index column used to represent the query to be performed by the aggregation function. For example, for the minimum value min(a) function, the first parameter is a, or for the maximum value max(b), the first parameter is b, but it is not limited to this and the present disclosure does not specifically limit it.

[0070] Specifically, when the aggregation function in the query request is a maximum value function, that is, when the target value to be queried by the query request is the maximum value, it is determined whether the first parameter of the aggregation function in the query request, that is, the maximum value function, is the second index column.

[0071] S163a: When the first parameter of the maximum value function is the second index column, based on the query request and the sorting of the data in the second index column, determine the maximum value from the second index column in descending order.

[0072] Specifically, when it is determined that the first parameter in the maximum value function is the second index column, that is, when the maximum value function queries the maximum value in the second index column, according to the query request and the arrangement order of multiple data in the second index column, the query is performed from the largest data in descending order to determine the maximum value in the second index column.

[0073] For example, for the above-mentioned second index column id2 of "4, 5, 7, 8", when the maximum value function is max(id2), that is, the maximum value function needs to obtain the maximum value in the second index column id2, and at the same time, based on the data arrangement order in the second index column id2, the search is started from the largest data in descending order, so that the maximum value of the second index column is determined to be 8 in the second index column id2 of "4, 5, 7, 8", but it is not limited to this, and the present disclosure does not specifically limit it.

[0074] In this way, this embodiment determines the second index column in the first index column, and based on the ordered data in the second index column, calls the aggregate function to determine the maximum value in the ordered data in the second index column. By reducing the number of searched data and quickly determining the maximum value according to the order of the data, the amount of calculation can be reduced and the efficiency of data query can be improved.

[0075] Optionally, based on the above embodiment, in some embodiments of the present disclosure, when the first parameter of the maximum value function is not the second index column, such as Figure 3 As shown, one possible implementation is:

[0076] S164a: Based on the first index column and the sorting of the data in the first index column, traverse each data in the first index column in descending order, starting from the first data in the first index column, and obtain each data in the first index column in sequence.

[0077] Specifically, when it is determined that the first parameter of the maximum value function involved in the query request is not the second index column, that is, when the index column queried by the maximum value function is not the second index column, according to the first index column and based on the arrangement order of the data in the first index column, in descending order, starting from the first data in the first index column, that is, starting from the largest data in the first index column, each data in the first index column is traversed to obtain the data in the first index column in turn.

[0078] Exemplarily, the first index column id1 is "1, 2, 3, 3, 4, 5, 7, 8" and the second index column id2 is "1, 2, 3, 3, 4". When the maximum value function is max(id1), based on the order of arrangement of the data in the first index column id1, in descending order, starting from the largest data 8, a traversal operation is performed on each data in the first index column id1 to obtain the data in the first index column in turn, but not limited to this and the present disclosure does not specifically limit it.

[0079] S165a: According to the first preset condition, determine the maximum value of the second index column from the first index column.

[0080] Specifically, according to the first preset condition, when each data is traversed in the first index column in descending order, each time the maximum value function is called, a data is taken out from the first index column. When the first data taken out from the first index column meets the first preset condition, it is determined that the data currently taken out from the first index column is the maximum value in the second index column.

[0081] Exemplarily, the above-mentioned first index column id1 is "1, 2, 3, 3, 4, 5, 7, 8", when the first preset condition is "id1<5", then the second index column id2 is "1, 2, 3, 3, 4", and when the maximum value function is max(id1), then based on the data arrangement order in the first index column id1, in descending order, starting from the largest data 8, each data in the first index column id1 is traversed to obtain the data in the first index column in turn. When the first data taken out from the first index column satisfies less than 5, that is, when the data taken out from the first index column is 4, it is determined that the data 4 currently taken out from the first index column is the maximum value in the second index column, but is not limited to this, and the present disclosure is not specifically limited.

[0082] In this way, this embodiment traverses the data in the first index column in descending order and compares it with the first preset condition. When the first data taken out meets the first preset condition, because the second index column has the same arrangement order as the first index column, the current first data that meets the first preset condition is the maximum value of the second index column, thereby reducing the amount of calculation and improving the efficiency of data query.

[0083] Figure 4 A flowchart of another data query method provided in an embodiment of the present disclosure is shown below. Figure 4 is Figure 2 Based on the embodiment shown, further, based on the query request and the sorting of the data in the second index column, a possible implementation method for determining the target value in the second index column is described as follows: Figure 4 As shown:

[0084] S161b: When the target value is the minimum value of the data in the second index column.

[0085] S162b: Determine whether the second parameter of the minimum value function in the query request is the second index column;

[0086] Among them, the minimum function refers to the aggregation function that needs to be called when performing a query in a query request. The aggregation function is, for example, the minimum function min(a) function. The second parameter refers to the index column used to represent the query to be performed by the minimum function. Exemplarily, for the minimum min(a) function, the first parameter is a, but is not limited to this, and the present disclosure does not specifically limit it.

[0087] Specifically, when the aggregation function in the query request is a minimum function, that is, when the target value to be queried by the query request is a minimum value, it is determined whether the second parameter of the aggregation function in the query request, that is, the minimum function, is the second index column.

[0088] S163b: When the second parameter of the minimum function is the second index column, based on the query request and the sorting of the data in the second index column, determine the minimum value from the second index column in ascending order.

[0089] Specifically, when it is determined that the second parameter of the minimum function is the second index column, that is, when the minimum function queries the minimum value in the second index column, the query is performed from the smallest data in ascending order according to the query request and the arrangement order of multiple data in the second index column, so as to determine the minimum value in the second index column.

[0090] For example, for the above-mentioned second index column id2 of "4, 5, 7, 8", when the minimum function is max(id2), that is, the minimum function needs to obtain the minimum value in the second index column id2, and at the same time, based on the data arrangement order in the second index column id2, the search is started from the smallest data in ascending order, so as to determine that the minimum value of the second index column in the second index column id2 "4, 5, 7, 8" is 4, but it is not limited to this, and the present disclosure does not specifically limit it.

[0091] In this way, this embodiment determines the second index column in the first index column, and based on the ordered data in the second index column, calls the aggregate function to determine the minimum value in the ordered data in the second index column. By reducing the number of searched data and quickly determining the minimum value according to the order of the data, the amount of calculation can be reduced and the efficiency of data query can be improved.

[0092] Optionally, based on the above embodiment, in some embodiments of the present disclosure, when the second parameter of the minimum function is not the second index column, such as Figure 4 As shown, one possible implementation is:

[0093] S164b: Based on the first index column and the sorting of the data in the first index column, each data in the first index column is traversed in ascending order, starting from the first data in the first index column, and each data in the first index column is acquired in sequence.

[0094] Specifically, when it is determined that the second parameter of the minimum function involved in the query request is not the second index column, that is, when the index column queried by the minimum function is not the second index column, according to the first index column and based on the arrangement order of the data in the first index column, in ascending order, starting from the first data in the first index column, that is, starting from the smallest data in the first index column, each data in the first index column is traversed to obtain the data in the first index column in turn.

[0095] Exemplarily, the first index column id1 is "1, 2, 3, 3, 4, 5, 7, 8" and the second index column id2 is "4, 5, 7, 8". When the minimum function is max(id1), based on the order of arrangement of the data in the first index column id1, in ascending order, starting from the smallest data 1, a traversal operation is performed on each data in the first index column id1 to obtain the data in the first index column in turn, but not limited to this and the present disclosure does not specifically limit it.

[0096] S165b: According to the first preset condition, determine the minimum value of the second index column from the first index column.

[0097] Specifically, according to the first preset condition, when each data is traversed in the first index column in ascending order, each time the minimum function is called, a data is taken out from the first index column. When the first data that meets the first preset condition is taken out from the first index column, it is determined that the data currently taken out from the first index column is the minimum value in the second index column.

[0098] Exemplarily, the above-mentioned first index column id1 is "1, 2, 3, 3, 4, 5, 7, 8", when the first preset condition is "id1>3", the second index column id2 is "4, 5, 7, 8", and when the maximum value function is max(id1), based on the data arrangement order in the first index column id1, in ascending order, starting from the smallest data 1, each data in the first index column id1 is traversed to obtain the data in the first index column in turn. When the first data taken out from the first index column satisfies greater than 3, that is, when the data taken out from the first index column is 4, it is determined that the data 4 currently taken out from the first index column is the minimum value in the second index column, but is not limited to this, and the present disclosure is not specifically limited.

[0099] In this way, this embodiment traverses the data in the first index column in ascending order and compares it with the first preset condition. When the first data taken out meets the first preset condition, because the second index column has the same arrangement order as the first index column, the current first data that meets the first preset condition is the minimum value of the second index column, thereby reducing the amount of calculation and improving the efficiency of data query.

[0100] It should be understood that although Figure 1-Figure 4 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 1-Figure 4 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.

[0101] In one embodiment, Figure 5 As shown, a data query device is provided, including: a query request acquisition module 10, a first index column acquisition module 12, a second index column determination module 14 and a target value determination module 16.

[0102] The query request acquisition module 10 is used to acquire a query request, wherein the query request is used to query data in a database.

[0103] The first index column acquisition module 12 is used to acquire at least two data in the database based on the database, and sort them to obtain a first index column.

[0104] The second index column determining module 14 is used to determine a second index column in the first index column according to a first preset condition, wherein the data in the second index column has the same order as the data in the first index column.

[0105] The target value determination module 16 is used to determine the target value in the second index column based on the query request and the sorting of the data in the second index column, wherein the target value is the maximum value of the data in the second index column and / or the minimum value of the data in the second index column, and the target value is one or more of at least two data in the database.

[0106] In one implementation of an embodiment of the present invention, the device also includes a judgment module for judging whether the query request meets preset conditions, wherein the preset conditions include: the query request is an aggregate query request, and the database queried in the query request is single; when the query request meets the preset conditions, based on the database, at least two data in the database are obtained and sorted to obtain a first index column.

[0107] In one implementation of an embodiment of the present invention, the target value determination module 16 is specifically used to determine whether the first parameter of the maximum value function in the query request is the second index column when the target value is the maximum value of the data in the second index column; when the first parameter of the maximum value function is the second index column, based on the query request and the sorting of the data in the second index column, determine the maximum value from the second index column in descending order.

[0108] In an implementation of an embodiment of the present invention, the target value determination module 16 is specifically used to, when the first parameter of the maximum value function is not the second index column, based on the first index column and the sorting of the data in the first index column, traverse each data in the first index column in descending order, starting from the first data in the first index column, and obtain each data in the first index column in turn; determine the maximum value of the second index column from the first index column according to the first preset condition.

[0109] In one implementation of an embodiment of the present invention, the target value determination module 16 is specifically used to, when the target value is the minimum value of the data in the second index column, determine whether the second parameter of the minimum value function in the query request is the second index column; when the second parameter of the minimum value function is the second index column, based on the query request and the sorting of the data in the second index column, determine the minimum value from the second index column in ascending order.

[0110] In one implementation of an embodiment of the present invention, the target numerical determination module 16 is specifically used to, when the second parameter of the minimum function is not the second index column, based on the first index column and the sorting of the data in the first index column, traverse each data in the first index column in ascending order, starting from the first data in the first index column, and obtain each data in the first index column in turn; determine the minimum value of the second index column from the first index column according to a first preset condition.

[0111] In the above embodiment, the query request acquisition module 10 is used to obtain a query request, wherein the query request is used to query data in a database. The first index column acquisition module 12 is used to obtain at least two data in a database based on the database, and sort them to obtain a first index column. The second index column determination module 14 is used to determine the second index column in the first index column according to a first preset condition, wherein the data in the second index column has the same sorting as the data in the first index column. The target value determination module 16 is used to determine the target value in the second index column based on the query request and the sorting of the data in the second index column, wherein the target value is the maximum value of the data in the second index column, and / or the minimum value of the data in the second index column, and the target value is one or more of the at least two data in the database. In this way, by acquiring multiple data in the database and sorting them to obtain a first index column, further, after determining in the first index column a second index column having the same sort as the data in the first index column, the target value is determined based on the sort in the second index column data and the query request, thereby avoiding the need in the prior art to traverse each data and then call an aggregate function to compare at least two data in the database to determine the target value, thereby reducing the amount of calculation and improving the efficiency of data query.

[0112] For the specific definition of the data query device, please refer to the definition of the data query method above, which will not be repeated here. Each module in the above-mentioned data query device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0113] The present disclosure provides an electronic device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the data query method provided by the present disclosure can be implemented. For example, when the processor executes the computer program, the data query method provided by the present disclosure can be implemented. Figures 1 to 4 The technical solution of any of the method embodiments shown has similar implementation principles and technical effects, which will not be repeated here.

[0114] The present disclosure also provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the data query method provided by the embodiment of the present disclosure can be implemented. For example, when the computer program is executed by a processor, the data query method provided by the embodiment of the present disclosure can be implemented. Figures 1 to 4 The technical solution of any of the method embodiments shown has similar implementation principles and technical effects, which will not be repeated here.

[0115] The present disclosure provides a computer program product. When the computer program product is run on a computer, the computer can implement the data query method provided by the embodiment of the present disclosure when executing the computer. For example, the computer can implement Figures 1 to 4 The technical solution of any of the method embodiments shown has similar implementation principles and technical effects, which will not be repeated here.

[0116] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided by the present disclosure can include at least one of non-volatile and volatile memory. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory or optical memory, etc. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in various forms, such as static random access memory (SRAM) and dynamic random access memory (DRAM).

[0117] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0118] The above-mentioned embodiments only express several implementation methods of the present disclosure, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for ordinary technicians in this field, several variations and improvements can be made without departing from the concept of the present disclosure, and these all belong to the protection scope of the present disclosure. Therefore, the protection scope of the patent of the present disclosure shall be subject to the attached claims.

Claims

1. A data query method, characterized in that: include: Obtaining a query request, wherein the query request is used to query data in a database; Determining whether the query request satisfies a preset condition, wherein the preset condition includes: the query request is an aggregate query request, and the database queried in the query request is a single database; When the query request meets the preset condition, based on the database, at least two data in the database are acquired and sorted to obtain a first index column; According to a first preset condition, determining a second index column in the first index column, wherein the data in the second index column has the same order as the data in the first index column; Based on the query request and the sorting of the data in the second index column, a target value is determined in the second index column, wherein the target value is the maximum value of the data in the second index column and / or the minimum value of the data in the second index column, and the target value is one or more of at least two data in the database.

2. The method according to claim 1, characterized in that The determining a target value in the second index column based on the query request and the sorting of the data in the second index column includes: When the target value is the maximum value of the data in the second index column, determining whether the first parameter of the maximum value function in the query request is the second index column; When the first parameter of the maximum value function is the second index column, based on the query request and the sorting of the data in the second index column, the maximum value is determined from the second index column in descending order.

3. The method according to claim 2, characterized in that The method further comprises: When the first parameter of the maximum value function is not the second index column, based on the first index column and the sorting of the data in the first index column, each data in the first index column is traversed in descending order, starting from the first data in the first index column, and each data in the first index column is acquired in sequence; According to the first preset condition, a maximum value of the second index column is determined from the first index column.

4. The method according to claim 1, characterized in that The determining a target value in the second index column based on the query request and the sorting of the data in the second index column includes: When the target value is the minimum value of the data in the second index column, determining whether the second parameter of the minimum value function in the query request is the second index column; When the second parameter of the minimum function is the second index column, based on the query request and the sorting of the data in the second index column, the minimum value is determined from the second index column in ascending order.

5. The method according to claim 4, characterized in that The method further comprises: When the second parameter of the minimum function is not the second index column, based on the first index column and the sorting of the data in the first index column, each data in the first index column is traversed in ascending order, starting from the first data in the first index column, and each data in the first index column is acquired in sequence; According to the first preset condition, a minimum value of the second index column is determined from the first index column.

6. A data query device, characterized in that: include: A query request acquisition module, used to acquire a query request, wherein the query request is used to query data in a database; A judgment module, used to judge whether the query request meets a preset condition, wherein the preset condition includes: the query request is an aggregate query request, and the database queried in the query request is a single database; A first index column acquisition module, configured to acquire at least two data in the database based on the database and sort the data to obtain a first index column when the query request meets a preset condition; A second index column determining module, configured to determine a second index column in the first index column according to a first preset condition, wherein the data in the second index column has the same order as the data in the first index column; A target value determination module is used to determine a target value in the second index column based on the query request and the order of the data in the second index column, wherein the target value is the maximum value of the data in the second index column and / or the minimum value of the data in the second index column, and the target value is one or more of at least two data in the database.

7. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the data query method according to any one of claims 1 to 5 are implemented.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the data query method according to any one of claims 1 to 5 are implemented.

9. A computer program product, characterized in that When the computer program product is executed on a computer, the computer is enabled to execute the data query method according to any one of claims 1 to 5.