Query method of database system, storage medium and device

By obtaining the query column combination of the query statement from the database system and creating query paths using hash multi-column indexes or other indexes, the problem of insufficient optimization in the index calling process is solved, and query efficiency is improved.

CN116719843BActive Publication Date: 2025-11-07CETC JINCANG (BEIJING) TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310639992.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-05-31
Publication Date
2025-11-07
Estimated Expiration
2043-05-31

AI Technical Summary

Technical Problem

Existing database systems suffer from insufficient optimization during index retrieval, leading to difficulties in using hash multi-column indexes and low query efficiency.

Method used

By retrieving all query columns from the query statement, we can identify column combinations that exist in multi-column indexes, detect column combinations that meet preset conditions, and create query paths using hash multi-column indexes or other multi-column indexes. This ensures that index calls match precisely and avoids situations where hash multi-column indexes cannot find data.

Benefits of technology

It improves query efficiency, ensures the accurate application of hash multi-column indexes, optimizes index calling methods, and maintains the high efficiency of the query process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116719843B_ABST
    Figure CN116719843B_ABST
Patent Text Reader

Abstract

The application provides a query method of a database system, a storage medium and equipment. The query method of the database system comprises the following steps: obtaining a query statement, and extracting all query columns in the query statement; obtaining a column combination of the query columns existing in a multi-column index; obtaining a column combination with the largest number of query columns, and marking the column combination as a detection column combination; detecting whether a query condition corresponding to the detection column combination meets a preset condition; if the preset condition is met, obtaining index key values of all indexes starting from the detection column combination according to an index configuration of the database system, marking the indexes as a detection index set, and storing index types of the indexes and corresponding index key values in the index configuration; detecting and obtaining a hash multi-column index with the same number of index key values as the number of query columns in the detection column combination in the detection index set; and creating a query path by using the hash multi-column index. The hash multi-column index can be obtained only by accurate matching, and the query efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of database, in particular to a query method of database system, storage medium and equipment. BACKGROUND

[0002] In the use of database, querying the data of database is a common database operation. In the process of querying the data of database, the user needs to send a query statement to the database, and the database will parse the query statement after receiving the query statement, and then optimize it to generate the query path considered optimal by the system.

[0003] And for the optimization process of the query statement, the database can be configured to provide a query path generation method for the query statement. Indexes can be compared to book directories. When a table is indexed, the index can be used to quickly locate the query content during the query, thereby helping to speed up the query. However, the current index calling method of the optimizer has further optimization space. SUMMARY

[0004] An object of the present application is to provide a query method of database system for optimizing index calling method, storage medium and equipment.

[0005] A further object of the present application is to improve the selection efficiency of indexes.

[0006] In particular, the present application provides a query method of database system, comprising:

[0007] Obtaining a query statement and extracting all query columns in the query statement;

[0008] Obtaining a column combination of all query columns existing in a multi-column index;

[0009] Obtaining the column combination with the largest number of query columns in all column combinations, denoted as a detection column combination;

[0010] Detecting whether the detection column combination corresponds to a query condition that meets a preset condition;

[0011] If the preset condition is met, obtaining an index key value from the detection column combination according to the index configuration of the database system to obtain a detection index set, and the index configuration stores the index type and the corresponding index key value of the index;

[0012] Detecting and obtaining a hash multi-column index with the same number of index key values as the number of query columns in the detection column combination in the detection index set;

[0013] If a hash multi-column index is obtained, a query path is created by using the hash multi-column index.

[0014] Optionally, the step of detecting whether the query condition corresponding to the detection column combination meets the preset condition comprises the following steps of:

[0015] If the preset condition is not met, it is determined whether there is another column combination, if yes, the next column combination is selected in descending order of the number of query columns contained, and is recorded as the detection column combination.

[0016] The step of detecting whether the query condition corresponding to the detection column combination meets the preset condition is executed.

[0017] Optionally, the step of detecting and obtaining a hash multi-column index with the same number of index key values as the number of query columns in the detection column combination in the detection index set comprises the following steps of:

[0018] If no hash multi-column index is obtained, it is detected whether there is another multi-column index other than the hash multi-column index in the detection index set, if yes, a query path is created by using the other multi-column index, and if no, the step of determining whether there is another column combination is executed.

[0019] Optionally, the step of determining whether there is another column combination comprises the following steps of:

[0020] If no, it is detected whether there is a single-column index suitable for the query statement, if a single-column index is detected, a query path is created by using the single-column index.

[0021] Optionally, the step of detecting whether there is a single-column index suitable for the query statement comprises the following steps of:

[0022] If no single-column index is detected, a query path is created in a preset processing mode.

[0023] Optionally, the step of creating a query path in a preset processing mode comprises the following steps of:

[0024] A query path is created in a full table scanning mode.

[0025] Optionally, the step of creating a query path by using the hash multi-column index comprises the following steps of:

[0026] If a plurality of hash multi-column indexes are obtained, a plurality of query paths are created by using the plurality of hash multi-column indexes.

[0027] Optionally, the step of detecting whether the query condition corresponding to the column combination meets the preset condition comprises the following steps of:

[0028] The detection column combination corresponds to the query condition, and if the query condition is an equation, the query condition of the column combination meets the preset condition.

[0029] According to another aspect of the present application, there is also provided a machine readable storage medium having stored thereon a machine executable program which, when executed by a processor, implements the query method of the database system according to any one of the above.

[0030] According to yet another aspect of the present application, there is also provided a computer device comprising a memory, a processor, and a machine executable program stored on the memory and running on the processor, and the processor implements the query method of the database system according to any one of the above when executing the machine executable program.

[0031] The query method of the database system of the present application obtains all query columns in a query statement, and then obtains column combinations of the query columns existing in multi-column indexes, and records the column combination with the largest number of query columns as a detection column combination. The query condition corresponding to the detection column combination is detected to see if it meets a preset condition, and if it meets the preset condition, the index key values of all indexes starting from the detection column combination are obtained according to the index configuration of the database system, and are recorded as a detection index set, and the index type and corresponding index key values of the indexes are stored in the index configuration. The number of index key values in the detection index set is detected and the same number of hash multi-column indexes of the query columns in the detection column combination are obtained. If the hash multi-column indexes are obtained, a query path is created using the hash multi-column indexes. That is, the multi-column indexes can be preliminarily obtained according to the column combination in the query statement, and then it is determined whether there is an applicable hash multi-column index according to the type and number of index key values of the multi-column indexes. Thus, the hash multi-column indexes can only be obtained through exact matching, so that the hash multi-column indexes can be accurately applied, effectively avoiding the situation that the hash multi-column indexes cannot find data, and improving the query efficiency. Moreover, because the multi-column indexes are preliminarily obtained according to the column combination in the query statement, the selection of the multi-column indexes suitable for the leftmost matching is still maintained on the basis of the exact matching of the hash multi-column indexes. Thus, in the case that there is no hash multi-column index available, other multi-column indexes can be used to create a query path, thereby optimizing the index calling mode in the query process, which is conducive to ensuring the query efficiency.

[0032] The above and other objects, advantages and features of the present application will become more apparent from the following detailed description of specific embodiments thereof, when taken in conjunction with the accompanying drawings. BRIEF DESCRIPTION OF DRAWINGS

[0033] The following sections will describe some specific embodiments of the invention in detail by way of example and not limitation, with reference to the accompanying drawings. The same reference numerals in the drawings denote the same or similar parts or portions. Those skilled in the art should understand that these drawings are not necessarily drawn to scale. In the drawings:

[0034] Figure 1 This is a schematic flowchart of a query method for a database system according to an embodiment of the present invention;

[0035] Figure 2 This is a schematic flowchart of a query method for a database system according to another embodiment of the present invention;

[0036] Figure 3 This is a schematic flowchart of a query method for a database system according to yet another embodiment of the present invention;

[0037] Figure 4 This is a schematic flowchart of a query method for a database system according to yet another embodiment of the present invention;

[0038] Figure 5 This is a schematic diagram of a machine-readable storage medium according to an embodiment of the present invention;

[0039] Figure 6 This is a schematic diagram of a computer device according to an embodiment of the present invention. Detailed Implementation

[0040] Those skilled in the art should understand that the embodiments described below are merely a part of the embodiments of the present invention, and not all of the embodiments of the present invention. These partial embodiments are intended to explain the technical principles of the present invention and are not intended to limit the scope of protection of the present invention. Based on the embodiments provided by the present invention, all other embodiments obtained by those skilled in the art without creative effort should still fall within the scope of protection of the present invention.

[0041] It should be noted that the logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be specifically implemented in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus or device (such as a computer-based system, a processor-included system or other system that can fetch and execute instructions from, an instruction execution system, apparatus or device).

[0042] like Figure 1 As shown, in one embodiment, the query method of the database system generally includes:

[0043] Step S101, a query statement is acquired, and all query columns in the query statement are extracted. Specifically, for a query statement, a query condition field is included, and the query condition includes column names of columns to be queried and assignments. Extracting all query columns in the query statement means extracting all involved column names.

[0044] For example, the query statement is "select id, age from tb where id=10 and age=12", which indicates that data with id=10 and age=12 is searched from a table with a table name tb. Then, for the query statement, the columns to be queried are id and age, and the assignments are "=10" and "=12" respectively. Therefore, the query columns are id and age.

[0045] Step S102, column combinations existing in multi-column indexes in all query columns are acquired. Specifically, a multi-column index is an index created for two or more data columns. A column combination existing in a multi-column index means that query columns included in the column combination are included in data columns to which the multi-column index is directed.

[0046] For example, the query statement is "select id, age from tb where id=10 and age=12", and if a multi-column index for id and age columns exists, the column combination id and age can be acquired in the query statement, because id and age are both included in the multi-column index.

[0047] Or, if a multi-column index for id, age, and name columns exists, the column combination id and age can be acquired in the query statement, because id and age are both included in the multi-column index. If the query statement is "select id, age, name from tb where id=10 and age=12 and name=A", the column combinations are id and age, age and name, and id, age, and name.

[0048] Step S103, a column combination with the most query columns is acquired from all column combinations, and is recorded as a detected column combination. Specifically, a column combination with the most query columns is found from all column combinations, and is recorded as a detected column combination.

[0049] For example, the query statement is "select id, age from tb where id=10 and age=12", and if a multi-column index for id and age columns exists, the column combination id and age can be acquired in the query statement, and the detected column combination is id and age, because the query columns are at most two.

[0050] Or, if there is a multi-column index for the id, age and name columns, the column combination id and age can be obtained in the above query statement, and the column combination id and age is detected because the query columns are at most two. If the query statement is "select id, age, name from tb where id = 10 and age = 12 and name = A", the column combinations are id and age, age and name, and id, age and name, and the column combination id, age and name is detected.

[0051] In step S104, it is detected whether the query conditions corresponding to the detection column combination meet the preset condition. Specifically, it is detected whether the query conditions corresponding to the detection column combination are all equalities, and if so, the query conditions corresponding to the detection column combination meet the preset condition. That is, it is detected whether the assignments of the query columns in the detection column combination are all equalities, and if so, the query conditions of the detection column combination meet the preset condition.

[0052] For example, the query statement is "select id, age from tb where id = 10 and age = 12", if the detection column combination id and age is obtained, the query conditions corresponding to the detection column combination id and age are both equalities ("= 10" and "= 12"), so the detection column combination meets the preset condition.

[0053] In step S105, if the preset condition is met, the index key values are obtained according to the index configuration of the database system to detect all indexes starting from the detection column combination, denoted as a detection index set. The index configuration stores the index types of the indexes and the corresponding index key values. Specifically, for an index, it includes an index type and an index key value, which can be set in the creation statement when the index is created. For the indexes created by the database system, they are all recorded in the index configuration of the database system. The index type can be a hash index, a B+ tree index, etc. The index key value is the column to which the index is directed, for example, a multi-column index for the id and age columns, and the index key value is id and age.

[0054] Because the order of the index key values is one of the properties of the index when the index is created, the index whose index key value starts with the detection column combination is the index whose first index key value is the same as the detection column combination.

[0055] For example, the query statement is "select id, age from tb where id=10 and age=12", if the detection column combination is id and age, and the detection column combination meets the preset condition. Therefore, the first index key value is id and the second index key value is age. As for whether there are other index key values, it is not considered. All the indexes obtained are recorded as a detection index set.

[0056] In step S106, a hash multi-column index with the same number of index key values as the number of query columns in the detection column combination is detected and obtained. Specifically, whether there is a hash multi-column index in the detection index set is detected. If there is a hash multi-column index, whether the number of index key values of the hash multi-column index is the same as the number of detection columns is detected. If the number is the same, the hash multi-column index is obtained.

[0057] In step S107, if the hash multi-column index is obtained, the hash multi-column index is used to create a query path. If the corresponding hash multi-column index can be obtained, the hash multi-column index is used to create a query path.

[0058] Although the hash index is faster than other indexes in terms of query speed, because the hash multi-column index can only support exact matching, and the existing database system adopts the leftmost matching, the use of the hash multi-column index is difficult.

[0059] Specifically, for the leftmost matching principle, if the index key values of the multi-column index are id and age, even if the query condition of the query statement is only "id=10", it is still determined that the multi-column index can be used. That is, the leftmost matching means starting from the first key value of the index, any number of consecutive indexes can be matched. This is different from the exact matching principle of the hash multi-column index, because the hash multi-column index can only be used when all index key values appear and are equal. Therefore, the use of the hash multi-column index is difficult. For example, if the index key values of the hash multi-column index are id and age, even if the query condition of the query statement is only "id=10", because the existing leftmost matching principle is used, it is still determined that the hash multi-column index can be used, but the hash multi-column index cannot be used in fact, which will cause the query to fail to find data.

[0060] In the scheme of the embodiment, all query columns in the query statement are acquired, and then a column combination existing in the multi-column index in all query columns is acquired, a column combination with the largest number of query columns is recorded as a detection column combination. It is detected whether the query condition corresponding to the detection column combination meets a preset condition, if the preset condition is met, the index key value of the index starting from the detection column combination is acquired according to the index configuration of the database system, and the index is recorded as a detection index set, and the index type and the corresponding index key value of the index are stored in the index configuration. A hash multi-column index with the same number of index key values as the number of query columns in the detection column combination is detected and acquired. If the hash multi-column index is acquired, the query path is created by using the hash multi-column index.

[0061] That is, the multi-column index can be preliminarily acquired according to the column combination in the query statement, and then it is determined whether the applicable hash multi-column index exists according to the type and the number of index key values of the multi-column index. Thus, the hash multi-column index can be acquired only by accurate matching, so that the hash multi-column index can be accurately applied, and the situation that the hash multi-column index cannot find data is effectively avoided. Moreover, because the multi-column index is preliminarily acquired according to the column combination in the query statement, the selection of the multi-column index suitable for the leftmost matching is still maintained on the basis of the accurate matching of the hash multi-column index. Thus, in the case that the hash multi-column index is not available, other multi-column indexes can be used to create the query path, and thus the index calling mode in the query process is optimized, which is beneficial to guarantee the query efficiency.

[0062] For example, if the index configuration includes the hash multi-column index for id and age, and the B+ tree multi-column index for id and age. When the query statement is "select id, age from tb where id=10 and age=12", that is, the data of id=10 and age=12 is searched from the table with the table name tb. Then, for the query statement, the column combination is id and age, and the column combination meets the preset condition. The hash multi-column index for id and age, and the B+ tree multi-column index for id and age are both started from the detection column combination, so the two indexes are acquired and recorded as the detection index set. The hash multi-column index for id and age with the same number of index key values as the number of query columns in the detection column combination exists in the detection index set, so the query path is created by using the hash multi-column index.

[0063] For example, if there is a hash multi-column index for id, age and name in the index configuration. When the query statement is "select id, age from tb where id=10 and age=12", that is, to find the data with id=10 and age=12 from the table with the table name tb. For this query statement, first, it is detected that the column combination is id and age, and the column combination meets the preset condition. The hash multi-column index for id, age and name is started from the detected column combination, so this index is obtained, which is recorded as the detected index set. Because the hash multi-column index for id, age and name is inconsistent with the number of query columns of the detected column combination, it is determined that it cannot be used.

[0064] As shown in Figure 2 In an embodiment, the query method of the database system generally comprises:

[0065] In step S201, a query statement is obtained, and all query columns in the query statement are extracted.

[0066] In step S202, column combinations of all query columns existing in multi-column indexes are obtained.

[0067] In step S203, a column combination with the largest number of query columns among all column combinations is obtained, which is recorded as a detected column combination.

[0068] In step S204, it is detected whether the query conditions corresponding to the detected column combination meet the preset condition. If yes, step S205 is executed, and if no, step S208 is executed. Specifically, it is detected whether the query conditions corresponding to the detected column combination are all equalities. If yes, the query conditions corresponding to the detected column combination meet the preset condition.

[0069] In step S205, all indexes with the detected column combination as the starting point are obtained according to the index configuration of the database system, which is recorded as a detected index set.

[0070] In step S206, a hash multi-column index with the same number of index key values in the detected index set and the number of query columns in the detected column combination is detected and obtained.

[0071] In step S207, if the hash multi-column index is obtained, a query path is created by using the hash multi-column index.

[0072] Step S208, it is judged whether there is other column combination, if yes, step S209 is executed, if no, step S210 is executed. Specifically, it is judged whether there is column combination which has not been detected. If the query column of the query statement is more than three columns, there can be multiple column combinations. For example, if the query statement is "select id, age, name from tb where id=10 and age=12 and name=A", there can be column combination of id and age, age and name, and id, age and name.

[0073] Step S209, the next column combination is selected according to the order of the number of query columns contained from more to less, which is recorded as the detected column combination. That is, the next column combination is selected according to the order of the number of query columns contained from more to less, which is recorded as the detected column combination. Step S204 is executed.

[0074] That is, in the case that the current detected column combination does not meet the preset condition, the column combination is continuously selected from the column combination as the detected column combination for detection according to the order of the number of query columns from more to less.

[0075] Step S210, it is detected whether there is single column index suitable for the query statement, if yes, step S211 is executed, if no, step S212 is executed. Specifically, in the case that all column combinations of the query statement do not meet the preset condition, it is indicated that there is no available multi-column index for the query statement, and then it is detected whether there is available single column index for the query statement. The detection manner can regard the single query column of the query statement as the column combination, and the same detection manner as the column combination is adopted.

[0076] Step S211, the query path is created by using the single column index. If the suitable single column index can be obtained, the query path is created by using the single column index.

[0077] Step S212, the query path is created according to the preset processing manner. If the suitable single column index is not obtained, the query path can be created in the manner other than the index. For example, the query path is created in the manner of full table scanning, or the query path is created by using the view query manner, etc.

[0078] In the scheme of the embodiment, the column combination of the query statement is detected by selecting according to the order of the number of query columns contained from more to less. That is, in the case that there is applicable hash multi-column index, the hash multi-column index containing the most query columns of the query statement can be preferentially selected and called, so that the optimal query path is ensured to be created.

[0079] For example, if the index configuration contains hashed multi-column indexes for id, age, and score, as well as hashed multi-column indexes for id and age, and the query statement is "select id,age,score from tb where id=m andage=n and score=x", then for this query statement, the column combination includes id, age, and score, as well as id and age.

[0080] First, the detection column combination is id, age, and score, and the query conditions for this combination are all equality statements, meeting the preset conditions. The hash multi-column index for id, age, and score starts with this detection column combination, so this index is retrieved and denoted as the detection index set. Because the number of columns in the hash multi-column index for id, age, and score is the same as the number of columns in the query for the detection column combination, this hash multi-column index is used. The id and age column combination is no longer detected.

[0081] When the query is "select id,age,score from tb where id=m and age=n andscore>x", the column combinations include id, age, and score, as well as id and age. First, the column combination to be checked is id, age, and score, and the query conditions for these combinations are not all equal, which does not meet the preset conditions. Therefore, the column combination of id and age is selected as the check column combination, as both id and age are equal, meeting the preset conditions. The hash multi-column indexes for id, age, and score, and the hash multi-column index for id and age, both start with the check column combinations, so the indexes are obtained and denoted as the check index set. Because the number of columns in the hash multi-column index for id, age, and score is inconsistent with the number of columns in the check column combinations, it is not selected. Because the number of columns in the hash multi-column index for id and age is consistent with the number of columns in the check column combinations, this hash multi-column index is applied.

[0082] like Figure 3 As shown, in one embodiment, the query method of the database system generally includes:

[0083] Step S301: Obtain the query statement and extract all query columns from the query statement.

[0084] Step S302: Obtain the column combinations that exist in the multi-column index in all query columns.

[0085] Step S303: Obtain the column combination with the most query columns among all column combinations, and denote it as the detection column combination.

[0086] Step S304, detecting whether the query conditions corresponding to the detection column combination meet the preset condition, if yes, executing step S305, if no, executing step S310. Specifically, detecting whether the query conditions corresponding to the detection column combination are all equalities, if yes, the query conditions corresponding to the detection column combination meet the preset condition.

[0087] Step S305, acquiring index key values according to the index configuration of the database system to detect all indexes starting from the column combination, denoted as a detection index set.

[0088] Step S306, detecting and acquiring a hash multi-column index in which the number of index key values in the detection index set is the same as the number of query columns in the detection column combination.

[0089] Step S307, if the hash multi-column index is acquired, creating a query path using the hash multi-column index.

[0090] Step S308, if the hash multi-column index is not acquired, detecting whether there is another multi-column index other than the hash multi-column index in the detection index set, if yes, executing step S309 to create a query path using the other multi-column index, if no, executing step 310. Specifically, if there is no available hash multi-column index, detecting whether there is another multi-column index, such as a B+ tree index, etc., in the detection index set.

[0091] Step S309, creating a query path using the other multi-column index. Because the multi-column index other than the hash multi-column index does not need to guarantee that the number of index key values is the same as the number of query columns, as long as the query columns and the index key values can be matched from front to back. Therefore, under the condition that the detection column combination meets the preset condition, as long as there is another multi-column index, it must be available.

[0092] Step S310, judging whether there is another column combination, if yes, executing step S311, if no, executing step S312. Specifically, that is, judging whether there is a column combination that has not been detected.

[0093] Step S311, selecting the next column combination according to the number of query columns contained in descending order, denoted as a detection column combination. Executing step S304.

[0094] Step S312, detecting whether there is a single-column index suitable for the query statement, if yes, executing step S313, if no, executing step S314.

[0095] Step S313, creating a query path using the single-column index. If a suitable single-column index can be acquired, a query path is created using the single-column index.

[0096] Step S314, creating the query path according to the preset processing mode. If no suitable single-column index is obtained, the query path can be created in a mode other than the index. For example, the query path is created in a full table scanning mode, or the query path is created in a view query mode, etc.

[0097] As shown in FIG. 1, in one embodiment, the query method of the database system generally comprises the following steps: Figure 4

[0098] Step S401, obtaining the query statement and extracting all query columns in the query statement.

[0099] Step S402, obtaining the detection column combination. The detection column combination is the column combination of all query columns existing in the multi-column index.

[0100] Step S403, detecting whether the query conditions corresponding to the detection column combination meet the preset condition. If yes, step S404 is executed, and if no, step S405 is executed. Specifically, it is detected whether the query conditions corresponding to the detection column combination are all equalities. If yes, the query conditions corresponding to the detection column combination meet the preset condition.

[0101] Step S404, obtaining the index key values of all indexes starting from the detection column combination according to the index configuration of the database system, and recording the indexes as a detection index set.

[0102] Step S405, detecting whether the indexes in the index set are hash multi-column indexes. If yes, step S406 is executed. That is, it is detected in sequence whether the indexes in the detection index set are hash multi-column indexes.

[0103] Step S406, detecting whether the number of index key values of the hash multi-column index is consistent with the number of query columns of the detection column combination. If yes, step S407 is executed.

[0104] Step S407, creating the query path by using the hash multi-column index.

[0105] Specifically, in one embodiment, the step of creating the query path by using the hash multi-column index comprises the following steps. If a plurality of hash multi-column indexes are obtained, a plurality of query paths are created by using the plurality of hash multi-column indexes. Then, the optimal query path is selected by the optimizer according to the cost rule.

[0106] The embodiment also provides a machine readable storage medium and a computer device. Figure 5 FIG. 8 is a schematic diagram of a machine readable storage medium 10 according to one embodiment of the present application. Figure 6 FIG. 9 is a schematic diagram of a computer device 20 according to one embodiment of the present application.

[0107] ​The machine readable storage medium 10 has stored thereon a machine executable program 11 which, when executed by a processor, implements the query method of the database system of any of the above embodiments.

[0108] The computer device 20 can include a memory 210, a processor 220, and a machine executable program 11 stored on the memory 210 and running on the processor 220, and the processor 220 implements the query method of the database system of any of the above embodiments when executing the machine executable program 11.

[0109] It should be noted that the logic and / or steps represented in the flowcharts or otherwise described herein, for example, can be considered as a list of executable instructions for implementing logic functions, and can be specifically embodied in any machine readable storage medium for use by or in connection with an instruction execution system, apparatus or device, such as a computer-based system, processor- based system, or other system that can fetch the instructions from the instruction execution system, apparatus or device and execute the instructions, or in conjunction with which the instructions can be executed.

[0110] For the description of the present embodiment, the machine readable storage medium 10 can be any device that can contain, store, communicate, propagate or transport the program for use by or in connection with the instruction execution system, apparatus or device, or in conjunction with which the instructions can be executed. More specific examples (non-exhaustive list) of computer readable medium include the following: electrical connection having one or more wires (electronic devices), portable computer diskette (magnetic devices), random access memory (RAM), read only memory (ROM), erasable programmable read only memory (EPROM or flash memory), fiber optic device, and portable compact disk read only memory (CDROM). In addition, the machine readable storage medium 10 can even be paper or other suitable medium on which the program can be printed, as the program can be electronically obtained, for example, by optical scanning of the paper or other medium, followed by electronic conversion of the optical scanning into a data file, and then editing, interpreting or otherwise processing the data file as necessary to obtain the program, and then storing the program in a computer memory.

[0111] It should be understood that parts of the present application can be realized in hardware, software, firmware or a combination thereof. In the above described embodiments, a plurality of steps or methods can be realized by software or firmware stored in a memory and executed by a suitable instruction execution system.

[0112] The computer device 20 can be, for example, a server, a desktop computer, a notebook computer, a tablet computer, or a smartphone. In some examples, the computer device 20 can be a cloud computing node. The computer device 20 can be described in the general context of computer system-executable instructions, such as program modules, being executed by a computer system. Generally, program modules can include routines, programs, objects, components, logic, data structures, and so on that perform particular tasks or implement particular abstract data types. The computer device 20 can be practiced in distributed cloud computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed cloud computing environment, program modules can be located in local or remote computer system storage media including memory storage devices.

[0113] The computer device 20 can include a processor 220 adapted to execute instructions stored in memory 210, which provides instructions to operations of the processor 220 during operation. The processor 220 can be a single core processor, a multi-core processor, a computing cluster, or any number of other configurations. The memory 210 can include random access memory (RAM), read only memory, flash memory, or any other suitable memory systems.

[0114] The processor 220 can be connected through a system interconnect (e.g., PCI, PCI-Express, etc.) to an I / O interface adapted to connect the computer device 20 to one or more I / O devices (input / output devices). The I / O devices can include, for example, a keyboard and a pointing device, where the pointing device can include a touchpad or a touchscreen, among others. The I / O devices can be built-in components of the computer device 20, or can be devices externally connected to the computer device.

[0115] The processor 220 can also be linked through the system interconnect to a display interface adapted to connect the computer device 20 to a display device. The display device can include a display screen that is a built-in component of the computer device 20. The display device can also include a computer monitor, a television, or a projector, among others, that is externally connected to the computer device 20. Further, a network interface controller (NIC) can be adapted to connect the computer device 20 to a network through the system interconnect. In some embodiments, the NIC can use any suitable interface or protocol (such as Internet Small Computer System Interface, among others) to transfer data. The network can be a cellular network, a radio network, a wide area network (WAN), a local area network (LAN), or the Internet, among others. Remote devices can be connected to the computer device through the network.

[0116] The flowcharts provided by this application are not intended to indicate that the operations of the methods will be performed in any particular order, or that all of the operations of a method are included in every case. In addition, a method can include additional operations. Additional changes can be made to the above-described methods within the scope of the technical ideas provided by the present embodiment methods.

[0117] Thus, those skilled in the art will recognize that the present application has been well- illustrated and described by various examples, but that the present application is not limited to the embodiments disclosed herein, but is capable of several modifications and variations without departing from the scope of the present application. Accordingly, the scope of the present application should be understood and appreciated to cover all such modifications and variations.

Claims

1. A query method of a database system, comprising: obtaining a query statement, and extracting all query columns in the query statement; obtaining column combinations of all the query columns existing in multi-column indexes; obtaining a column combination with the largest number of query columns among all the column combinations, and recording the column combination as a detection column combination; detecting whether a query condition corresponding to the detection column combination meets a preset condition; if the preset condition is met, obtaining index key values of all indexes starting from the detection column combination according to an index configuration of the database system, recording the indexes as a detection index set, and the index configuration storing index types of indexes and corresponding index key values; detecting and obtaining a hash multi-column index with the same number of index key values as the number of query columns in the detection column combination in the detection index set; if the hash multi-column index is obtained, creating a query path by using the hash multi-column index.

2. The query method of a database system according to claim 1, wherein, The step of detecting whether the query condition corresponding to the detection column combination meets the preset condition comprises: if the preset condition is not met, determining whether there is another column combination, if yes, selecting a next column combination in order of the number of query columns contained from large to small, and recording the column combination as the detection column combination; performing the step of detecting whether the query condition corresponding to the detection column combination meets the preset condition.

3. The query method of a database system according to claim 2, wherein, The step of detecting and obtaining the hash multi-column index with the same number of index key values as the number of query columns in the detection column combination in the detection index set comprises: if the hash multi-column index is not obtained, detecting whether there is another multi-column index except the hash multi-column index in the detection index set, if yes, creating a query path by using the other multi-column index, and if no, performing the step of determining whether there is another column combination.

4. The query method of a database system according to claim 2, wherein, The step of determining whether there is another column combination comprises: if no, detecting whether there is a single-column index suitable for the query statement, if the single-column index is detected, creating a query path by using the single-column index.

5. The query method of a database system according to claim 4, wherein, The step of detecting whether there is a single-column index suitable for the query statement comprises: if the single-column index is not detected, creating a query path according to a preset processing mode.

6. The query method of a database system according to claim 5, wherein, The step of creating a query path according to the preset processing mode comprises: creating a query path in a full table scanning mode.

7. The query method of a database system according to claim 1, wherein, The step of creating a query path by using the hash multi-column index comprises: if a plurality of hash multi-column indexes are obtained, creating a plurality of query paths by using the plurality of hash multi-column indexes.

8. The query method of a database system according to Claim 1, wherein, The step of detecting whether the query condition corresponding to the detection column combination meets the preset condition comprises: detecting whether the query condition corresponding to the detection column combination is all equalities, if yes, the query condition corresponding to the column combination meets the preset condition. 9.A machine readable storage medium, having stored thereon a machine executable program, the machine executable program, when executed by a processor, implements the query method of the database system according to any one of claims 1 to 8.

10. A computer device comprising a memory, a processor, and a machine executable program stored on the memory and running on the processor, and the processor implements the query method of the database system according to any one of claims 1 to 8 when executing the machine executable program.

Citation Information

Patent Citations

  • Database index generation method, machine readable storage medium and computer equipment

    CN115374121A

  • Index establishment method and device

    US20180276264A1