WO2019085778A1 - 确定数据库中有效分区的方法、装置和系统 - Google Patents

确定数据库中有效分区的方法、装置和系统 Download PDF

Info

Publication number
WO2019085778A1
WO2019085778A1 PCT/CN2018/111172 CN2018111172W WO2019085778A1 WO 2019085778 A1 WO2019085778 A1 WO 2019085778A1 CN 2018111172 W CN2018111172 W CN 2018111172W WO 2019085778 A1 WO2019085778 A1 WO 2019085778A1
Authority
WO
WIPO (PCT)
Prior art keywords
condition
partition
sub
data partition
data
Prior art date
Application number
PCT/CN2018/111172
Other languages
English (en)
French (fr)
Inventor
魏闯先
涂继业
曾杰南
胡进
Original Assignee
阿里巴巴集团控股有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 阿里巴巴集团控股有限公司 filed Critical 阿里巴巴集团控股有限公司
Publication of WO2019085778A1 publication Critical patent/WO2019085778A1/zh
Priority to US16/860,872 priority Critical patent/US20200257675A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2365Ensuring data consistency and integrity
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • G06F16/278Data partitioning, e.g. horizontal or vertical partitioning
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2453Query optimisation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24553Query execution of query operations

Definitions

  • the present invention relates to the field of data processing, and in particular to a method, apparatus and system for determining an effective partition in a database.
  • partitioning the table that is, the table.
  • the data in the data is divided into multiple partitions (LIST partitions) according to a certain logic (the logic is usually "time").
  • the logic is usually "time"
  • each partition table stores part of the data.
  • querying the data in each table it is split into multiple partitions for query, and all the partition query results are summarized as the final result of querying the entire table.
  • Partitioned tables map different partitions to disk to balance I/O and improve overall system performance.
  • a predetermined train schedule includes three columns: id, start time, end time, and the "start time” column is used as the basis of the partition table, and the same All records of the day are placed in a partition table.
  • the query condition is the equivalent or range query of the "start time” column
  • the DBA or the user needs to calculate the partition table number that satisfies the condition according to the partition method, and modify the structure of the database.
  • the query statement increases the filter condition of the partition table; and when the query condition is a non-partitioned column, for example, when the query condition is a range query of the "end time” column, the query optimization cannot be performed.
  • the embodiments of the present invention provide a method, an apparatus, and a system for determining an effective partition in a database, so as to at least solve the existing technical problem that it is difficult to avoid invalid partition query, resulting in low query efficiency.
  • a method for determining a valid partition in a database includes: obtaining meta information of a data partition in a database, where the meta information includes: a region range value of the data partition; according to the query condition and the data The meta-information of the partition determines whether the data partition is a valid partition.
  • an apparatus for determining a valid partition in a database including: an obtaining module, configured to acquire meta information of a data partition in a database, where the meta information includes: an area range of the data partition a value determining module for determining whether the data partition is a valid partition according to the query condition and the meta information of the data partition.
  • a system for determining a valid partition in a database including: a server, configured to acquire meta information of a data partition in a database, where the meta information includes: a regional range value of the data partition
  • the database system is connected to the server and is used to determine whether the data partition is a valid partition according to the query condition and the meta information of the data partition.
  • a computer terminal comprising: a processor; and a memory coupled to the processor for providing an instruction to the processor to process a data partition in the database Meta-information, wherein the meta-information includes: an area range value of the data partition; and determining whether the data partition is a valid partition according to the query condition and the meta-information of the data partition.
  • a storage medium includes a stored program, wherein, when the program is running, the device where the storage medium is controlled performs the following method steps: acquiring meta information of the data partition in the database
  • the meta information includes: an area range value of the data partition; and determining, according to the query condition and the meta information of the data partition, whether the data partition is a valid partition.
  • a processor configured to run a program, wherein the program is executed to perform the following method steps: acquiring meta information of a data partition in a database, wherein the meta information includes : the area range value of the data partition; determining whether the data partition is a valid partition according to the query condition and the meta information of the above data partition.
  • the meta-information of the data partition in the database is obtained, where the meta-information includes: a region range value of the data partition; and determining whether the data partition is a valid partition according to the query condition and the meta-information of the data partition,
  • the query is executed, the purpose of querying the invalid partition is not needed, thereby realizing the technical effect of improving the query efficiency, thereby solving the existing technical problem that it is difficult to avoid invalid partition query, resulting in low query efficiency.
  • FIG. 1 is a schematic structural diagram of a system for determining an effective partition in a database according to Embodiment 1 of the present invention
  • FIG. 2 is a flow chart showing the steps of a method for determining an effective partition in a database according to Embodiment 2 of the present invention
  • FIG. 3 is a flow chart showing the steps of an optional method for determining an effective partition in a database according to Embodiment 2 of the present invention
  • FIG. 4 is a flow chart showing the steps of an optional method for determining an effective partition in a database according to Embodiment 2 of the present invention.
  • FIG. 5 is a flow chart showing the steps of an optional method for determining an effective partition in a database according to Embodiment 2 of the present invention.
  • FIG. 6 is a flow chart showing the steps of an optional method for determining an effective partition in a database according to Embodiment 2 of the present invention.
  • FIG. 7 is a schematic structural diagram of an apparatus for determining an effective partition in a database according to Embodiment 3 of the present invention.
  • FIG. 8 is a block diagram showing the hardware configuration of a computer terminal according to Embodiment 4 of the present invention.
  • Partition table refers to the data in the database table, physically deposited on many small "table spaces" called partitions, logically the database table is still a complete table.
  • Meta Information An element provides meta information about a page.
  • the tag is at the head of the document and contains no content.
  • the tag's attributes define the name/value pairs associated with the document.
  • Database Administrator A general term for the relevant staff involved in the management and maintenance of the database management system (DBMS). It is a branch of the operation and maintenance engineer and is responsible for the entire design of the business database from design and testing to deployment and delivery. Lifecycle management.
  • SQL Structured Query Language
  • FIG. 1 is a schematic structural diagram of a system for determining an effective partition in a database according to an embodiment of the present application.
  • the depicted structure is only an example of a suitable environment, and does not impose any limitation on the scope of use or function of the present application.
  • the system for determining valid partitions in the database should also not be interpreted as having any dependency or requirement on any of the components shown in Figure 1 or a combination thereof.
  • Embodiment 1 of the present application can be widely applied to the Internet.
  • the information age has arrived. Faced with the huge amount of data information that comes with information processing, it needs to be stored and processed, and the data storage structure of the database is continuously designed and optimized. Specifically, when the amount of data stored in the database continues to increase, when the scale exceeds a certain scale, the speed of querying the data will be slower, and the performance of the application will be degraded. Therefore, it is necessary to consider partitioning the table, and each partition table is considered. Part of the data is stored. When querying the data in each table, it will be split into multiple partitions for query. All the partition query results are summarized as the final result of querying the entire table.
  • the present application proposes a system for determining an effective partition in a database, and the system can achieve the purpose of not querying an invalid partition when performing a query, thereby realizing the technical effect of improving query efficiency, thereby solving the existing inevitable invalidity. Partition queries lead to technical problems with less efficient queries.
  • the query condition is “end time”
  • the difference between the end time and the start time is relatively small or relatively stable (for example, the start time). It is the departure time of the train, and the end time is the arrival time of the train.
  • the "end time” column of each LIST partition is relatively concentrated, and the technical effect of determining and cutting out a large number of invalid LIST partitions can be achieved, thereby improving the query performance.
  • FIG. 1 shows a schematic structural diagram of a system for determining an effective partition in a database.
  • the system includes: a server 10 and a database system 20.
  • the server 10 is configured to acquire meta-information of the data partition in the database, where the meta-information includes: an area range value of the data partition; the database system 20 is connected to the server 10, and is configured to perform meta-information according to the query condition and the data partition. Determine if the data partition is a valid partition.
  • the server 10 may be a cloud server (that is, a cloud server), and the database system 20 may be any type of database system, for example, an analytical database system.
  • the above database system supports massive data query, and can perform arbitrary analysis and statistics on any dimension of massive data, and supports high concurrency and low latency (millisecond response) queries.
  • the above data partition may be a table partition (that is, a LIST partition), and specifically, may be a column partition.
  • the above meta information may be meta information added when creating a LIST partition; the above area range value is a maximum value and a minimum value of each column of data in the LIST partition.
  • the server may implicitly establish a mapping relationship between the column value of each column of the LIST partition and the area code of the corresponding LIST partition.
  • the DBA does not need to manually modify the SQL according to the query condition, and according to the query condition and the mapping relationship, it can quickly determine whether the LIST partition is a valid partition.
  • the combined condition may be split into multiple sub-conditions, and the database system sequentially performs query according to multiple sub-conditions, and according to each sub-condition The result of the query of the condition, combined to obtain the query result of the combined condition.
  • the valid partition may be a partition that satisfies the query condition.
  • the query condition is a combined condition
  • the partition is determined to be a valid partition.
  • the condition result of the combined condition obtained is a valid result (true), that is, the LIST partition satisfies the query condition. Then, the LIST partition is determined to be a valid partition; otherwise, the LIST partition is determined to be an invalid partition.
  • the database system is further configured to directly trim the data partition into an invalid partition. Invalid partition.
  • the query performance is affected. If a LIST partition is queried according to multiple sub-conditions in the combined condition, it is determined that the LIST partition is an invalid partition, then each LIST is Before the partition performs the query, the LIST partition is directly cropped, and only the valid partition is queried when the query is executed, thereby improving the query performance.
  • the meta information of the data partition in the database is obtained by the server, wherein the meta information includes: the area range value of the data partition; and the database system connected to the server, according to the query condition and the element of the data partition Information to determine if the data partition is a valid partition.
  • the database system is further configured to: when creating a data partition of the database, traverse each data record of the database, and obtain an area range value of each data record; and record each data area The range value is saved to the meta information of the corresponding data partition, and the area range value of the data partition is obtained.
  • the above meta information may be cached in the memory in an actual system application to reduce the IO overhead in the query process.
  • the foregoing database system is further configured to determine whether the data partition is a valid partition by: obtaining, in the case that the query condition is a combined condition, at least one sub-condition included in the combined condition; The condition type, the condition value of the sub-condition is obtained; the condition result of the sub-condition is determined by comparing the condition value of the sub-condition with the area range value of the data partition, wherein the area range value of the data partition includes at least: the area maximum value and the area Minimum value; determines whether the data partition is a valid partition based on the conditional result of at least one sub-condition.
  • the combination condition may be composed of a plurality of sub-query conditions.
  • the combination condition is split into a plurality of sub-conditions for independent query, and the at least one sub-condition, that is, a sub-component of the combination condition.
  • the query condition can be understood as a single condition with respect to the combined condition.
  • the types of the foregoing sub-conditions may include, but are limited to, an equivalence condition, a range query condition, and other types of query conditions, and the condition value of the sub-condition is a judgment condition value corresponding to the type of the sub-condition.
  • the type of the sub-condition is an equivalence condition
  • the equivalence condition, the conditional result of the equivalence condition is a valid result (true), otherwise the conditional result of the equivalence condition is determined to be an invalid result (false).
  • the type of the sub-condition is a range query condition
  • the database system is further configured to determine whether the data partition is a valid partition by acquiring a conditional result of each sub-condition if the query condition includes multiple sub-conditions; if each sub-condition If the conditional result is a valid result, the data partition is determined to be a valid partition; if the conditional result of any one or more sub-conditions is an invalid result, the data partition is determined to be an invalid partition.
  • the database system is further configured to combine the conditional results of each sub-condition to obtain a conditional result of the combined condition.
  • the LIST partition is determined to be a valid partition, and the partition query may be performed without cropping the LIST partition; in another optional embodiment, If the result of the combination is false, it can be determined that the LIST partition is an invalid partition, and the query condition is not satisfied, and the database system directly crops the LIST partition without performing a partition query.
  • the database system is further configured to sequentially determine whether each data partition included in the database is a valid partition, wherein the current determined data is determined. If the partition is a valid partition, the corresponding partition query is executed. Otherwise, the data partition determined to be an invalid partition is cropped, and the next partition of the data is effectively partitioned until all data partitions in the database are determined. The decision is completed.
  • the condition value of the sub-condition is an arbitrary preset value
  • the database system is further configured to determine the condition result of the sub-condition by: : If the maximum value of the region is less than or equal to the condition value of the sub-condition, or the region minimum value is greater than or equal to the condition value of the sub-condition, the condition result of the sub-condition is determined to be an invalid result; otherwise, the condition result of the sub-condition is determined to be a valid result.
  • the present application further provides an optional implementation manner, in the case that the type of the sub-condition is a range query condition, the condition value of the sub-condition is a preset range value, wherein the database system is further used by the following manner Determining the condition result of the sub-condition: If the preset range value and the regional range value of the data partition have an intersection, the condition result of the sub-condition is determined to be a valid result; otherwise, the condition result of the sub-condition is determined to be an invalid result.
  • the type of the foregoing sub-condition is a range query condition
  • the condition value of the sub-condition is a preset range value (2, 4) as an example; if the maximum value of the column partition y is 6, The minimum value is 3, that is, the range from the minimum value to the maximum value of the data region is (3, 6), and the range value can be determined by comparing the condition value of the sub-condition with the region range value of the data partition (3, 6) If there is an intersection with the preset range value (2, 4), the condition result of the range condition is true.
  • condition of the sub-condition is still a range query condition
  • condition value of the sub-condition is a preset range value (2, 4) as an example; if the maximum value of the column partition y is 8 The minimum value is 5, that is, the range from the minimum value to the maximum value of the data area is (5, 8), and the range value (5, 8) and the preset range value (2, 4) can be determined by the comparison. If there is no intersection, the condition result of the range condition is false.
  • the database system determines that the condition result of the sub-condition is a valid result.
  • x, y, and z may be the sequence numbers of the data partitions.
  • the foregoing optional embodiments for the combination conditions and sub-conditions are only illustrative and are not limited thereto. The conditions of the query and the specific application environment are transformed and converted.
  • an embodiment of a method of determining an effective partition in a database is provided. It is noted that the steps illustrated in the flowchart of the figures may be performed in a computer system such as a set of computer executable instructions. Also, although logical sequences are shown in the flowcharts, in some cases the steps shown or described may be performed in a different order than the ones described herein.
  • the method for determining the effective partition in the database provided by the embodiment can be used in the process of querying multiple partitions in the database, without requiring the DBA to perceive the partition logic and manually rewriting the SQL, according to the query conditions and the database. Meta-information automatically determines and trims invalid partitions, which improves query performance for multiple partitions in the database.
  • FIG. 2 is a flow chart showing the steps of a method for determining an effective partition in a database according to Embodiment 2 of the present invention. As shown in FIG. 2, the method includes the following method steps:
  • Step S102 Obtain meta information of a data partition in the database, where the meta information includes: an area range value of the data partition.
  • the data partition may be a table partition (that is, a LIST partition), and specifically, may be a column partition; the meta information may be meta information added when creating a LIST partition; the foregoing area range The value is the maximum and minimum values of each column of data in the LIST partition.
  • the mapping relationship between the column value of each column of the LIST partition and the area code of the corresponding LIST partition may be implicitly established.
  • the DBA does not need to manually modify the SQL according to the query condition, and according to the query condition and the mapping relationship, it can quickly determine whether the LIST partition is a valid partition (that is, a partition that satisfies the query condition).
  • FIG. 3 is a flow chart of steps of an optional method for determining an effective partition in a database according to Embodiment 1 of the present invention. As shown in FIG. 3, step S102 is performed, that is, Before obtaining the meta information of the data partition in the database, the method further includes:
  • Step S100 when creating a data partition of the database, traversing each data record of the database, and obtaining an area range value of each data record;
  • Step S101 Save the area range value of each data record to the meta information of the corresponding data partition, and obtain the area range value of the data partition.
  • the above meta information may be cached in the memory in an actual system application to reduce the IO overhead in the query process.
  • Step S104 Determine, according to the query condition and the meta information of the data partition, whether the data partition is a valid partition.
  • the combined condition may be split into multiple sub-conditions, and the query is sequentially performed according to multiple sub-conditions, according to each sub-condition The result of the query is combined to obtain the query result of the combined condition.
  • the invalid partition may be a partition that does not satisfy the query condition of the DBA or the user, and the effective partition may be a partition that satisfies the query condition; the foregoing query condition may be selected and determined according to actual conditions.
  • the condition result of the combined condition obtained is a valid result (true), that is, the LIST partition satisfies the query condition. Then, the LIST partition is determined to be a valid partition; otherwise, the LIST partition is determined to be an invalid partition.
  • the method further includes: directly determining the invalid partition when determining that the data partition is an invalid partition. .
  • the query performance is affected. If a LIST partition is queried according to multiple sub-conditions in the combined condition, it is determined that the LIST partition is an invalid partition, then each LIST is Before the partition performs the query, the LIST partition is directly cropped, and only the valid partition is queried when the query is executed, thereby improving the query performance.
  • FIG. 4 is a flow chart of steps of an optional method for determining an effective partition in a database according to Embodiment 1 of the present invention.
  • step S104 that is, According to the query condition and the meta-information of the data partition, determining whether the data partition is a valid partition can be implemented by the following method steps:
  • step S1041 if the query condition is a combination condition, at least one sub-condition included in the combination condition is obtained.
  • the combination condition may be composed of a plurality of sub-query conditions.
  • the combination condition is split into a plurality of sub-conditions for independent query, and the at least one sub-condition, that is, a sub-component of the combination condition.
  • the query condition can be understood as a single condition with respect to the combined condition.
  • x, y, and z may be the sequence numbers of the data partitions.
  • the foregoing optional embodiments for the combination conditions and sub-conditions are only illustrative and are not limited thereto. The conditions of the query and the specific application environment are transformed and converted.
  • Step S1043 Obtain a condition value of the sub-condition according to the type of the sub-condition.
  • the type of the foregoing sub-conditions may include, but is limited to, an equivalence condition, a range query condition, and other types of query conditions, and the condition value of the sub-condition is set corresponding to the type of the sub-condition.
  • a judgment condition value may be included in the foregoing step S1043.
  • Step S1045 determining a condition result of the sub-condition by comparing the condition value of the sub-condition with the area range value of the data partition, wherein the area range value of the data partition includes at least: an area maximum value and a region minimum value.
  • the type of the sub-condition is an equivalence condition
  • the equivalence condition, the conditional result of the equivalence condition is a valid result (true), otherwise the conditional result of the equivalence condition is determined to be an invalid result (false).
  • the type of the sub-condition is a range query condition
  • Step S1047 determining whether the data partition is a valid partition based on the condition result of the at least one sub-condition.
  • FIG. 5 is a flow chart of steps of an optional method for determining an effective partition in a database according to Embodiment 1 of the present invention.
  • the foregoing step S1047 that is, Determining whether the data partition is a valid partition based on the condition result of the at least one sub-condition includes the following method steps:
  • Step S10471 Obtain a condition result of each sub-condition in a case where the query condition includes a plurality of sub-conditions.
  • step S10473 if the conditional result of each sub-condition is a valid result, it is determined that the data partition is a valid partition.
  • step S10475 if the condition result of any one or more sub-conditions is an invalid result, it is determined that the data partition is an invalid partition.
  • conditional results of each sub-condition are combined to obtain a conditional result of the combined condition.
  • the LIST partition is determined to be a valid partition, and the partition query may be performed without cropping the LIST partition; in another optional embodiment, If the result of the combination is false, it can be determined that the LIST partition is an invalid partition, and the query condition is not satisfied, and the LIST partition is directly cropped, and the query of the invalid partition is not required.
  • each data partition included in the database is an invalid partition, wherein, when determining that the currently determined data partition is a valid partition, Next, the corresponding partition query is executed. Otherwise, the data partition determined to be an invalid partition is cropped, and the next partition of the data is invalidated, until all data partitions in the database are determined.
  • the condition value of the sub-condition is an arbitrary preset value, wherein the step S1045, that is, the condition for comparing the sub-conditions
  • the value of the region range of the value and the data partition, and the conditional result of the sub-condition can be determined by the following method steps:
  • the condition result of the sub-condition is determined to be an invalid result
  • conditional result of the sub-condition is determined to be a valid result.
  • the type of the sub-condition is an equivalence condition
  • the present application further provides an optional implementation manner, in the case that the type of the sub-condition is a range query condition, the condition value of the sub-condition is a preset range value, wherein the foregoing step S1045, that is, through comparison
  • the condition value of the sub-condition and the area range value of the data partition, and the condition result of the sub-condition are determined by the following method steps:
  • condition result of the sub-condition is determined to be an invalid result.
  • the type of the foregoing sub-condition is a range query condition
  • the condition value of the sub-condition is a preset range value (2, 4) as an example; if the maximum value of the column partition y is 6, The minimum value is 3, that is, the range from the minimum value to the maximum value of the data region is (3, 6), and the range value can be determined by comparing the condition value of the sub-condition with the region range value of the data partition (3, 6) If there is an intersection with the preset range value (2, 4), the condition result of the range condition is true.
  • condition of the sub-condition is still a range query condition
  • condition value of the sub-condition is a preset range value (2, 4) as an example; if the maximum value of the column partition y is 8 The minimum value is 5, that is, the range from the minimum value to the maximum value of the data area is (5, 8), and the range value (5, 8) and the preset range value (2, 4) can be determined by the comparison. If there is no intersection, the condition result of the range condition is false.
  • conditional result of the sub-condition is determined to be a valid result if the type of the sub-condition is neither an equivalence condition nor a range query condition.
  • the present application obtains meta-information of a data partition in a database, where the meta-information includes: a region range value of the data partition; and according to the query condition and the meta-information of the data partition, further determining whether the data partition is Effective partitioning.
  • the embodiment provided by the present application creates a LIST partition
  • the meta information of the data partition in the database is increased, and when the query is executed, the meta information of the data partition in the database is obtained, and according to the meta information and the query condition, You can determine the partition number of the invalid partition that does not meet the conditions and automatically crop the invalid partition; you do not need DBA or user-aware partition logic and manually change the SQL, which can effectively improve query efficiency.
  • the solution provided by the foregoing embodiment of the present application achieves the purpose of not querying an invalid partition when performing a query, thereby achieving the technical effect of improving query efficiency, thereby solving the existing difficulty in avoiding invalid partition query, resulting in query efficiency. Lower technical issues.
  • FIG. 6 is a flow chart showing the steps of a method for determining an effective partition in a database according to Embodiment 1 of the present invention. As shown in FIG. The method can be implemented by the following method steps:
  • step S1 it is determined whether the query of all LIST partitions is completed.
  • step S1 whether the query of all LIST partitions is completed may be determined by using a SQL query statement. Specifically, if all the LIST partition queries have been completed, the query is ended; if all the LIST partition queries are not completed, Step S2 is performed.
  • step S2 a LIST partition is sequentially selected to query whether the LIST partition is a valid partition.
  • the query may be performed one by one.
  • the meta information of the LIST partition may be obtained, and then determining whether the LIST partition is a valid partition according to the query condition and the meta information.
  • the meta information includes: a range value (maximum value and minimum value) of the LIST partition.
  • step S3 if the query condition is a combination condition, the combination condition is split into at least one sub-condition.
  • At least one sub-condition that is, a sub-query condition constituting the above-mentioned combination condition, can be understood as a single condition with respect to the combination condition.
  • step S4 a sub-condition is sequentially selected.
  • step S5 the type of the sub-condition is determined.
  • condition value of the sub-condition may be acquired according to the type of the sub-condition.
  • the type of the sub-condition may include but is limited to: an equivalence condition, a range query condition, and other types of query conditions, and the condition value of the sub-condition is a judgment condition value corresponding to the type of the sub-condition.
  • the condition value of the sub-condition is any preset value; and when the type of the sub-condition is a range query condition, the sub-condition The condition value is the preset range value.
  • step S6 when it is determined that the type of the sub-condition is an equivalence condition, step S6 is performed, and if it is determined that the type of the sub-condition is a range query condition, step S7 is performed, and the type of the sub-condition is determined. In the case where it is neither an equivalence condition nor a range query condition, step S8 is performed.
  • step S6 it is determined whether the maximum value of the region is less than or equal to the sub-condition value, or whether the region minimum value is greater than or equal to the condition value.
  • step S61 if the region maximum value is less than or equal to the condition value of the sub-condition, or the region minimum value is greater than or equal to the condition value of the sub-condition, the determination result of step S61 is obtained; otherwise, the determination result of step S63 is obtained.
  • step S61 the condition result is a valid partition.
  • the above condition result is a conditional result of the equivalence condition.
  • step S63 the condition result is an invalid partition.
  • the above condition result is a conditional result of the equivalence condition.
  • step S7 it is determined that the preset range value and the regional range value of the LIST partition have an intersection.
  • the above area range value is a range value ranging from a minimum value to a maximum value of the LIST partition.
  • step S71 if there is an intersection between the preset range value and the range value of the minimum value of the LIST partition to the maximum value, the determination result of step S71 is obtained; otherwise, the determination result of step S73 is obtained.
  • step S71 the condition result is a valid partition.
  • the above condition result is a condition result of the range query condition.
  • step S73 the condition result is an invalid partition.
  • the above condition result is a condition result of the range query condition.
  • step S8 the condition result is a valid partition.
  • step S8 if the type of the sub-condition is neither an equivalence condition nor a range query condition, all the obtained condition results are valid partitions.
  • step S9 is performed.
  • step S9 it is judged whether the query of all the sub-conditions is completed.
  • step S10 is performed, and if it is determined that the query of any one or more of the sub-conditions is not completed, the process returns to step S4 to continue the unfinished query. Query any one or more of the sub-conditions.
  • each data partition included in the database is a valid partition, wherein, when determining that the currently determined data partition is a valid partition, Next, the corresponding partition query is executed. Otherwise, the data partition determined to be an invalid partition will be cropped, and the next partition of the data partition in the database will be validly partitioned until all data partitions in the database are completed.
  • step S10 it is judged whether the condition result of the combination result is a valid result.
  • the query condition includes multiple sub-conditions, it is necessary to obtain the condition result of each sub-condition; as an optional embodiment, if the conditional result of each sub-condition is a valid result, it is determined The LIST partition is a valid partition; if the condition result of any one or more sub-conditions is invalid, it is determined that the LIST partition is an invalid partition.
  • step S11 if it is determined that the condition result of the combination result is a valid result, step S11 is performed; if it is determined that the condition result of the combination result is an invalid result, if the LIST partition is determined to be an invalid partition, the invalid LIST is directly cut. Partition, and return to step S1 to continue to determine whether to complete the query of all LIST partitions.
  • the purpose of improving the query efficiency is achieved by performing the query without querying the invalid partition, thereby solving the existing problem that the invalid partition query is difficult to avoid, resulting in the query. Less efficient technical issues.
  • the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course, by hardware, but in many cases, the former is A better implementation.
  • the technical solution of the present invention which is essential or contributes to the prior art, may be embodied in the form of a software product stored in a storage medium (such as ROM/RAM, disk,
  • the optical disc includes a number of instructions for causing a terminal device (which may be a cell phone, a computer, a server, or a network device, etc.) to perform the methods of various embodiments of the present invention.
  • FIG. 7 is a schematic structural diagram of an apparatus for determining an effective partition in a database according to Embodiment 3 of the present invention, As shown in FIG. 7, the device includes: an obtaining module 60 and a determining module 62, wherein
  • the obtaining module 60 is configured to obtain meta-information of the data partition in the database, where the meta-information includes: an area range value of the data partition; and the determining module 62 is configured to determine whether the data partition is valid according to the query condition and the meta-information of the data partition. Partition.
  • the foregoing obtaining module 60 and determining module 62 correspond to steps S102 to S104 in Embodiment 2, and the two modules are the same as the examples and application scenarios implemented by the corresponding steps, but are not limited to the above embodiments. 2 published content. It should be noted that the above module can be operated as a part of the device in the computer terminal provided in Embodiment 4.
  • the application is configured to obtain meta-information of a data partition in a database by setting an obtaining module, where the meta-information includes: a region range value of the data partition; and a determining module, configured to use the query condition And the meta-information of the data partition to determine whether the data partition is a valid partition.
  • the embodiment provided by the present application creates a LIST partition
  • the meta information of the data partition in the database is increased, and when the query is executed, the meta information of the data partition in the database is obtained, and according to the meta information and the query condition, You can determine the partition number of the invalid partition that does not meet the conditions and automatically crop the invalid partition; you do not need DBA or user-aware partition logic and manually change the SQL, which can effectively improve query efficiency.
  • the solution provided by the foregoing embodiment of the present application achieves the purpose of not querying an invalid partition when performing a query, thereby achieving the technical effect of improving query efficiency, thereby solving the existing difficulty in avoiding invalid partition query, resulting in query efficiency. Lower technical issues.
  • the determining module 62 includes: a first acquiring unit 621, a second obtaining unit 623, a first determining unit 625, and a second determining unit 627, where
  • a first obtaining unit 621 configured to obtain at least one sub-condition included in the combination condition if the query condition is a combination condition
  • a second acquisition unit 623 configured to acquire a condition value of the sub-condition according to the type of the sub-condition
  • a determining unit 625 configured to determine a condition result of the sub-condition by comparing a condition value of the sub-condition with a region range value of the data partition, where the region range value of the data partition includes at least: a region maximum value and a region minimum value
  • the determining unit 627 is configured to determine whether the data partition is a valid partition based on the condition result of the at least one sub condition.
  • first acquiring unit 621, the second obtaining unit 623, the first determining unit 625, and the second determining unit 627 correspond to steps S1041 to S1047 in Embodiment 2, and the two modules and corresponding
  • the example implemented by the step is the same as the application scenario, but is not limited to the content disclosed in Embodiment 2 above.
  • the above module can be operated as a part of the device in the computer terminal provided in Embodiment 4.
  • the condition value of the sub-condition is an arbitrary preset value, wherein, as shown in FIG. 7, the first determining unit 625, The first determining subunit 6251 and the second determining subunit 6253, wherein
  • the first determining subunit 6251 is configured to determine that the condition result of the sub condition is an invalid result if the area maximum value is less than or equal to the condition value of the sub condition, or the area minimum value is greater than or equal to the condition value of the sub condition; the second determining subunit 6253, if the condition that the maximum value of the region is greater than the sub-condition, or the minimum value of the region is less than the condition value of the sub-condition, determining that the condition result of the sub-condition is a valid result.
  • the condition value of the sub-condition is a preset range value, wherein, as shown in FIG. 7, the first determining unit 625, The third determining subunit 6255 and the fourth determining subunit 6257, wherein
  • the third determining sub-unit 6255 is configured to determine, if the preset range value and the regional range value of the data partition have an intersection, the condition result of the sub-condition is a valid result; and the fourth determining sub-unit 6257 is configured to use the preset range If there is no intersection between the value and the range value of the data partition, then the condition result of the sub-condition is determined to be invalid.
  • conditional result of the sub-condition is determined to be a valid result if the type of the sub-condition is neither an equivalence condition nor a range query condition.
  • the foregoing second determining unit 627 includes: an obtaining subunit 6271, a fifth determining subunit 6273, and a sixth determining subunit 6275, where
  • the obtaining subunit 6271 is configured to obtain a condition result of each sub-condition if the query condition includes a plurality of sub-conditions; and a fifth determining sub-unit 6273, if the condition result of each sub-condition is a valid result, The data partition is determined to be a valid partition; a sixth determining sub-unit 6275 is configured to determine that the data partition is an invalid partition if the conditional result of any one or more of the sub-conditions is an invalid result.
  • the foregoing obtaining subunit 6271, the fifth determining subunit 6273, and the sixth determining subunit 6275 correspond to the steps S10471 to S10475 in Embodiment 2, and the two modules and the corresponding steps are implemented by the corresponding steps. It is the same as the application scenario, but is not limited to the content disclosed in the above embodiment 2. It should be noted that the above module can be operated as a part of the device in the computer terminal provided in Embodiment 4.
  • the foregoing apparatus further includes: an executing module 64, configured to directly trim the invalid partition if the data partition is determined to be an invalid partition.
  • the foregoing apparatus further includes: a traversing module 56 and a saving module 58, wherein
  • the traversing module 56 is configured to: traverse each data record of the database when the data partition of the database is created, and obtain an area range value of each data record; the saving module 58 is configured to save the area range value of each data record to In the meta information of the corresponding data partition, the area range value of the data partition is obtained.
  • the traversal module 56 and the save module 58 correspond to the steps S100 to S101 in the embodiment 2, and the two modules are the same as the examples and application scenarios implemented by the corresponding steps, but are not limited to the above embodiments. 2 published content. It should be noted that the above module can be operated as a part of the device in the computer terminal provided in Embodiment 4.
  • each data partition included in the database is a valid partition, wherein, when determining that the currently determined data partition is a valid partition, Next, the corresponding partition query is executed. Otherwise, the data partition determined to be an invalid partition will be cropped, and the next partition of the data partition in the database will be validly partitioned until all data partitions in the database are completed.
  • Embodiments of the present invention may provide a computer terminal, which may be any one of computer terminal groups.
  • the foregoing computer terminal may also be replaced with a terminal device such as a mobile terminal.
  • the computer terminal may be located in at least one network device of the plurality of network devices of the computer network.
  • Fig. 8 is a block diagram showing the hardware structure of a computer terminal.
  • computer terminal 12 may include one or more (shown in the Figures 122a, 122b, ..., 122n) processor 122 (processor 122 may include, but is not limited to, a microprocessor MCU or programmable A processing device such as a logic device FPGA, a memory 124 for storing data, and a transmission device 126 for communication functions.
  • processor 122 may include, but is not limited to, a microprocessor MCU or programmable A processing device such as a logic device FPGA, a memory 124 for storing data, and a transmission device 126 for communication functions.
  • it can also include: display, input/output interface (I/O interface), universal serial bus (USB) port (which can be included as one of the ports of the I/O interface), network interface, power supply And / or camera.
  • I/O interface input/output interface
  • USB universal serial bus
  • FIG. 8 is merely illust
  • processors 122 and/or other data processing circuits may be referred to herein generally as "data processing circuits.”
  • the data processing circuit may be embodied in whole or in part as software, hardware, firmware or any other combination.
  • the data processing circuitry can be a single, separate processing module, or all or part of any of the other components incorporated into computer terminal 12.
  • the data processing circuit is controlled as a processor (e.g., selection of a variable resistance terminal path connected to the interface).
  • the processor 122 may call the memory stored information and the application program by the transmission device to perform the following steps: acquiring meta information of the data partition in the database, where the meta information includes: a region range value of the data partition; according to the query condition and the foregoing The meta-information of the data partition determines whether the above data partition is a valid partition.
  • the memory 124 can be used to store software programs and modules of the application software, such as the program instructions/data storage devices corresponding to the method for determining effective partitions in the database in the embodiment of the present application, and the processor 122 runs the software programs stored in the memory 124 and The module, thereby performing various functional applications and data processing, implements the above-described method of determining valid partitions in a database.
  • Memory 124 may include high speed random access memory and may also include non-volatile memory such as one or more magnetic storage devices, flash memory, or other non-volatile solid state memory.
  • memory 124 may further include memory remotely located relative to processor 122, which may be coupled to computer terminal 12 via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
  • Transmission device 126 is for receiving or transmitting data via a network.
  • the network specific examples described above may include a wireless network provided by a communication provider of the computer terminal 12.
  • transmission device 126 includes a Network Interface Controller (NIC) that can be connected to other network devices through a base station to communicate with the Internet.
  • NIC Network Interface Controller
  • the transmission device 126 can be a Radio Frequency (RF) module for communicating wirelessly with the Internet.
  • RF Radio Frequency
  • the display can be, for example, a touch screen liquid crystal display (LCD) that enables a user to interact with a user interface of computer terminal 12.
  • LCD liquid crystal display
  • the computer terminal 12 shown in FIG. 8 above may include hardware components (including circuits), software components (including computer code stored on a computer readable medium), or A combination of both hardware and software components. It should be noted that FIG. 8 is only one example of a specific embodiment, and is intended to show the types of components that may be present in the computer terminal 12 described above.
  • the computer terminal may execute the program code of the following steps in the method for determining the effective partition in the database of the application: acquiring meta information of the data partition in the database, where the meta information includes: an area range value of the data partition; Determine whether the data partition is a valid partition based on the query conditions and the meta-information of the data partition.
  • the processor may invoke the memory stored information and the application program by the transmission device to perform the following steps: acquiring meta information of the data partition in the database, where the meta information includes: a region range value of the data partition; according to the query condition and the data partition Meta information to determine if the data partition is a valid partition.
  • the foregoing processor may further execute the following program code: if the query condition is a combined condition, obtain at least one sub-condition included in the combined condition; and obtain a condition value of the sub-condition according to the type of the sub-condition; Comparing the condition value of the sub-condition with the region range value of the data partition, determining a condition result of the sub-condition, wherein the region range value of the data partition includes at least: a region maximum value and a region minimum value; and a condition result based on the at least one sub-condition, Determine if the data partition is a valid partition.
  • the foregoing processor may further execute the following program code: if the maximum value of the region is less than or equal to the condition value of the sub-condition, or the region minimum value is greater than or equal to the condition value of the sub-condition, determining that the condition result of the sub-condition is invalid The result; otherwise, the conditional result of the sub-condition is determined to be a valid result.
  • the foregoing processor may further execute the following program code: if the preset range value and the regional range value of the data partition have an intersection, determining a condition result of the sub-condition is a valid result; otherwise, determining a condition of the sub-condition The result is invalid.
  • the foregoing processor may further execute the program code of the following steps: determining that the condition result of the sub-condition is a valid result if the type of the sub-condition is neither an equivalence condition nor a range query condition.
  • the foregoing processor may further execute the following program code: if the query condition includes multiple sub-conditions, obtain a condition result of each sub-condition; if the condition result of each sub-condition is a valid result, Determine that the data partition is a valid partition; if the conditional result of any one or more sub-conditions is invalid, determine that the data partition is an invalid partition.
  • the foregoing processor may further execute the following program code: directly determine the invalid partition when the data partition is determined to be an invalid partition.
  • the foregoing processor may further execute the following program code: when creating a data partition of the database, traverse each data record of the database, and obtain a range value of each data record; and record each data area The range value is saved to the meta information of the corresponding data partition, and the area range value of the data partition is obtained.
  • the foregoing processor may further execute the following program code: in the process of executing the query statement of the database, it is required to sequentially determine whether each data partition included in the database is a valid partition, wherein the current determined data is determined. If the partition is a valid partition, the corresponding partition query is executed. Otherwise, the data partition determined to be an invalid partition is cropped, and the next partition of the data is effectively partitioned until all data partitions in the database are determined. The decision is completed.
  • a scheme for determining an effective partition in a database is provided.
  • the meta-information includes: a region range value of the data partition; determining whether the data partition is a valid partition according to the query condition and the meta-information of the data partition, thereby achieving that when the query is executed,
  • the purpose of querying invalid partitions is to solve the existing technical problem that it is difficult to avoid invalid partition query, resulting in low query efficiency.
  • FIG. 8 is only an illustration, and the computer terminal can also be a smart phone (such as an Android mobile phone, an iOS mobile phone, etc.), a tablet computer, an applause computer, and a mobile Internet device (Mobile Internet Devices, MID). ), PAD and other terminal devices.
  • FIG. 8 does not limit the structure of the above electronic device.
  • computer terminal 12 may also include more or fewer components (such as a network interface, display device, etc.) than shown in FIG. 8, or have a different configuration than that shown in FIG.
  • Embodiments of the present invention also provide a storage medium.
  • the foregoing storage medium may be used to save the program code executed by the method for determining a valid partition in the database provided by Embodiment 1 above.
  • the foregoing storage medium may be located in any one of the computer terminal groups in the computer network, or in any one of the mobile terminal groups.
  • the storage medium is configured to store program code for performing the following steps: acquiring meta information of the data partition in the database, wherein the meta information includes: a region range value of the data partition; according to the query condition And the meta-information of the data partition to determine whether the data partition is a valid partition.
  • the storage medium is configured to store program code for performing the following steps: in case the query condition is a combined condition, obtaining at least one sub-condition included in the combined condition; according to the type of the sub-condition Obtaining a condition value of the sub-condition; determining a condition result of the sub-condition by comparing the condition value of the sub-condition with the area range value of the data partition, wherein the area range value of the data partition includes at least: an area maximum value and a region minimum value; Based on the conditional result of the at least one sub-condition, it is determined whether the data partition is a valid partition.
  • the storage medium is configured to store program code for performing the following steps: if the region maximum value is less than or equal to the condition value of the sub-condition, or the region minimum value is greater than or equal to the condition value of the sub-condition, Then, the condition result of the sub-condition is determined to be an invalid result; otherwise, the condition result of the sub-condition is determined to be a valid result.
  • the storage medium is configured to store program code for performing the following steps: if the preset range value and the regional range value of the data partition have an intersection, determining that the conditional result of the sub-condition is valid The result; otherwise, the conditional result of the sub-condition is determined to be an invalid result.
  • the storage medium is arranged to store program code for performing the following steps: determining the condition of the sub-condition if the type of the sub-condition is neither an equivalence condition nor a range query condition The result is an effective result.
  • the storage medium is arranged to store program code for performing the following steps: if the query condition includes a plurality of sub-conditions, obtaining a condition result of each sub-condition; if the condition of each sub-condition If the result is a valid result, the data partition is determined to be a valid partition; if the conditional result of any one or more sub-conditions is an invalid result, the data partition is determined to be an invalid partition.
  • the storage medium is arranged to store program code for performing the step of directly trimming the invalid partition if it is determined that the data partition is an invalid partition.
  • the storage medium is configured to store program code for performing the following steps: when creating a data partition of the database, traversing each data record of the database and obtaining an area range of each data record Value; save the area range value of each data record to the meta information of the corresponding data partition to obtain the area range value of the data partition.
  • the storage medium is configured to store program code for performing the following steps: in the process of executing the query statement of the database, it is necessary to sequentially determine whether each data partition included in the database is a valid partition. Wherein, in the case that it is determined that the currently determined data partition is a valid partition, the corresponding partition query is executed; otherwise, the data partition determined to be an invalid partition is cropped, and the next data partition in the database is effectively partitioned. It is determined that all data partitions in the database are complete.
  • the disclosed technical contents may be implemented in other manners.
  • the device embodiments described above are merely illustrative.
  • the division of the unit is only a logical function division.
  • multiple units or components may be combined or may be Integrate into another system, or some features can be ignored or not executed.
  • the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, unit or module, and may be electrical or otherwise.
  • the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of the embodiment.
  • each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
  • the above integrated unit can be implemented in the form of hardware or in the form of a software functional unit.
  • the integrated unit if implemented in the form of a software functional unit and sold or used as a standalone product, may be stored in a computer readable storage medium.
  • the technical solution of the present invention which is essential or contributes to the prior art, or all or part of the technical solution, may be embodied in the form of a software product stored in a storage medium.
  • a number of instructions are included to cause a computer device (which may be a personal computer, server or network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present invention.
  • the foregoing storage medium includes: a U disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic disk, or an optical disk, and the like. .

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • Computer Security & Cryptography (AREA)
  • Computing Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本发明公开了一种确定数据库中有效分区的方法、装置和系统。其中,该方法包括:获取数据库中数据分区的元信息,其中,元信息包括:数据分区的区域范围值;根据查询条件和数据分区的元信息,确定数据分区是否为有效分区。本发明解决了现有的难以避免无效分区查询,导致查询效率较低的技术问题。

Description

确定数据库中有效分区的方法、装置和系统
本申请要求2017年11月02日递交的申请号为201711063844.0、发明名称为“确定数据库中有效分区的方法、装置和系统”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本发明涉及数据处理领域,具体而言,涉及一种确定数据库中有效分区的方法、装置和系统。
背景技术
当数据库表空间中存放的数据量不断增大,超过一定的规模时,查询数据的速度就会变慢,应用程序的性能就会下降,因此,需要考虑对表进行分区,也即,将表中的数据按照某一逻辑(该逻辑通常为“时间”)切分成多个分区(LIST分区),表进行分区后,逻辑上仍是一张表,只是将表中的数据物理上存放到多个“表空间”中,每个分区表中存放部分数据,在查询每个表中的数据时,会被拆分成多个分区进行查询,所有分区查询结果汇总为查询整个表的最终结果,分区表可以把不同的分区映射到磁盘以平衡I/O,改善整个系统的性能。
但是,在分区表数量较多时会严重影响查询性能,当一个表的分区表个数越多,查询时由于存在过多的无效分区,会导致查询性能越差。
现有的避免无效分区的查询的方法,需要DBA(数据库管理员)或者用户感知分区逻辑,并根据分区逻辑手动改写SQL,当分区逻辑发生变化时,需要再次重写SQL,非常容易出错;而且该方法仅适用于查询条件是分区列的查询优化,当查询条件是非分区列时将无法进行优化,现有的解决方案并不能有效避免无效分区查询,且流程复杂容易出错,查询效率仍不能得到提高。
以下通过一个具体示例对现有技术中存在的缺陷进行举例说明:例如,预定某火车时刻表包含3列:id,开始时间,结束时间,以“开始时间”列作为分区表的依据,将同一天的所有记录放在一个分区表中,当查询条件为“开始时间”列的等值或范围查询时,DBA或者用户则需要依据分区方法计算出满足条件的分区表号,并修改数据库的结构查询语句来增加分区表的筛选条件;而且当查询条件是非分区列时,例如,当查询条 件为“结束时间”列的范围查询时,将无法进行查询优化。
针对上述现有的难以有效避免无效分区查询,查询效率较低的问题,目前尚未提出有效的解决方案。
发明内容
本发明实施例提供了一种确定数据库中有效分区的方法、装置和系统,以至少解决现有的难以避免无效分区查询,导致查询效率较低的技术问题。
根据本发明实施例的一个方面,提供了一种确定数据库中有效分区的方法,包括:获取数据库中数据分区的元信息,其中,元信息包括:数据分区的区域范围值;根据查询条件和数据分区的元信息,确定数据分区是否为有效分区。
根据本发明实施例的另一方面,还提供了一种确定数据库中有效分区的装置,包括:获取模块,用于获取数据库中数据分区的元信息,其中,元信息包括:数据分区的区域范围值;确定模块,用于根据查询条件和数据分区的元信息,确定数据分区是否为有效分区。
根据本发明实施例的另一方面,还提供了一种确定数据库中有效分区的系统,包括:服务器,用于获取数据库中数据分区的元信息,其中,元信息包括:数据分区的区域范围值;数据库系统,与服务器连接,用于根据查询条件和数据分区的元信息,确定数据分区是否为有效分区。
根据本发明实施例的另一方面,还提供了一种计算机终端,包括:处理器;以及存储器,与处理器连接,用于为处理器提供处理以下处理步骤的指令:获取数据库中数据分区的元信息,其中,上述元信息包括:数据分区的区域范围值;根据查询条件和上述数据分区的元信息,确定上述数据分区是否为有效分区。
根据本发明实施例的另一方面,还提供了一种存储介质,存储介质包括存储的程序,其中,在程序运行时控制存储介质所在设备执行下述方法步骤:获取数据库中数据分区的元信息,其中,上述元信息包括:数据分区的区域范围值;根据查询条件和上述数据分区的元信息,确定上述数据分区是否为有效分区。
根据本发明实施例的另一方面,还提供了一种处理器,处理器用于运行程序,其中,程序运行时执行下述方法步骤:获取数据库中数据分区的元信息,其中,上述元信息包括:数据分区的区域范围值;根据查询条件和上述数据分区的元信息,确定上述数据分区是否为有效分区。
在本发明实施例中,通过获取数据库中数据分区的元信息,其中,元信息包括:数据分区的区域范围值;根据查询条件和数据分区的元信息,确定数据分区是否为有效分区,达到了在执行查询时,无需查询无效分区的目的,从而实现了提高查询效率的技术效果,进而解决了现有的难以避免无效分区查询,导致查询效率较低的技术问题。
附图说明
此处所说明的附图用来提供对本发明的进一步理解,构成本申请的一部分,本发明的示意性实施例及其说明用于解释本发明,并不构成对本发明的不当限定。在附图中:
图1是根据本发明实施例1的一种确定数据库中有效分区的系统的结构示意图;
图2是根据本发明实施例2的一种确定数据库中有效分区的方法的步骤流程图;
图3是根据本发明实施例2的一种可选的确定数据库中有效分区的方法的步骤流程图;
图4是根据本发明实施例2的一种可选的确定数据库中有效分区的方法的步骤流程图;
图5是根据本发明实施例2的一种可选的确定数据库中有效分区的方法的步骤流程图;
图6是根据本发明实施例2的一种可选的确定数据库中有效分区的方法的步骤流程图;
图7是根据本发明实施例3的一种确定数据库中有效分区的装置的结构示意图;以及
图8是根据本发明实施例4的一种计算机终端的硬件结构框图。
具体实施方式
为了使本技术领域的人员更好地理解本发明方案,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分的实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都应当属于本发明保护的范围。
需要说明的是,本发明的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样 使用的数据在适当情况下可以互换,以便这里描述的本发明的实施例能够以除了在这里图示或描述的那些以外的顺序实施。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或单元的过程、方法、系统、产品或设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或单元。
首先,在对本申请实施例进行描述的过程中出现的部分名词或术语适用于如下解释:
分区表(LIST分区):是指将数据库表中的数据,在物理上存放到称为分区的许多小的“表空间”上,逻辑上数据库表仍是一张完整的表。
元信息(Meta Information,meta):元素可提供相关页面的元信息,标签位于文档的头部,不包含任何内容,标签的属性定义了与文档相关联的名称/值对。
数据库管理员(Database Administrator,DBA):是指从事管理和维护数据库管理系统(DBMS)的相关工作人员的统称,属于运维工程师的一个分支,主要负责业务数据库从设计、测试到部署交付的全生命周期管理。
结构化查询语言(Structured Query Language,SQL):是一种数据库查询和程序设计语言,用于存取数据以及查询、更新和管理关系数据系统,同时也是数据可脚本文件的扩展名。
实施例1
在描述本申请的各实施例的进一步细节之前,将参考图1来描述可用于实现本申请原理的一个合适的确定数据库中有效分区的系统。
图1是根据本申请实施例的一种确定数据库中有效分区的系统的结构示意图,出于描述的目的,所绘结构仅为合适环境的一个示例,并非对本申请的使用范围或功能提出任何局限。也不应将该确定数据库中有效分区的系统,解释为对图1所示的任一组件或其组合具有任何依赖或需求。
本申请实施例1所提供的系统实施例可以广泛应用在互联网上。随着社会经济的快速发展,信息化时代已经来临,面对随着信息处理而来的海量数据信息,需要对其进行存储和处理,并不断设计和优化数据库的数据存储结构。具体的,当数据库中存放的数据量不断增大,超过一定的规模时,查询数据的速度就会变慢,应用程序的性能就会下降,因此,需要考虑对表进行分区,每个分区表中存放部分数据,在查询每个表中的数据时,会被拆分成多个分区进行查询,所有分区查询结果汇总为查询整个表的最终结果。
但是,在分区表数量较多时会严重影响查询性能,当一个表的分区表个数越多,查询时由于存在过多的无效分区,会导致查询性能越差,目前通常采用的解决方法是,数据库管理员或者用户需要完全的感知分区逻辑综合业务查询,在SQL中增加分区表的范围,而且这种方法仅适用于分区列条件查询优化。
本申请提出了一种确定数据库中有效分区的系统,通过该系统可以达到在执行查询时,无需查询无效分区的目的,从而实现了提高查询效率的技术效果,进而解决了现有的难以避免无效分区查询,导致查询效率较低的技术问题。
基于本申请所提供的确定数据库中有效分区的系统,还可以解决现有技术中,当查询条件为“结束时间”时,当结束时间与开始时间的差别相对较小或者相对稳定(例如开始时间是火车出发时间,结束时间为火车到达时间),每个LIST分区的“结束时间”列相对集中,可以实现确定并裁剪掉大量无效LIST分区的技术效果,从而可以达到提高查询性能的目的。
具体的,图1示出了一种确定数据库中有效分区的系统的结构示意图,如图1所示,该系统包括:服务器10和数据库系统20。
其中,服务器10,用于获取数据库中数据分区的元信息,其中,元信息包括:数据分区的区域范围值;数据库系统20,与服务器10连接,用于根据查询条件和数据分区的元信息,确定数据分区是否为有效分区。
可选的,上述服务器10可以为云端服务器(也即,云服务器),上述数据库系统20可以为任意一种类型的数据库系统,例如,分析型数据库系统。
此外,仍需要说明的是,上述数据库系统支持海量的数据查询,并可以对海量数据进行任意维度即时的分析和统计,支持高并发、低延时(毫秒级响应)查询。
需要说明的是,上述数据分区可以为表分区(也即,LIST分区),具体的,可以为列分区。此外,上述元信息可以为创建LIST分区时所添加的元信息;上述区域范围值,为LIST分区中每列数据的最大值和最小值。
在一种可选的实施例中,服务器通过获取上述表分区中每列数据的最大值和最小值,可以隐含建立LIST分区中每列数据的列值与其对应的LIST分区的区号的映射关系,进而可以实现查询数据库表中的数据时,无需DBA根据查询条件手动修改SQL,根据查询条件和该映射关系,即可快速确定该LIST分区是否为有效分区。
需要说明的是,为提高查询的准确性和查询效率,在上述查询条件为组合条件时,可以将该组合条件拆分成多个子条件,数据库系统依次根据多个子条件进行查询,并根 据每个子条件的查询结果,组合得到组合条件的查询结果。
可选的,上述有效分区可以为满足查询条件的分区,在查询条件为组合条件的情况下,需组合条件中的所有子条件的条件结果为有效分区,则确定该分区为有效分区。
在一种可选的实施例中,如果根据组合条件中的多个子条件对一个LIST分区进行查询,得到的组合条件的条件结果为有效结果(true),也即,该LIST分区满足查询条件,则确定该LIST分区为有效分区,否则,则确定该LIST分区为无效分区。
在一种可选的实施方式中,在根据查询条件和数据分区的元信息,确定数据分区是否为有效分区之后,上述数据库系统还用于在确定数据分区为无效分区的情况下,直接剪裁掉无效分区。
此外,仍需要说明的是,为了避免查询无效分区,影响查询性能,如果在根据组合条件中的多个子条件对一个LIST分区进行查询时,确定该LIST分区为无效分区,则在对每个LIST分区执行查询之前,直接裁剪掉该LIST分区,在执行查询时仅查询有效分区,因而可以实现提高查询性能的目的。
由上可知,在本申请中,通过服务器获取数据库中数据分区的元信息,其中,元信息包括:数据分区的区域范围值;并通过与服务器连接的数据库系统,根据查询条件和数据分区的元信息,确定数据分区是否为有效分区。
容易注意到的是,由于本申请提供的实施方案在创建LIST分区时,增加数据库中数据分区的元信息,在执行查询时,获取数据库中数据分区的元信息,并根据该元信息和查询条件,可以确定不满足条件的无效分区的分区号并自动裁剪上述无效分区;无需DBA(数据库管理员)或者用户感知分区逻辑和手工更改SQL,从而可以有效提高查询效率。
在一种可选的实施方式中,上述数据库系统还用于在创建数据库的数据分区时,遍历数据库的每条数据记录,并获取每条数据记录的区域范围值;将每条数据记录的区域范围值保存至对应的数据分区的元信息中,得到数据分区的区域范围值。
需要说明的是,在创建任意一个LIST分区时,可以遍历该LIST分区中每列数据记录,统计每列数据记录的最大值和最小值,并将所有列的最大值和最小值保存到该LIST分区对应的元信息中。
此外,仍需要说明的是,由于上述最大值和最小值占用的内存非常小,在实际系统应用中可以将上述元信息缓存在内存中,以减少查询过程中的IO开销。
在另一种可选的实施方式中,上述数据库系统还用于通过以下方式确定数据分区是 否为有效分区:在查询条件为组合条件的情况下,得到组合条件包括的至少一个子条件;根据子条件的类型,获取子条件的条件值;通过比对子条件的条件值与数据分区的区域范围值,确定子条件的条件结果,其中,数据分区的区域范围值至少包括:区域最大值和区域最小值;基于至少一个子条件的条件结果,确定数据分区是否为有效分区。
具体的,上述组合条件可以为多个子查询条件组合构成,在执行查询时,需要将该组合条件拆分成多个子条件进行独立查询,上述至少一个子条件,也即构成上述组合条件的一个子查询条件,相对于组合条件而言,上述子条件可以理解为一个单条件。
可选的,上述子条件的类型,可以包括但限于:等值条件、范围查询条件和其他类型的查询条件,上述子条件的条件值为与子条件的类型对应设置的一个判断条件值。
在一种可选的实施例中,如果子条件的类型为等值条件,则判断LIST分区中的区域最大值或区域最小值是否等于等值条件的条件值,若等于则确定该LIST分区满足该等值条件,该等值条件的条件结果为有效结果(true),否则确定该等值条件的条件结果为无效结果(false)。
在另一种可选的实施例中,如果子条件的类型为范围查询条件,则判断LIST分区中的区域最大值或区域最小值是否与范围查询条件的条件值存在交集,若存在交集,则确定该LIST分区满足该范围查询条件,条件结果为true,否则确定该范围查询条件的条件结果为false。
在一种可选的实施方式中,上述数据库系统还用于通过以下方式确定数据分区是否为有效分区:在查询条件包括多个子条件的情况下,获取每个子条件的条件结果;如果每个子条件的条件结果都是有效结果的情况下,确定数据分区为有效分区;如果任意一个或多个子条件的条件结果为无效结果的情况下,确定数据分区为无效分区。
作为一种可选的实施方式,在得到组合条件中每个子条件的条件结果之后,上述数据库系统还用于将每个子条件的条件结果进行组合,得到组合条件的条件结果。
在一种可选的实施例中,如果得到的组合条件结果为true,则确定该LIST分区为有效分区,无需裁剪该LIST分区,可以执行分区查询;在另一种可选的实施例中,如果得到的组合结果为false,可以则确定该LIST分区为无效分区,不满足查询条件,则上述数据库系统直接裁剪掉该LIST分区,无需执行分区查询。
在一种可选的实施方式中,在执行数据库的查询语句的过程中,上述数据库系统还用于需要依次判定数据库中包括的每个数据分区是否为有效分区,其中,在确定当前判定的数据分区为有效分区的情况下,则执行对应的分区查询,否则,将裁剪掉判定为无 效分区的数据分区,并对数据库中的下一个数据分区进行有效分区的判定,直至数据库中的所有数据分区都完成判定。
在一种可选的实施方式中,在子条件的类型为等值条件的情况下,子条件的条件值为任意一个预设值,上述数据库系统还用于通过以下方式确定子条件的条件结果:如果区域最大值小于等于子条件的条件值,或者,区域最小值大于等于子条件的条件值,则确定子条件的条件结果为无效结果;否则,确定子条件的条件结果为有效结果。
此外,本申请还提供一种可选的实施方式,在子条件的类型为范围查询条件的情况下,子条件的条件值为预设的范围值,其中,上述数据库系统还用于通过以下方式确定子条件的条件结果:如果预设的范围值与数据分区的区域范围值存在交集,则确定子条件的条件结果为有效结果;否则,确定子条件的条件结果为无效结果。
在一种可选的实施例中,以上述子条件的类型为范围查询条件,子条件的条件值为预设的范围值(2,4)为例;如果列分区y的最大值为6,最小值为3,也即,该数据区域的最小值到最大值的范围为(3,6),通过比对子条件的条件值与数据分区的区域范围值,可以确定区域范围值(3,6)与预设的范围值(2,4)存在交集,则该范围条件的条件结果为true。
在一种可选的实施例中,仍以上述子条件的类型为范围查询条件,子条件的条件值为预设的范围值(2,4)为例;如果列分区y的最大值为8,最小值为5,也即,该数据区域的最小值到最大值的范围为(5,8),通过比对可以确定区域范围值(5,8)与预设的范围值(2,4)不存在交集,则该范围条件的条件结果为false。
在本申请中,还存在另一种可选的实施方式,在子条件的类型既不是等值条件,也不是范围查询条件的情况下,则数据库系统确定上述子条件的条件结果为有效结果。
需要说明的是,上述x,y,z可以为数据分区的序号,以上关于组合条件和子条件的可选实施例,仅为示意性说明,并不对其进行限定,在涉及具体查询时,可以根据查询的条件和具体应用环境,进行变形和转换。
实施例2
根据本发明实施例,提供了一种确定数据库中有效分区的方法实施例,需要说明的是,在附图的流程图示出的步骤可以在诸如一组计算机可执行指令的计算机系统中执行,并且,虽然在流程图中示出了逻辑顺序,但是在某些情况下,可以以不同于此处的顺序执行所示出或描述的步骤。
需要说明的是,本实施例所提供的一种确定数据库中有效分区的方法可用于数据库 中多分区进行查询的过程中,无需DBA感知分区逻辑和手工改写SQL,能够根据查询条件和数据库中的元信息,自动确定并剪裁无效分区,从而可以提高数据库中多分区的查询性能。
具体的,本申请提供了如图2所示的确定数据库中有效分区的方法。图2是根据本发明实施例2的一种确定数据库中有效分区的方法的步骤流程图,如图2所示,该方法包括如下方法步骤:
步骤S102,获取数据库中数据分区的元信息,其中,元信息包括:数据分区的区域范围值。
可选的,在上述步骤S102中,数据分区可以为表分区(也即,LIST分区),具体的,可以为列分区;上述元信息可以为创建LIST分区时所添加的元信息;上述区域范围值,为LIST分区中每列数据的最大值和最小值。
在一种可选的实施例中,通过获取上述表分区中每列数据的最大值和最小值,可以隐含建立LIST分区中每列数据的列值与其对应的LIST分区的区号的映射关系,可以实现在查询数据库表中的数据时,无需DBA根据查询条件手动修改SQL,根据查询条件和该映射关系,即可快速确定该LIST分区是否为有效分区(也即,满足查询条件的分区)。
在一种可选的实施方式中,图3是根据本发明实施例1的一种可选的确定数据库中有效分区的方法的步骤流程图,如图3所示,在执行步骤S102,也即在获取数据库中数据分区的元信息之前,方法还包括:
步骤S100,在创建数据库的数据分区时,遍历数据库的每条数据记录,并获取每条数据记录的区域范围值;
步骤S101,将每条数据记录的区域范围值保存至对应的数据分区的元信息中,得到数据分区的区域范围值。
基于上述步骤S100至步骤S101所提供的可选实施例,在创建任意一个LIST分区时,遍历该LIST分区中每列数据记录,统计每列数据记录的最大值和最小值,并将所有列的最大值和最小值保存到该LIST分区对应的元信息中。
此外,仍需要说明的是,由于上述最大值和最小值占用的内存非常小,在实际系统应用中可以将上述元信息缓存在内存中,以减少查询过程中的IO开销。
步骤S104,根据查询条件和数据分区的元信息,确定数据分区是否为有效分区。
需要说明的是,为提高查询的准确性和查询效率,在上述查询条件为组合条件时,可以将该组合条件拆分成多个子条件,并依次根据多个子条件进行查询,根据每个子条 件的查询结果,组合得到组合条件的查询结果。
其中,在本申请实施例中,无效分区可以为不满足DBA或者用户的查询条件的分区,有效分区可以为满足查询条件的分区;上述查询条件可以根据实际情况进行选择和确定。
在一种可选的实施例中,如果根据组合条件中的多个子条件对一个LIST分区进行查询,得到的组合条件的条件结果为有效结果(true),也即,该LIST分区满足查询条件,则确定该LIST分区为有效分区,否则,则确定该LIST分区为无效分区。
在一种可选的实施方式中,在根据查询条件和数据分区的元信息,确定数据分区是否为有效分区之后,方法还包括:在确定数据分区为无效分区的情况下,直接剪裁掉无效分区。
此外,仍需要说明的是,为了避免查询无效分区,影响查询性能,如果在根据组合条件中的多个子条件对一个LIST分区进行查询时,确定该LIST分区为无效分区,则在对每个LIST分区执行查询之前,直接裁剪掉该LIST分区,在执行查询时仅查询有效分区,因而可以实现提高查询性能的目的。
在一种可选的实施方式中,图4是根据本发明实施例1的一种可选的确定数据库中有效分区的方法的步骤流程图,如图4所示,上述步骤S104,也即,根据查询条件和数据分区的元信息,确定数据分区是否为有效分区,可以通过如下方法步骤实现:
步骤S1041,在查询条件为组合条件的情况下,得到组合条件包括的至少一个子条件。
具体的,上述组合条件可以为多个子查询条件组合构成,在执行查询时,需要将该组合条件拆分成多个子条件进行独立查询,上述至少一个子条件,也即构成上述组合条件的一个子查询条件,相对于组合条件而言,子条件可以理解为一个单条件。
在一种可选的实施例中,例如上述组合条件为(x=5,OR 2<y<4)AND(z!=4)则该组合条件可以被拆分为以下三个子条件:1:x=5;2:2<y<4;3:(z!=4)。
需要说明的是,上述x,y,z可以为数据分区的序号,以上关于组合条件和子条件的可选实施例,仅为示意性说明,并不对其进行限定,在涉及具体查询时,可以根据查询的条件和具体应用环境,进行变形和转换。
步骤S1043,根据子条件的类型,获取子条件的条件值。
可选的,在上述步骤S1043中,上述子条件的类型,可以包括但限于:等值条件、范围查询条件和其他类型的查询条件,上述子条件的条件值为与子条件的类型对应设置的一个判断条件值。
步骤S1045,通过比对子条件的条件值与数据分区的区域范围值,确定子条件的条件结果,其中,数据分区的区域范围值至少包括:区域最大值和区域最小值。
在一种可选的实施例中,如果子条件的类型为等值条件,则判断LIST分区中的区域最大值或区域最小值是否等于等值条件的条件值,若等于则确定该LIST分区满足该等值条件,该等值条件的条件结果为有效结果(true),否则确定该等值条件的条件结果为无效结果(false)。
在另一种可选的实施例中,如果子条件的类型为范围查询条件,则判断LIST分区中的区域最大值或区域最小值是否与范围查询条件的条件值存在交集,若存在交集,则确定该LIST分区满足该范围查询条件,条件结果为true,否则确定该范围查询条件的条件结果为false。
需要说明的是,上述其他类型的查询条件为类型既不是等值条件,也不是范围查询条件的子条件,所有的条件结果均为true。
步骤S1047,基于至少一个子条件的条件结果,确定数据分区是否为有效分区。
在一种可选的实施方式中,图5是根据本发明实施例1的一种可选的确定数据库中有效分区的方法的步骤流程图,如图5所示,上述步骤S1047,也即,基于至少一个子条件的条件结果,确定数据分区是否为有效分区,包括如下方法步骤:
步骤S10471,在查询条件包括多个子条件的情况下,获取每个子条件的条件结果。
步骤S10473,如果每个子条件的条件结果都是有效结果的情况下,确定数据分区为有效分区。
步骤S10475,如果任意一个或多个子条件的条件结果为无效结果的情况下,确定数据分区为无效分区。
作为一种可选的实施方式,在得到组合条件中每个子条件的条件结果之后,将每个子条件的条件结果进行组合,得到组合条件的条件结果。
在一种可选的实施例中,如果得到的组合条件结果为true,则确定该LIST分区为有效分区,无需裁剪该LIST分区,可以执行分区查询;在另一种可选的实施例中,如果得到的组合结果为false,可以则确定该LIST分区为无效分区,不满足查询条件,直接裁剪掉该LIST分区,无需执行无效分区的查询。
在一种可选的实施方式中,在执行数据库的查询语句的过程中,需要依次判定数据库中包括的每个数据分区是否为无效分区,其中,在确定当前判定的数据分区为有效分区的情况下,则执行对应的分区查询,否则,将裁剪掉判定为无效分区的数据分区,并 对数据库中的下一个数据分区进行无效分区的判定,直至数据库中的所有数据分区都完成判定。
在一种可选的实施方式中,在子条件的类型为等值条件的情况下,子条件的条件值为任意一个预设值,其中,上述步骤S1045,也即通过比对子条件的条件值与数据分区的区域范围值,确定子条件的条件结果,可以通过如下方法步骤实现:
如果区域最大值小于等于子条件的条件值,或者,区域最小值大于等于子条件的条件值,则确定子条件的条件结果为无效结果;
否则,确定子条件的条件结果为有效结果。
在一种可选的实施例中,以上述子条件的类型为等值条件,子条件的条件值为x=5为例;如果列分区x的最大值小于等于5,或者x列分区的最小值大于等于5,则可以确定上述列分区x不满足该等值条件,得到该等值条件的条件结果为false。
在另一种可选的实施例中,仍以上述子条件的类型为等值条件,子条件的条件值为x=5为例;如果列分区x的最大值大于5,或者x列分区的最小值小于5,则可以确定上述列分区x满足该等值条件,得到该等值条件的条件结果为true。
此外,本申请还提供一种可选的实施方式,在子条件的类型为范围查询条件的情况下,子条件的条件值为预设的范围值,其中,上述步骤S1045,也即通过比对子条件的条件值与数据分区的区域范围值,确定子条件的条件结果,可以通过如下方法步骤实现:
如果预设的范围值与数据分区的区域范围值存在交集,则确定子条件的条件结果为有效结果;
否则,确定子条件的条件结果为无效结果。
在一种可选的实施例中,以上述子条件的类型为范围查询条件,子条件的条件值为预设的范围值(2,4)为例;如果列分区y的最大值为6,最小值为3,也即,该数据区域的最小值到最大值的范围为(3,6),通过比对子条件的条件值与数据分区的区域范围值,可以确定区域范围值(3,6)与预设的范围值(2,4)存在交集,则该范围条件的条件结果为true。
在一种可选的实施例中,仍以上述子条件的类型为范围查询条件,子条件的条件值为预设的范围值(2,4)为例;如果列分区y的最大值为8,最小值为5,也即,该数据区域的最小值到最大值的范围为(5,8),通过比对可以确定区域范围值(5,8)与预设的范围值(2,4)不存在交集,则该范围条件的条件结果为false。
另外,在一种可选的实施方式中,在子条件的类型既不是等值条件,也不是范围查 询条件的情况下,确定子条件的条件结果为有效结果。
基于上述实施例可知,本申请通过获取数据库中数据分区的元信息,其中,元信息包括:数据分区的区域范围值;并根据查询条件和上述数据分区的元信息,进而可以确定数据分区是否为有效分区。
容易注意到的是,由于本申请提供的实施方案创建LIST分区时,增加数据库中数据分区的元信息,在执行查询时,获取数据库中数据分区的元信息,并根据该元信息和查询条件,可以确定不满足条件的无效分区的分区号并自动裁剪无效分区;无需DBA或者用户感知分区逻辑和手工更改SQL,从而可以有效提高查询效率。
通过本申请上述实施例所提供的方案,达到了在执行查询时,无需查询无效分区的目的,从而实现了提高查询效率的技术效果,进而解决了现有的难以避免无效分区查询,导致查询效率较低的技术问题。
以下结合一个具体的实施方式对本申请上述实施例进行举例说明,图6是根据本发明实施例1的一种可选的确定数据库中有效分区的方法的步骤流程图,如图6所示,上述方法可以通过如下方法步骤实现:
步骤S1,判断是否完成所有LIST分区的查询。
可选的,在上述步骤S1中,可以通过SQL查询语句判断是否完成所有LIST分区的查询,具体的,若已经完成所有LIST分区的查询,则结束查询;若未完成所有LIST分区的查询,则执行步骤S2。
步骤S2,顺序选择一个LIST分区,查询该LIST分区是否为有效分区。
可选的,由于一个数据库中可能存在一个或者多个LIST分区,因此,在对数据中的至少一个LIST分区进行查询是否为有效分区时,可以逐一分区进行查询。
具体的,可以获取该LIST分区的元信息,进而根据查询条件和元信息确定该LIST分区是否为有效分区。
在一种可选的实施例中,上述元信息包括:LIST分区的区域范围值(最大值和最小值)。
步骤S3,在查询条件为组合条件的情况下,将上述组合条件拆分成至少一个子条件。
具体的,在上述步骤S3中,至少一个子条件,也即构成上述组合条件的一个子查询条件,相对于组合条件而言,子条件可以理解为一个单条件。
步骤S4,顺序选择一个子条件。
步骤S5,判断上述子条件的类型。
需要说明的是,在上述步骤S5中,可以根据子条件的类型,获取子条件的条件值。
可选的,子条件的类型可以包括但限于:等值条件、范围查询条件和其他类型的查询条件,子条件的条件值为与子条件的类型对应设置的一个判断条件值。
在一种可选的实施例中,在子条件的类型为等值条件的情况下,子条件的条件值为任意一个预设值;在子条件的类型为范围查询条件的情况下,子条件的条件值为预设的范围值。
具体的,在判断出上述子条件的类型为等值条件的情况下,执行步骤S6,在判断出上述子条件的类型为范围查询条件的情况下,执行步骤S7,在判断上述子条件的类型既不是等值条件也不是范围查询条件的情况下,执行步骤S8。
步骤S6,判断区域最大值是否小于等于子条件值,或,区域最小值是否大于等于条件值。
具体的,如果区域最大值小于等于子条件的条件值,或者,区域最小值大于等于子条件的条件值,则得到步骤S61的判断结果;否则,得到步骤S63的判断结果。
步骤S61,条件结果为有效分区。
具体的,上述条件结果为等值条件的条件结果。
步骤S63,条件结果为无效分区。
具体的,上述条件结果为等值条件的条件结果。
步骤S7,判断预设的范围值与LIST分区的区域范围值存在交集。
具体的,上述区域范围值为LIST分区的最小值到最大值的范围值。
可选的,如果预设的范围值与LIST分区的最小值到最大值的范围值存在交集,则得到步骤S71的判断结果;否则,得到步骤S73的判断结果。
步骤S71,条件结果为有效分区。
具体的,上述条件结果为范围查询条件的条件结果。
步骤S73,条件结果为无效分区。
具体的,上述条件结果为范围查询条件的条件结果。
步骤S8,条件结果为有效分区。
可选的,在上述步骤S8中,如果子条件的类型既不是等值条件也不是范围查询条件,则得到的所有条件结果均为有效分区。
在一种可选的实施例中,在按照顺序选择至少一个子条件,并根据至少一个子条件的类型确定条件值对LIST分区进行查询,得到至少一个子条件的条件结果之后,执行步 骤S9。
步骤S9,判断是否完成所有子条件的查询。
具体的,若判断出已完成组合条件中所有子条件的查询,则执行步骤S10,若判断出未完成组合条件中任意一个或多个子条件的查询,则返回执行步骤S4,继续对未完成查询的任意一个或多个子条件进行查询。
在一种可选的实施方式中,在执行数据库的查询语句的过程中,需要依次判定数据库中包括的每个数据分区是否为有效分区,其中,在确定当前判定的数据分区为有效分区的情况下,则执行对应的分区查询,否则,将裁剪掉判定为无效分区的数据分区,并对数据库中的下一个数据分区进行有效分区的判定,直至数据库中的所有数据分区都完成判定。
步骤S10,判断组合结果的条件结果是否为有效结果。
需要说明的是,在查询条件包括多个子条件的情况下,需要获取每个子条件的条件结果;作为一种可选的实施例,如果每个子条件的条件结果都是有效结果的情况下,确定LIST分区为有效分区;如果任意一个或多个子条件的条件结果为无效结果的情况下,确定LIST分区为无效分区。
具体的,如果确定上述组合结果的条件结果为有效结果,则执行步骤S11;如果确定上述组合结果的条件结果为无效结果,在确定上述LIST分区为无效分区的情况下,直接剪裁掉无效的LIST分区,并返回执行步骤S1,继续判断是否完成所有LIST分区的查询。
基于上述可选的实施例所提供的方案,可以达到在执行查询时,无需查询无效分区的目的,从而实现了提高查询效率的技术效果,进而解决了现有的难以避免无效分区查询,导致查询效率较低的技术问题。
需要说明的是,对于前述的各方法实施例,为了简单描述,故将其都表述为一系列的动作组合,但是本领域技术人员应该知悉,本发明并不受所描述的动作顺序的限制,因为依据本发明,某些步骤可以采用其他顺序或者同时进行。其次,本领域技术人员也应该知悉,说明书中所描述的实施例均属于优选实施例,所涉及的动作和模块并不一定是本发明所必须的。
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到根据上述实施例的方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本发明的技术方案本质上或者说对现 有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端设备(可以是手机,计算机,服务器,或者网络设备等)执行本发明各个实施例的方法。
需要说明的是,本实施例的优选实施方式可以参见实施例1中的相关描述,此处不再赘述。
实施例3
根据本发明实施例,还提供了一种用于实施上述确定数据库中有效分区的方法的装置,图7是根据本发明实施例3的一种确定数据库中有效分区的装置的结构示意图,如图7所示,该装置包括:获取模块60和确定模块62,其中,
获取模块60,用于获取数据库中数据分区的元信息,其中,元信息包括:数据分区的区域范围值;确定模块62,用于根据查询条件和数据分区的元信息,确定数据分区是否为有效分区。
此处需要说明的是,上述获取模块60和确定模块62对应于实施例2中的步骤S102至步骤S104,两个模块与对应的步骤所实现的实例和应用场景相同,但不限于上述实施例2所公开的内容。需要说明的是,上述模块作为装置的一部分可以运行在实施例4提供的计算机终端中。
基于上述实施例所限定的方案可以获知,本申请通过设置获取模块,用于获取数据库中数据分区的元信息,其中,元信息包括:数据分区的区域范围值;确定模块,用于根据查询条件和数据分区的元信息,确定数据分区是否为有效分区。
容易注意到的是,由于本申请提供的实施方案创建LIST分区时,增加数据库中数据分区的元信息,在执行查询时,获取数据库中数据分区的元信息,并根据该元信息和查询条件,可以确定不满足条件的无效分区的分区号并自动裁剪无效分区;无需DBA或者用户感知分区逻辑和手工更改SQL,从而可以有效提高查询效率。
通过本申请上述实施例所提供的方案,达到了在执行查询时,无需查询无效分区的目的,从而实现了提高查询效率的技术效果,进而解决了现有的难以避免无效分区查询,导致查询效率较低的技术问题。
在一种可选的实施方式中,如图7所示,上述确定模块62,包括:第一获取单元621、第二获取单元623、第一确定单元625和第二确定单元627,其中,
第一获取单元621,用于在查询条件为组合条件的情况下,得到组合条件包括的至少一个子条件;第二获取单元623,用于根据子条件的类型,获取子条件的条件值;第 一确定单元625,用于通过比对子条件的条件值与数据分区的区域范围值,确定子条件的条件结果,其中,数据分区的区域范围值至少包括:区域最大值和区域最小值;第二确定单元627,用于基于至少一个子条件的条件结果,确定数据分区是否为有效分区。
此处需要说明的是,上述第一获取单元621、第二获取单元623、第一确定单元625和第二确定单元627对应于实施例2中的步骤S1041至步骤S1047,两个模块与对应的步骤所实现的实例和应用场景相同,但不限于上述实施例2所公开的内容。需要说明的是,上述模块作为装置的一部分可以运行在实施例4提供的计算机终端中。
在一种可选的实施方式中,在子条件的类型为等值条件的情况下,子条件的条件值为任意一个预设值,其中,如图7所示,上述第一确定单元625,包括:第一确定子单元6251和第二确定子单元6253,其中,
第一确定子单元6251,用于如果区域最大值小于等于子条件的条件值,或者,区域最小值大于等于子条件的条件值,则确定子条件的条件结果为无效结果;第二确定子单元6253,用于如果区域最大值大于子条件的条件值,或者,区域最小值小于子条件的条件值,则确定子条件的条件结果为有效结果。
在一种可选的实施方式中,在子条件的类型为范围查询条件的情况下,子条件的条件值为预设的范围值,其中,如图7所示,上述第一确定单元625,包括:第三确定子单元6255和第四确定子单元6257,其中,
第三确定子单元6255,用于如果预设的范围值与数据分区的区域范围值存在交集,则确定子条件的条件结果为有效结果;第四确定子单元6257,用于如果预设的范围值与数据分区的区域范围值不存在交集,则确定子条件的条件结果为无效结果。
在一种可选的实施方式中,在子条件的类型既不是等值条件,也不是范围查询条件的情况下,确定子条件的条件结果为有效结果。
在一种可选的实施方式中,如图7所示,上述第二确定单元627,包括:获取子单元6271、第五确定子单元6273和第六确定子单元6275,其中,
获取子单元6271,用于在查询条件包括多个子条件的情况下,获取每个子条件的条件结果;第五确定子单元6273,用于如果每个子条件的条件结果都是有效结果的情况下,确定数据分区为有效分区;第六确定子单元6275,用于如果任意一个或多个子条件的条件结果为无效结果的情况下,确定数据分区为无效分区。
此处需要说明的是,上述获取子单元6271、第五确定子单元6273和第六确定子单元6275对应于实施例2中的步骤S10471至步骤S10475,两个模块与对应的步骤所实现 的实例和应用场景相同,但不限于上述实施例2所公开的内容。需要说明的是,上述模块作为装置的一部分可以运行在实施例4提供的计算机终端中。
在一种可选的实施方式中,如图7所示,上述装置还包括:执行模块64,用于在确定数据分区为无效分区的情况下,直接剪裁掉无效分区。
在一种可选的实施方式中,如图7所示,上述装置还包括:遍历模块56和保存模块58,其中,
遍历模块56,用于在创建数据库的数据分区时,遍历数据库的每条数据记录,并获取每条数据记录的区域范围值;保存模块58,用于将每条数据记录的区域范围值保存至对应的数据分区的元信息中,得到数据分区的区域范围值。
此处需要说明的是,上述遍历模块56和保存模块58对应于实施例2中的步骤S100至步骤S101,两个模块与对应的步骤所实现的实例和应用场景相同,但不限于上述实施例2所公开的内容。需要说明的是,上述模块作为装置的一部分可以运行在实施例4提供的计算机终端中。
在一种可选的实施方式中,在执行数据库的查询语句的过程中,需要依次判定数据库中包括的每个数据分区是否为有效分区,其中,在确定当前判定的数据分区为有效分区的情况下,则执行对应的分区查询,否则,将裁剪掉判定为无效分区的数据分区,并对数据库中的下一个数据分区进行有效分区的判定,直至数据库中的所有数据分区都完成判定。
需要说明的是,本实施例的优选实施方式可以参见实施例1和2中的相关描述,此处不再赘述。
实施例4
本发明的实施例可以提供一种计算机终端,该计算机终端可以是计算机终端群中的任意一个计算机终端设备。可选地,在本实施例中,上述计算机终端也可以替换为移动终端等终端设备。
可选地,在本实施例中,上述计算机终端可以位于计算机网络的多个网络设备中的至少一个网络设备。
图8示出了一种计算机终端的硬件结构框图。如图8所示,计算机终端12可以包括一个或多个(图中采用122a、122b,……,122n来示出)处理器122(处理器122可以包括但不限于微处理器MCU或可编程逻辑器件FPGA等的处理装置)、用于存储数据的存储器124、以及用于通信功能的传输装置126。除此以外,还可以包括:显示器、输 入/输出接口(I/O接口)、通用串行总线(USB)端口(可以作为I/O接口的端口中的一个端口被包括)、网络接口、电源和/或相机。本领域普通技术人员可以理解,图8所示的结构仅为示意,其并不对上述电子装置的结构造成限定。例如,计算机终端12还可包括比图8中所示更多或者更少的组件,或者具有与图8所示不同的配置。
应当注意到的是上述一个或多个处理器122和/或其他数据处理电路在本文中通常可以被称为“数据处理电路”。该数据处理电路可以全部或部分的体现为软件、硬件、固件或其他任意组合。此外,数据处理电路可为单个独立的处理模块,或全部或部分的结合到计算机终端12中的其他元件中的任意一个。如本申请实施例中所涉及到的,该数据处理电路作为一种处理器控制(例如与接口连接的可变电阻终端路径的选择)。
处理器122可以通过传输装置调用存储器存储的信息及应用程序,以执行下述步骤:获取数据库中数据分区的元信息,其中,上述元信息包括:数据分区的区域范围值;根据查询条件和上述数据分区的元信息,确定上述数据分区是否为有效分区。
存储器124可用于存储应用软件的软件程序以及模块,如本申请实施例中的确定数据库中有效分区的方法对应的程序指令/数据存储装置,处理器122通过运行存储在存储器124内的软件程序以及模块,从而执行各种功能应用以及数据处理,即实现上述的确定数据库中有效分区的方法。存储器124可包括高速随机存储器,还可包括非易失性存储器,如一个或者多个磁性存储装置、闪存、或者其他非易失性固态存储器。在一些实例中,存储器124可进一步包括相对于处理器122远程设置的存储器,这些远程存储器可以通过网络连接至计算机终端12。上述网络的实例包括但不限于互联网、企业内部网、局域网、移动通信网及其组合。
传输装置126用于经由一个网络接收或者发送数据。上述的网络具体实例可包括计算机终端12的通信供应商提供的无线网络。在一个实例中,传输装置126包括一个网络适配器(Network Interface Controller,NIC),其可通过基站与其他网络设备相连从而可与互联网进行通讯。在一个实例中,传输装置126可以为射频(Radio Frequency,RF)模块,其用于通过无线方式与互联网进行通讯。
显示器可以例如触摸屏式的液晶显示器(LCD),该液晶显示器可使得用户能够与计算机终端12的用户界面进行交互。
此处需要说明的是,在一些可选实施例中,上述图8所示的计算机终端12可以包括硬件元件(包括电路)、软件元件(包括存储在计算机可读介质上的计算机代码)、或硬件元件和软件元件两者的结合。应当指出的是,图8仅为特定具体实例的一个实例, 并且旨在示出可存在于上述计算机终端12中的部件的类型。
在本实施例中,上述计算机终端可以执行应用程序的确定数据库中有效分区的方法中以下步骤的程序代码:获取数据库中数据分区的元信息,其中,元信息包括:数据分区的区域范围值;根据查询条件和数据分区的元信息,确定数据分区是否为有效分区。
处理器可以通过传输装置调用存储器存储的信息及应用程序,以执行下述步骤:获取数据库中数据分区的元信息,其中,元信息包括:数据分区的区域范围值;根据查询条件和数据分区的元信息,确定数据分区是否为有效分区。
可选的,上述处理器还可以执行如下步骤的程序代码:在查询条件为组合条件的情况下,得到组合条件包括的至少一个子条件;根据子条件的类型,获取子条件的条件值;通过比对子条件的条件值与数据分区的区域范围值,确定子条件的条件结果,其中,数据分区的区域范围值至少包括:区域最大值和区域最小值;基于至少一个子条件的条件结果,确定数据分区是否为有效分区。
可选的,上述处理器还可以执行如下步骤的程序代码:如果区域最大值小于等于子条件的条件值,或者,区域最小值大于等于子条件的条件值,则确定子条件的条件结果为无效结果;否则,确定子条件的条件结果为有效结果。
可选的,上述处理器还可以执行如下步骤的程序代码:如果预设的范围值与数据分区的区域范围值存在交集,则确定子条件的条件结果为有效结果;否则,确定子条件的条件结果为无效结果。
可选的,上述处理器还可以执行如下步骤的程序代码:在子条件的类型既不是等值条件,也不是范围查询条件的情况下,确定子条件的条件结果为有效结果。
可选的,上述处理器还可以执行如下步骤的程序代码:在查询条件包括多个子条件的情况下,获取每个子条件的条件结果;如果每个子条件的条件结果都是有效结果的情况下,确定数据分区为有效分区;如果任意一个或多个子条件的条件结果为无效结果的情况下,确定数据分区为无效分区。
可选的,上述处理器还可以执行如下步骤的程序代码:在确定数据分区为无效分区的情况下,直接剪裁掉无效分区。
可选的,上述处理器还可以执行如下步骤的程序代码:在创建数据库的数据分区时,遍历数据库的每条数据记录,并获取每条数据记录的区域范围值;将每条数据记录的区域范围值保存至对应的数据分区的元信息中,得到数据分区的区域范围值。
可选的,上述处理器还可以执行如下步骤的程序代码:在执行数据库的查询语句的 过程中,需要依次判定数据库中包括的每个数据分区是否为有效分区,其中,在确定当前判定的数据分区为有效分区的情况下,则执行对应的分区查询,否则,将裁剪掉判定为无效分区的数据分区,并对数据库中的下一个数据分区进行有效分区的判定,直至数据库中的所有数据分区都完成判定。
采用本发明实施例,提供了一种确定数据库中有效分区的方案。通过获取数据库中数据分区的元信息,其中,元信息包括:数据分区的区域范围值;根据查询条件和数据分区的元信息,确定数据分区是否为有效分区,从而达到了在执行查询时,无需查询无效分区的目的,进而解决了现有的难以避免无效分区查询,导致查询效率较低的技术问题。
本领域普通技术人员可以理解,图8所示的结构仅为示意,计算机终端也可以是智能手机(如Android手机、iOS手机等)、平板电脑、掌声电脑以及移动互联网设备(Mobile Internet Devices,MID)、PAD等终端设备。图8其并不对上述电子装置的结构造成限定。例如,计算机终端12还可包括比图8中所示更多或者更少的组件(如网络接口、显示装置等),或者具有与图8所示不同的配置。
本领域普通技术人员可以理解上述实施例的各种方法中的全部或部分步骤是可以通过程序来指令终端设备相关的硬件来完成,该程序可以存储于一计算机可读存储介质中,存储介质可以包括:闪存盘、只读存储器(Read-Only Memory,ROM)、随机存取器(Random Access Memory,RAM)、磁盘或光盘等。
实施例5
本发明的实施例还提供了一种存储介质。可选地,在本实施例中,上述存储介质可以用于保存上述实施例1所提供的确定数据库中有效分区的方法所执行的程序代码。
可选地,在本实施例中,上述存储介质可以位于计算机网络中计算机终端群中的任意一个计算机终端中,或者位于移动终端群中的任意一个移动终端中。
可选地,在本实施例中,存储介质被设置为存储用于执行以下步骤的程序代码:获取数据库中数据分区的元信息,其中,元信息包括:数据分区的区域范围值;根据查询条件和数据分区的元信息,确定数据分区是否为有效分区。
可选地,在本实施例中,存储介质被设置为存储用于执行以下步骤的程序代码:在查询条件为组合条件的情况下,得到组合条件包括的至少一个子条件;根据子条件的类型,获取子条件的条件值;通过比对子条件的条件值与数据分区的区域范围值,确定子条件的条件结果,其中,数据分区的区域范围值至少包括:区域最大值和区域最小值; 基于至少一个子条件的条件结果,确定数据分区是否为有效分区。
可选地,在本实施例中,存储介质被设置为存储用于执行以下步骤的程序代码:如果区域最大值小于等于子条件的条件值,或者,区域最小值大于等于子条件的条件值,则确定子条件的条件结果为无效结果;否则,确定子条件的条件结果为有效结果。
可选地,在本实施例中,存储介质被设置为存储用于执行以下步骤的程序代码:如果预设的范围值与数据分区的区域范围值存在交集,则确定子条件的条件结果为有效结果;否则,确定子条件的条件结果为无效结果。
可选地,在本实施例中,存储介质被设置为存储用于执行以下步骤的程序代码:在子条件的类型既不是等值条件,也不是范围查询条件的情况下,确定子条件的条件结果为有效结果。
可选地,在本实施例中,存储介质被设置为存储用于执行以下步骤的程序代码:在查询条件包括多个子条件的情况下,获取每个子条件的条件结果;如果每个子条件的条件结果都是有效结果的情况下,确定数据分区为有效分区;如果任意一个或多个子条件的条件结果为无效结果的情况下,确定数据分区为无效分区。
可选地,在本实施例中,存储介质被设置为存储用于执行以下步骤的程序代码:在确定数据分区为无效分区的情况下,直接剪裁掉无效分区。
可选地,在本实施例中,存储介质被设置为存储用于执行以下步骤的程序代码:在创建数据库的数据分区时,遍历数据库的每条数据记录,并获取每条数据记录的区域范围值;将每条数据记录的区域范围值保存至对应的数据分区的元信息中,得到数据分区的区域范围值。
可选地,在本实施例中,存储介质被设置为存储用于执行以下步骤的程序代码:在执行数据库的查询语句的过程中,需要依次判定数据库中包括的每个数据分区是否为有效分区,其中,在确定当前判定的数据分区为有效分区的情况下,则执行对应的分区查询,否则,将裁剪掉判定为无效分区的数据分区,并对数据库中的下一个数据分区进行有效分区的判定,直至数据库中的所有数据分区都完成判定。
上述本发明实施例序号仅仅为了描述,不代表实施例的优劣。
在本发明的上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述的部分,可以参见其他实施例的相关描述。
在本申请所提供的几个实施例中,应该理解到,所揭露的技术内容,可通过其它的方式实现。其中,以上所描述的装置实施例仅仅是示意性的,例如所述单元的划分,仅 仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,单元或模块的间接耦合或通信连接,可以是电性或其它的形式。
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。
另外,在本发明各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可为个人计算机、服务器或者网络设备等)执行本发明各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、移动硬盘、磁碟或者光盘等各种可以存储程序代码的介质。
以上所述仅是本发明的优选实施方式,应当指出,对于本技术领域的普通技术人员来说,在不脱离本发明原理的前提下,还可以做出若干改进和润饰,这些改进和润饰也应视为本发明的保护范围。

Claims (13)

  1. 一种确定数据库中有效分区的方法,其特征在于,包括:
    获取数据库中数据分区的元信息,其中,所述元信息包括:数据分区的区域范围值;
    根据查询条件和所述数据分区的元信息,确定所述数据分区是否为有效分区。
  2. 根据权利要求1所述的方法,其特征在于,根据查询条件和所述数据分区的元信息,确定所述数据分区是否为有效分区,包括:
    在所述查询条件为组合条件的情况下,得到所述组合条件包括的至少一个子条件;
    根据所述子条件的类型,获取所述子条件的条件值;
    通过比对所述子条件的条件值与所述数据分区的区域范围值,确定所述子条件的条件结果,其中,所述数据分区的区域范围值至少包括:区域最大值和区域最小值;
    基于所述至少一个子条件的条件结果,确定所述数据分区是否为有效分区。
  3. 根据权利要求2所述的方法,其特征在于,在所述子条件的类型为等值条件的情况下,所述子条件的条件值为任意一个预设值,其中,通过比对所述子条件的条件值与所述数据分区的区域范围值,确定所述子条件的条件结果,包括:
    如果所述区域最大值小于等于所述子条件的条件值,或者,所述区域最小值大于等于所述子条件的条件值,则确定所述子条件的条件结果为无效结果;
    否则,确定所述子条件的条件结果为有效结果。
  4. 根据权利要求2所述的方法,其特征在于,在所述子条件的类型为范围查询条件的情况下,所述子条件的条件值为预设的范围值,其中,通过比对所述子条件的条件值与所述数据分区的区域范围值,确定所述子条件的条件结果,包括:
    如果所述预设的范围值与所述数据分区的区域范围值存在交集,则确定所述子条件的条件结果为有效结果;
    否则,确定所述子条件的条件结果为无效结果。
  5. 根据权利要求2所述的方法,其特征在于,在所述子条件的类型既不是等值条件,也不是范围查询条件的情况下,确定所述子条件的条件结果为有效结果。
  6. 根据权利要求2至5中任意一项所述的方法,其特征在于,基于所述至少一个子条件的条件结果,确定所述数据分区是否为有效分区,包括:
    在所述查询条件包括多个子条件的情况下,获取每个子条件的条件结果;
    如果所述每个子条件的条件结果都是有效结果的情况下,确定所述数据分区为有效分区;
    如果任意一个或多个子条件的条件结果为无效结果的情况下,确定所述数据分区为无效分区。
  7. 根据权利要求1所述的方法,其特征在于,在根据查询条件和所述数据分区的元信息,确定所述数据分区是否为有效分区之后,所述方法还包括:
    在确定所述数据分区为无效分区的情况下,直接剪裁掉所述无效分区。
  8. 根据权利要求1所述的方法,其特征在于,在获取数据库中数据分区的元信息之前,所述方法还包括:
    在创建所述数据库的数据分区时,遍历所述数据库的每条数据记录,并获取所述每条数据记录的区域范围值;
    将所述每条数据记录的区域范围值保存至对应的数据分区的元信息中,得到所述数据分区的区域范围值。
  9. 根据权利要求1所述的方法,其特征在于,在执行数据库的查询语句的过程中,需要依次判定所述数据库中包括的每个数据分区是否为有效分区,其中,在确定当前判定的数据分区为有效分区的情况下,则执行对应的分区查询,否则,将裁剪掉判定为无效分区的数据分区,并对所述数据库中的下一个数据分区进行有效分区的判定,直至所述数据库中的所有数据分区都完成判定。
  10. 一种确定数据库中有效分区的系统,其特征在于,包括:
    服务器,用于获取数据库中数据分区的元信息,其中,所述元信息包括:数据分区的区域范围值;
    数据库系统,与所述服务器连接,用于根据查询条件和所述数据分区的元信息,确定所述数据分区是否为有效分区。
  11. 一种计算机终端,其特征在于,包括:
    处理器;以及
    存储器,与所述处理器连接,用于为所述处理器提供处理以下处理步骤的指令:获取数据库中数据分区的元信息,其中所述元信息包括:数据分区的区域范围值;根据查询条件和所述数据分区的元信息,确定所述数据分区是否为有效分区。
  12. 一种存储介质,其特征在于,所述存储介质包括存储的程序,其中,在所述程序运行时控制所述存储介质所在设备执行下述方法步骤:获取数据库中数据分区的元信息,其中,所述元信息包括:数据分区的区域范围值;根据查询条件和所述数据分区的元信息,确定所述数据分区是否为有效分区。
  13. 一种处理器,其特征在于,所述处理器用于运行程序,其中,所述程序运行时执行下述方法步骤:获取数据库中数据分区的元信息,其中,所述元信息包括:数据分区的区域范围值;根据查询条件和所述数据分区的元信息,确定所述数据分区是否为有效分区。
PCT/CN2018/111172 2017-11-02 2018-10-22 确定数据库中有效分区的方法、装置和系统 WO2019085778A1 (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
US16/860,872 US20200257675A1 (en) 2017-11-02 2020-04-28 Method, apparatus, and system for evaluating a partition in a database

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201711063844.0A CN110019337A (zh) 2017-11-02 2017-11-02 确定数据库中有效分区的方法、装置和系统
CN201711063844.0 2017-11-02

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US16/860,872 Continuation US20200257675A1 (en) 2017-11-02 2020-04-28 Method, apparatus, and system for evaluating a partition in a database

Publications (1)

Publication Number Publication Date
WO2019085778A1 true WO2019085778A1 (zh) 2019-05-09

Family

ID=66332800

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/111172 WO2019085778A1 (zh) 2017-11-02 2018-10-22 确定数据库中有效分区的方法、装置和系统

Country Status (3)

Country Link
US (1) US20200257675A1 (zh)
CN (1) CN110019337A (zh)
WO (1) WO2019085778A1 (zh)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11544239B2 (en) * 2018-11-13 2023-01-03 Thoughtspot, Inc. Low-latency database analysis using external data sources
CN112925834B (zh) * 2019-12-05 2024-05-31 阿里巴巴集团控股有限公司 数据导入的方法和装置
CN113297266B (zh) * 2020-07-08 2022-08-12 阿里巴巴集团控股有限公司 数据处理方法、装置、设备及计算机存储介质
US11461366B1 (en) 2021-10-20 2022-10-04 Bnsf Railway Company System and method for data pruning via dynamic partition management
CN114416884B (zh) * 2022-03-28 2022-06-14 北京奥星贝斯科技有限公司 连接分区表的方法和装置

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101436192A (zh) * 2007-11-16 2009-05-20 国际商业机器公司 用于优化针对垂直存储式数据库的查询的方法和设备
US20170097957A1 (en) * 2015-10-01 2017-04-06 International Business Machines Corporation System and method for transferring data between rdbms and big data platform
CN106959927A (zh) * 2016-01-08 2017-07-18 阿里巴巴集团控股有限公司 获取虚拟机中的逻辑分区的位置信息的方法及装置

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7877405B2 (en) * 2005-01-07 2011-01-25 Oracle International Corporation Pruning of spatial queries using index root MBRS on partitioned indexes
US8996544B2 (en) * 2012-09-28 2015-03-31 Oracle International Corporation Pruning disk blocks of a clustered table in a relational database management system
US20150039610A1 (en) * 2013-07-31 2015-02-05 Thomas Hubauer Method and system for a data access based on domain models
WO2016183552A1 (en) * 2015-05-14 2016-11-17 Walleye Software, LLC A memory-efficient computer system for dynamic updating of join processing
CN105512200A (zh) * 2015-11-26 2016-04-20 华为技术有限公司 一种分布式数据库处理的方法和设备

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101436192A (zh) * 2007-11-16 2009-05-20 国际商业机器公司 用于优化针对垂直存储式数据库的查询的方法和设备
US20170097957A1 (en) * 2015-10-01 2017-04-06 International Business Machines Corporation System and method for transferring data between rdbms and big data platform
CN106959927A (zh) * 2016-01-08 2017-07-18 阿里巴巴集团控股有限公司 获取虚拟机中的逻辑分区的位置信息的方法及装置

Also Published As

Publication number Publication date
US20200257675A1 (en) 2020-08-13
CN110019337A (zh) 2019-07-16

Similar Documents

Publication Publication Date Title
WO2019085778A1 (zh) 确定数据库中有效分区的方法、装置和系统
EP3563268B1 (en) Scalable database system for querying time-series data
EP3285178B1 (en) Data query method in crossing-partition database, and crossing-partition query device
US20180060389A1 (en) Query optimization over distributed heterogeneous execution engines
EP2869220B1 (en) Networked database system
US20130138681A1 (en) Method and system for metadata driven processing of federated data
EP3401807B1 (en) Synopsis based advanced partition elimination
US20180329963A1 (en) Embedded Analytics and Transactional Data Processing
CN102937980A (zh) 一种集群数据库数据查询方法
US10394805B2 (en) Database management for mobile devices
CN111061766A (zh) 一种业务数据的处理方法、装置、计算机设备及存储介质
US9734176B2 (en) Index merge ordering
WO2020215689A1 (zh) 一种列存储文件的查询方法及查询装置
JP2022543306A (ja) ブロックチェーンデータ処理の方法、装置、機器及び可読記憶媒体
CN110502692A (zh) 基于搜索引擎的信息检索方法、装置、设备和存储介质
CN110162540B (zh) 区块链账本数据的查询方法、电子装置及存储介质
WO2019127772A1 (zh) 数据字典展示方法、装置、终端设备及存储介质
US10997170B2 (en) Local database cache
US11797537B2 (en) Data processing method, data processing device and non-volatile computer-readable storage media
CN106156064B (zh) 对数据库进行流量控制的方法及装置
WO2021129259A1 (zh) 一种根据用户使用习惯动态快速加载模块的方法
CN112905600A (zh) 数据查询方法、装置和存储介质及电子设备
CN107277095B (zh) 会话分割方法及装置
WO2017206562A1 (zh) 一种数据表的处理方法、装置及系统
CN106326295B (zh) 语义数据的存储方法及装置

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 18872620

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 18872620

Country of ref document: EP

Kind code of ref document: A1