Method and apparatus for partitioning database objects

By receiving splitting instructions and filtering files, the system obtains splitting information and splits the database or table according to the target fields and patterns. This solves the problem of inflexibility in existing database and table sharding technologies and achieves more efficient database splitting and query request processing.

CN114281879BActive Publication Date: 2025-12-16CHINA CONSTRUCTION BANK
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111629220.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-28
Publication Date
2025-12-16
Estimated Expiration
2041-12-28

AI Technical Summary

Technical Problem

Existing database sharding and table partitioning methods are not flexible enough, cannot meet various user needs, and cannot effectively reduce the amount of data in a single table or reduce system resource consumption.

Method used

By receiving splitting instructions, determining the filter file, obtaining the information to be split, and flexibly splitting the database or data table according to the target field, value range, and splitting mode, including database splitting and table splitting operations.

Benefits of technology

It enables flexible partitioning of databases or tables according to specific needs, reduces cross-database operations, improves the fine-grained control of transactions, meets more demanding and refined business requirements, improves the execution efficiency of query requests, and saves system resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114281879B_ABST
    Figure CN114281879B_ABST
Patent Text Reader

Abstract

The application discloses a database object segmentation method and device, and relates to the technical field of data storage. A specific embodiment of the method comprises the following steps: receiving a segmentation instruction for a database object, determining a filter file corresponding to the segmentation instruction, obtaining segmentation information from the filter file, wherein the segmentation information comprises a to-be-segmented object, a value range of a target field and a segmentation mode; wherein the to-be-segmented object comprises a target database and / or a target table, the target field is a transaction field in the to-be-segmented object, and the segmentation mode is a date mode, a characteristic field mode or a custom mode; and performing a segmentation operation on the to-be-segmented object according to the target field, the value range of the target field and the segmentation mode. The embodiment can flexibly segment a database or a data table.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of data storage, and in particular to a database object segmentation method and device. BACKGROUND

[0002] The commonly used database and table segmentation methods include horizontal database segmentation and horizontal table segmentation. The horizontal database segmentation has the characteristics that the structures of each database are the same, the data of each database is different, there is no intersection between databases, and the intersection of all databases is the full data. The horizontal database segmentation is mainly aimed at too much full table data. The horizontal table segmentation takes the field item as the basis, and splits the data of one table into multiple tables according to a certain strategy. The structures of each table are the same, the data of each table is different, and the union of all tables is the full data.

[0003] The above-mentioned database and table segmentation methods can reduce the single table data volume and reduce the resource consumption of the system, but the segmentation methods are not flexible enough to meet the multiple needs of users for database and table segmentation. SUMMARY

[0004] Therefore, the embodiments of the present application provide a database object segmentation method and device, which can flexibly segment a database or a data table.

[0005] In a first aspect, the embodiments of the present application provide a database object segmentation method, which comprises the following steps.

[0006] Receiving a segmentation instruction for a database object, and determining a filter file corresponding to the segmentation instruction;

[0007] Obtaining segmentation information from the filter file, wherein the segmentation information comprises a to-be-segmented object, a value range of a target field and a segmentation mode; the to-be-segmented object comprises a target database and / or a target table, the target field is a transaction field in the to-be-segmented object, and the segmentation mode is a date mode, a characteristic field mode or a custom mode;

[0008] Performing a segmentation operation on the to-be-segmented object according to the target field, the value range of the target field and the segmentation mode.

[0009] Optionally, the segmentation operation on the to-be-segmented object according to the target field, the value range of the target field and the segmentation mode comprises the following steps.

[0010] Performing a database segmentation operation on the target database according to the target field, the value range and the segmentation mode, to obtain multiple databases of the target database;

[0011] Performing a table segmentation operation on the target table according to the target field, the value range and the segmentation mode, to obtain multiple tables of the target table.

[0012] Optionally, the split mode is a time mode, and the value range includes a target transaction code, and the split information further includes a start time and an end time.

[0013] The split operation on the to-be-split object according to the target field, the value range of the target field, and the split mode includes:

[0014] querying, from the to-be-split object, a first database object in which the target field is the target transaction code and the time field is between the start time and the end time;

[0015] extracting, from the to-be-split object, the first database object to generate a first split object of the to-be-split object.

[0016] Optionally, the split mode is a time mode, and the value range includes a first transaction code and a second transaction code, and the split information further includes a valid time.

[0017] The split operation on the to-be-split object according to the target field, the value range of the target field, and the split mode includes:

[0018] querying, from the to-be-split object, a second database object in which the target field is between the first transaction code and the second transaction code and the time field is the valid time;

[0019] extracting, from the to-be-split object, the second database object to generate a second split object of the to-be-split object.

[0020] Optionally, the split mode is a time mode, and the split information further includes a maximum interval between start and end dates.

[0021] The split operation on the to-be-split object according to the target field, the value range of the target field, and the split mode includes:

[0022] querying, from the to-be-split object, a third database object in which the target field is within the value range and an interval between a start date and an end date is not greater than the maximum interval between start and end dates;

[0023] extracting, from the to-be-split object, the third database object to generate a third split object of the to-be-split object.

[0024] Optionally, after the third database object is extracted from the to-be-split object to generate the third split object of the to-be-split object, the method further includes:

[0025] receiving a query request for the object to be segmented;

[0026] determining a start date and an end date corresponding to the query request, and determining a query interval between the start date and the end date corresponding to the query request;

[0027] in a case where the query interval is not greater than the maximum interval of the start date and the end date, executing the query request in the third segmented object;

[0028] in a case where the query interval is greater than the maximum interval of the start date and the end date, executing the query request in the historical database corresponding to the object to be segmented.

[0029] Optionally, the segmentation mode is a feature field mode, and the value range includes a target transaction code, and the segmentation information further includes a feature field and a feature value.

[0030] The segmentation operation on the object to be segmented according to the value range of the target field and the segmentation mode includes:

[0031] querying, from the object to be segmented, a fourth database object in which the target field is the target transaction code and the feature field is the feature value;

[0032] extracting the fourth database object from the object to be segmented to generate a fourth segmented object of the object to be segmented.

[0033] Optionally, the segmentation mode is a custom mode.

[0034] Before the segmentation operation on the object to be segmented according to the value range of the target field and the segmentation mode, the method further includes:

[0035] receiving a custom field and a value range of the custom field input by a user for the filter file.

[0036] Optionally, the segmentation operation on the object to be segmented according to the target field, the value range of the target field and the segmentation mode includes:

[0037] querying, from the object to be segmented, a fifth database object in which the target field is within the value range of the target field and the custom field is within the value range of the custom field;

[0038] extracting the fifth database object from the object to be segmented to generate a fifth segmented object of the object to be segmented.

[0039] Optionally, the segmentation information further includes a historical time interval.

[0040] The segmentation operation on the to-be-segmented object according to the value range of the target field and the segmentation mode comprises:

[0041] The sixth database object is queried from the to-be-segmented object, wherein the target field is within the value range of the target field, the custom field is within the value range of the custom field, and the interval between the effective date and the current date is less than the historical time interval;

[0042] The sixth database object is extracted from the to-be-segmented object to generate a sixth segmented object of the to-be-segmented object.

[0043] Optionally, after the sixth database object is extracted from the to-be-segmented object to generate a sixth segmented object of the to-be-segmented object, the method further comprises:

[0044] receiving a query request for the to-be-segmented object;

[0045] determining an effective date corresponding to the query request and determining a query interval between the effective date corresponding to the query request and the current date;

[0046] in a case where the query interval is not greater than the historical data interval, executing the query request in the sixth segmented object;

[0047] in a case where the query interval is greater than the historical time interval, executing the query request in a historical database corresponding to the to-be-segmented object.

[0048] In a second aspect, an embodiment of the present application provides a database object segmentation device, comprising:

[0049] an instruction receiving module configured to receive a segmentation instruction for a database object and determine a filter file corresponding to the segmentation instruction;

[0050] an information obtaining module configured to obtain segmentation information from the filter file, wherein the segmentation information comprises a to-be-segmented object, a value range of a target field and a segmentation mode; the to-be-segmented object comprises a target database and / or a target table, the target field is a transaction field in the to-be-segmented object, and the segmentation mode is a date mode, a feature field mode or a custom mode;

[0051] a segmentation module configured to perform a segmentation operation on the to-be-segmented object according to the target field, the value range of the target field and the segmentation mode.

[0052] Optionally, the segmentation module is specifically configured to:

[0053] According to the target field, the value range and the split mode, a database split operation is performed on the target database to obtain a plurality of split databases of the target database.

[0054] According to the target field, the value range and the split mode, a table split operation is performed on the target table to obtain a plurality of split tables of the target table.

[0055] In a third aspect, an electronic device is provided, and the electronic device comprises:

[0056] one or more processors;

[0057] a storage device configured to store one or more programs,

[0058] When the one or more programs are executed by the one or more processors, the one or more processors implement the method of any of the above embodiments.

[0059] In a fourth aspect, a computer readable medium is provided, and the computer readable medium stores a computer program, and the program is executed by a processor to implement the method of any of the above embodiments.

[0060] In a fifth aspect, a computer program product is provided, and the computer program product comprises a computer program, and the program is executed by a processor to implement the method of any of the above embodiments.

[0061] An embodiment of the above application has the following advantages or beneficial effects: determining a filter file corresponding to a split instruction, obtaining split information from the filter file, and performing a split operation on a to-be-split object according to the split information. Split information such as a to-be-split object, a value range of a target field and a split mode can be set in the filter file according to specific needs. According to the split information, a database or a data table can be flexibly split.

[0062] In addition, the target field is a transaction field in the to-be-split object, and the target field can be determined according to the actual application of the database object to be split. For example, for a database object of a bill system, a bill identifier field can be selected as the target field. For a database object of a transaction system, a transaction identifier field can be selected as the target field. Taking the transaction field in the to-be-split object as the target field reduces cross-database operations, improves the degree of transaction refinement control, and can meet more demanding and refined business needs.

[0063] Further effects of the above non-conventional optional mode will be described in the following with reference to the specific embodiments. BRIEF DESCRIPTION OF DRAWINGS

[0064] The accompanying drawings are used to better understand the application and do not constitute an improper limitation on the application. Among them:

[0065] Figure 1 is a flowchart of a database object segmentation method provided by a first embodiment of the present application;

[0066] Figure 2 is a flowchart of a database object segmentation method based on time pattern provided by a second embodiment of the present application;

[0067] Figure 3 is a flowchart of a database object segmentation method based on feature field pattern provided by a third embodiment of the present application;

[0068] Figure 4 is a flowchart of a database object segmentation method based on custom pattern provided by a fourth embodiment of the present application;

[0069] Figure 5 is a structural diagram of a database object segmentation apparatus provided by an embodiment of the present application;

[0070] Figure 6 is a structural diagram of a computer system of a terminal device or server suitable for implementing an embodiment of the present application. DETAILED DESCRIPTION

[0071] Exemplary embodiments of the present application are described herein with reference to the accompanying drawings, which are meant to be exemplary and not limiting. Therefore, it should be recognized that many modifications and variations of the exemplary embodiments described herein can be made without departing from the scope and spirit of the application. Also, for the purpose of clarity and a concise description, descriptions of well-known functions and constructions can be omitted.

[0072] In the technical solutions of the present application, the acquisition, storage, use, processing, etc. of data comply with relevant provisions of national laws and regulations.

[0073] Figure 1 is a flowchart of a database object segmentation method provided by a first embodiment of the present application, as shown in Figure 1 the method comprises:

[0074] Step 101: receiving a segmentation instruction for a database object, and determining a filter file corresponding to the segmentation instruction.

[0075] The database object can be a database or a data table. The segmentation instruction is used to split a single database into multiple databases, or to split a single data table into multiple data tables.

[0076] The scheme of the embodiment of the present application does not make any limitation on the format of the filtering file. The format of the filtering file can be set according to specific needs. For example, the filtering file can be an xml file, a txt file, an excel file, etc.

[0077] The correspondence between the database and the filtering file, the correspondence between the data table and the filtering file, the correspondence between the transaction field and the filtering file, the correspondence between the transaction field and the transaction field value and the filtering file, etc. can be set in the system. The splitting instruction for the database object is received, the instruction information corresponding to the splitting instruction is determined, the instruction information includes at least one of the database, the data table, the transaction field and the transaction field value. According to the above correspondence, the filtering file corresponding to the instruction information is determined, and the filtering file is determined as the filtering file corresponding to the splitting instruction.

[0078] Step 102: obtaining splitting information from the filtering file, the splitting information including: a to-be-split object, a value range of a target field and a splitting mode.

[0079] The to-be-split object includes a target database and / or a target table. The target field is a transaction field in the to-be-split object. The target field can be determined according to the actual application of the database object to be split. For example, for the database object of a bill system, the bill identification field can be selected as the target field. For the database object of a transaction system, the transaction identification field can be selected as the target field.

[0080] The splitting mode can include a date mode, a feature field mode or a custom mode. The date mode refers to the target field and the date field in the to-be-split object to split the to-be-split object. The feature field mode refers to the target field and the feature field in the to-be-split object to split the to-be-split object.

[0081] Step 103: performing a splitting operation on the to-be-split object according to the target field, the value range of the target field and the splitting mode.

[0082] The target database can be subjected to a database splitting operation according to the target field, the value range and the splitting mode, so as to obtain a plurality of databases of the target database. The target table can also be subjected to a table splitting operation according to the target field, the value range and the splitting mode, so as to obtain a plurality of tables of the target table.

[0083] In the embodiment of the present application, the filtering file corresponding to the splitting instruction is determined, the splitting information is obtained from the filtering file, and the to-be-split object is subjected to a splitting operation according to the splitting information. The to-be-split object, the value range of the target field and the splitting mode, etc. can be set in the filtering file according to specific needs. According to the splitting information, the database or the data table can be flexibly split.

[0084] In addition, the target field is a transaction field in the to-be-split object, and the target field can be determined according to actual application of the to-be-split database object. For example, for a database object of a bill system, a bill identification field can be selected as the target field. For a database object of a transaction system, a transaction identification field can be selected as the target field. Taking the transaction field in the to-be-split object as the target field can improve performance of cross-database operation, improve the degree of transaction refinement control, and meet more stringent and refined business requirements.

[0085] Figure 2 is a flowchart of a database object splitting method based on a time mode provided by the second embodiment of the present application, as shown in Figure 2 The method comprises the following steps.

[0086] Step 201: receiving a splitting instruction for a database object, and determining a filter file corresponding to the splitting instruction.

[0087] Step 202: obtaining splitting information from the filter file, wherein the splitting information comprises a to-be-split object, a value range of a target field, a splitting mode, a start time and an end time, the splitting mode is a time mode, and the value range comprises a target transaction code.

[0088] In the case where the splitting mode is the time mode, the start time and the end time can be included in the splitting information to determine the database or the data table in the time period. The form of the start time and the end time can be set according to specific requirements. The start time and the end time can be a day, a month, a year, or a time stamp.

[0089] Step 203: querying a first database object from the to-be-split object, wherein the target field of the first database object is the target transaction code, and a time field of the first database object is between the start time and the end time.

[0090] The time field of the to-be-split object can be determined according to the structure of the specific to-be-split object or specific requirements. For example, the time field of the to-be-split object can be a transaction time, a payment time, an effective time, a prepayment time, etc.

[0091] The year, month, day and time in the time field of the to-be-split object can also be intercepted, and the intercepted fields are compared with the start time and the end time in the splitting information to determine the first database object. The first database object is composed of data records extracted from the to-be-split object. The data records match the splitting information, that is, the target field of the data records corresponds to the target transaction code in the splitting information, and the time field of the data records is between the start time and the end time in the splitting information.

[0092] Step 204: extracting the first database object from the to-be-split object to generate a first split object of the to-be-split object.

[0093] If the to-be-split object is a database, the first split object is a sub-database of the to-be-split object. The first database object is extracted from the to-be-split database, and a sub-database of the to-be-split object, i.e., the first split object, is formed by data records in the extracted first database object.

[0094] If the to-be-split object is a data table, the first split object is a sub-table of the to-be-split object. The first database object is extracted from the to-be-split data table, and a sub-table of the to-be-split object, i.e., the first split object, is formed by data records in the extracted first database object.

[0095] The first database object that meets the split information in the filter file is extracted from the to-be-split object, and the split first database object is taken as the first split object of the to-be-split object. If there are N filter files for the to-be-split data object, the to-be-split object can be split for N times to obtain N+1 split objects of the to-be-split object. For example, if there are 5 filter files for the to-be-split database, the to-be-split database can be split for 5 times to obtain 6 sub-databases of the to-be-split database. If there are 3 filter files for the to-be-split table, the to-be-split table can be split for 3 times to obtain 4 sub-tables of the to-be-split table.

[0096] In an embodiment of the present application, the split mode is a time mode, the value range includes a first transaction code and a second transaction code, and the split information further includes a valid time. The split operation on the to-be-split object according to the target field, the value range of the target field and the split mode includes: querying a second database object from the to-be-split object, in which the target field is between the first transaction code and the second transaction code, and the time field is the valid time. The second database object is extracted from the to-be-split object to generate a second split object of the to-be-split object. The value of the target field can also be a range to better adapt to different split needs.

[0097] The second database object is formed by data records extracted from the to-be-split object. The data records match the split information, i.e., the target field of the data records is between the first transaction code and the second transaction code, and the time field of the data records corresponds to the valid time in the split information.

[0098] If the to-be-divided object is a database, the second divided object is a sub-database of the to-be-divided object. The second database object is extracted from the to-be-divided database, and the data records in the extracted second database object form a sub-database of the to-be-divided object, i.e., the second divided object.

[0099] If the to-be-divided object is a data table, the second divided object is a sub-table of the to-be-divided object. The second database object is extracted from the to-be-divided data table, and the data records in the extracted second database object form a sub-table of the to-be-divided object, i.e., the second divided object.

[0100] In an embodiment of the present application, the division mode is a time mode, and the division information further comprises a maximum interval of start and end dates. The division operation on the to-be-divided object according to the target field, the value range of the target field, and the division mode comprises: querying, from the to-be-divided object, a third database object in which the target field is within the value range, and the interval between the start date and the end date is not greater than the maximum interval of start and end dates; and extracting the third database object from the to-be-divided object to generate a third divided object of the to-be-divided object.

[0101] The third database object is composed of data records extracted from the to-be-divided object. The data records match the division information, i.e., the target field of the data records is within the value range of the division information, and the interval between the start date and the end date of the data records is not greater than the maximum interval of start and end dates in the division information.

[0102] If the to-be-divided object is a database, the third divided object is a sub-database of the to-be-divided object. The third database object is extracted from the to-be-divided database, and the data records in the extracted third database object form a sub-database of the to-be-divided object, i.e., the third divided object.

[0103] If the to-be-divided object is a data table, the third divided object is a sub-table of the to-be-divided object. The third database object is extracted from the to-be-divided data table, and the data records in the extracted third database object form a sub-table of the to-be-divided object, i.e., the third divided object.

[0104] In a case that the segmentation mode is the time mode, the segmentation information can further include a date maximum interval to meet different segmentation needs. After receiving a query request for the to-be-segmented object, a query interval between a start date and an end date corresponding to the query request can be determined. In a case that the query interval is not greater than the start-end date maximum interval, the query request is executed in the third segmented object; in a case that the query interval is greater than the start-end date maximum interval, the query request is executed in the historical database corresponding to the to-be-segmented object. Different query requests are allocated to different database segmented objects, which can improve the execution efficiency of the query request and save system resources compared with querying in a full-amount database object.

[0105] Figure 3 is a flowchart of a database object segmentation method based on a feature field mode provided by a third embodiment of the present application, as shown in the figure, the method comprises the following steps: Figure 3

[0106] Step 301: receiving a segmentation instruction for a database object, and determining a filter file corresponding to the segmentation instruction.

[0107] Step 302: obtaining segmentation information from the filter file, wherein the segmentation information comprises a to-be-segmented object, a value range of a target field, a segmentation mode, a feature field and a feature value, the segmentation mode is a feature field mode, and the value range comprises a target transaction code.

[0108] In a case that the segmentation mode is the feature field mode, the segmentation information can comprise the feature field and the feature value. The feature field can be other fields in the to-be-segmented object except the target field, such as gender, currency, channel, etc. The feature value needs to match the feature field, for example, the feature field is gender, and the feature value can be male or female. The feature field is currency, and the feature value can be RMB, USD or GBP, etc.

[0109] Step 303: querying a fourth database object from the to-be-segmented object, wherein the target field is the target transaction code, and the feature field is the feature value.

[0110] The fourth database object is composed of data records extracted from the to-be-segmented object. The data records match the segmentation information, that is, the target field of the data records corresponds to the target transaction code in the segmentation information, and the feature field of the data records corresponds to the feature value in the segmentation information.

[0111] Step 304: extracting the fourth database object from the to-be-segmented object to generate a fourth segmented object of the to-be-segmented object.

[0112] ​If the to-be-split object is a database, the fourth split object is a sub-database of the to-be-split object. The fourth database object is extracted from the to-be-split database, and a sub-database, i.e., the fourth split object, of the to-be-split object is formed by data records in the extracted fourth database object.

[0113] If the to-be-split object is a data table, the fourth split object is a sub-table of the to-be-split object. The fourth database object is extracted from the to-be-split data table, and a sub-table, i.e., the fourth split object, of the to-be-split object is formed by data records in the extracted fourth database object.

[0114] In the case where the split mode is the characteristic field mode, the target database or the target table can be split into a plurality of sub-databases or sub-tables as needed according to the transaction field and the characteristic field.

[0115] Figure 4 is a flowchart of a database object split method based on a custom mode provided by the fourth embodiment of the present application, as shown in Figure 4 the method comprises the following steps.

[0116] Step 401: receiving a split instruction for a database object, and determining a filter file corresponding to the split instruction.

[0117] Step 402: obtaining split information from the filter file, wherein the split information comprises a to-be-split object, a value range of a target field, and a split mode, and the split mode is a custom mode.

[0118] Step 403: receiving a custom field and a value range of the custom field input by a user for the filter file.

[0119] In the case where the split mode is the custom mode, the custom field and the value range of the custom field input by the user for the filter file need to be received, and the custom field and the value range of the custom field are kept in the filter file.

[0120] Step 404: querying a fifth database object from the to-be-split object, wherein a target field of the fifth database object is within the value range of the target field, and a custom field of the fifth database object is within the value range of the custom field.

[0121] The fifth database object is formed by data records extracted from the to-be-split object. The data records match the split information, i.e., a target field of the data records is within the value range of the target field in the split information, and a custom field of the data records is within the value range of the custom field in the split information.

[0122] Step 405: extracting the fifth database object from the to-be-split object to generate a fifth split object of the to-be-split object.

[0123] If the to-be-split object is a database, the fifth split object is a sub-database of the to-be-split object. The fifth database object is extracted from the to-be-split database, and a sub-database of the to-be-split object, i.e., the fifth split object, is formed by data records in the extracted fifth database object.

[0124] If the to-be-split object is a data table, the fifth split object is a sub-table of the to-be-split object. The fifth database object is extracted from the to-be-split data table, and a sub-table of the to-be-split object, i.e., the fifth split object, is formed by data records in the extracted fifth database object.

[0125] In an embodiment of the present application, a custom mode of splitting is provided, and a user can set a custom field and a value range of the custom field according to business needs. The system can perform splitting processing on a database object according to a target field and the custom field and the value range of the custom field set by the user.

[0126] In an embodiment of the present application, the splitting information further includes a historical time interval, and the splitting operation on the to-be-split object according to the value range of the target field and the splitting mode includes: querying a sixth database object from the to-be-split object, where a target field in the sixth database object is within the value range of the target field, a custom field in the sixth database object is within the value range of the custom field, and an interval between an effective date in the sixth database object and a current date is less than the historical time interval; and extracting the sixth database object from the to-be-split object to generate a sixth split object of the to-be-split object.

[0127] The effective date can be obtained in various ways, such as directly from a field of the effective date, or from a start time, an end time, or a transaction time. The current date is a current date of the system. In the case where the splitting mode is a custom mode, the splitting information can further include a historical time interval, and the database object is split by using a time interval between the effective date and the current date to meet different splitting needs.

[0128] The sixth database object is formed by data records extracted from the to-be-split object. The data records match the splitting information, i.e., a target field of the data records is within the value range of the target field in the splitting information, a custom field of the data records is within the value range of the custom field in the splitting information, and an interval between the effective date in the data records and the current date is less than the historical time interval in the splitting information.

[0129] If the to-be-split object is a database, the sixth split object is a sub-database of the to-be-split object. The sixth database object is extracted from the to-be-split database, and a sub-database, i.e., the sixth split object, of the to-be-split object is formed by data records in the extracted sixth database object.

[0130] If the to-be-split object is a data table, the sixth split object is a sub-table of the to-be-split object. The sixth database object is extracted from the to-be-split data table, and a sub-table, i.e., the sixth split object, of the to-be-split object is formed by data records in the extracted sixth database object.

[0131] When a query request for the to-be-split object is received, a valid date corresponding to the query request is determined, and a query interval between the valid date corresponding to the query request and a current date is determined; in a case where the query interval is not greater than the historical data interval, the query request is executed in the sixth split object; in a case where the query interval is greater than the historical time interval, the query request is executed in the historical database corresponding to the to-be-split object. Different query requests are allocated to different database split objects, which can improve the execution efficiency of the query request and save system resources compared with querying in a full-amount database object.

[0132] To make the method of the embodiment of the application more convenient to understand, the following explains a specific implementation process of a database split scheme. To realize transaction sub-database and sub-table operation and transaction code binding, the name of a filter file of each transaction can be determined according to a transaction code, for example, the name of the filter file can be DataFilter-transaction code.xml. A data filter interceptor is defined by using the AOP feature of Spring, which is used to parse the filter file defined in the foregoing. It is decided which database and which table are queried according to conditions in the filter file. In this way, when a user request is issued, the effect of sub-database and sub-table can be realized according to different input conditions of each transaction. Considering business requirements, the parameter configuration of the filter file can be modified to adjust the actual queried database and table.

[0133] The transaction-level sub-database and sub-table scheme provided by the embodiment of the application can realize self-defined and controllable sub-database and sub-table query according to request conditions. The sub-database and sub-table scheme can include the following steps.

[0134] Step S01: defining a data filter interceptor according to a transaction. For each transaction to be sub-database and sub-table, a filter file is defined according to the transaction, and the filter file is intercepted by the aop feature when a user request is issued. The name of the filter file can be DataFilter-transaction code.xml. The number of filter files is in a 1:1 relationship with the number of transactions. The filter file can include information such as a transaction code, a request entity object, a split mode, date 1, date 2, and a self-defined date number.

[0135] Step S02: defining data filter interceptor, parsing the previous filter file. Specifically, it can include the following steps:

[0136] In the web.xml, introduce the definition class datafilter.xml; in the datafilter.xml, use DI (dependency injection) and IOC (inversion of control) management parsing class DataFilterConfigParser in the container, for parsing filter file. In DataFilterConfigParser.java, use the characteristics of Spring-beans interface programming, implement the afterPropertiesSet() method of InitializingBean interface, and then parse the transaction code, request entity object, and split mode xml fragments in the filter file.

[0137] In which, id can be marked by transaction code identification as a unique identifier; class is the request vo, encapsulating the user's request information; mode indicates the processing mode.

[0138] Step S03: define necessary auxiliary classes. The filter interceptor in the above step S02 needs some auxiliary classes to work, which are described as follows:

[0139] Auxiliary class 1: must include the following attribute mapping relationship:

[0140] Transaction code id, dateMaxInterval (maximum interval of start and end date), histInterval (more than how many days, query AB library mark), beginField (query start field), endField (query end field), characteristic id Field, mode (split mode) (here, two common modes are listed: date (date mode), query according to date; characteristic field mode, use a characteristic id as the query condition, in actual application, you can choose appropriate id or characteristic value according to each business system, to facilitate the expansion of application).

[0141] Auxiliary class 2: the main logic is to judge whether the start date is legal, and has the judgment of querying AB library.

[0142] The logic of judging whether the start date is legal is as follows: if the mode in the above configuration file is "date", and the "beginField", "endField", "dateMaxInterval" values in the configuration file are obtained, the logical check is performed, and the interval between the start date and the end date is not greater than "dateMaxInterval".

[0143] The logic for judging the query of the AB library: if mode = feature id in the configuration file above, the feature information is extracted from the feature id (the extraction method is shown in the auxiliary class 3 below), and the "histInterval" in the configuration file is used to judge the query of the AB library (if the valid date < the current date - the value of "histInterval", the B library history library is queried, otherwise the A library production library is queried)

[0144] Auxiliary class 3: used for first acquiring [feature id] and then acquiring the valid date (the division date of the AB library) or machine information. For example, the bill system can use the bill identification, and the transaction system can use the transaction number identification.

[0145] It is not necessary to perform the splitting operation on all libraries or tables, and only the tables with large business data volume can be targeted, so that the development amount in the actual code engineering can be simplified. By controlling the granularity of the library and table division to the transaction level, the transaction refinement control degree is improved, and more stringent and refined business requirements can be met. Customized library division fields can be added in the logic for judging the query of the AB library, so as to cope with more flexible requirements.

[0146] The scheme of the embodiment of the application innovatively divides the library and table according to the transaction level granularity on the basis of the ordinary library and table division. The commonly used idea of the table and library division logic is provided, the customized library division field is added, and the most commonly used date query and flag are taken as examples for illustration, and specific business logic can also be added, so as to facilitate the function extension of various businesses.

[0147] In addition, in terms of the cross-shard transaction consistency, in view of the problem of inaccurate data falling into the partition, a history table can be used for bottom-up operation. Data analysis is performed at the end of each day, and the data with inaccurate partition is migrated to the corresponding shard area.

[0148] Figure 5 is a structural schematic diagram of a database object splitting device provided by an embodiment of the application, as shown in the figure, the device comprises: Figure 5

[0149] The instruction receiving module 501 is configured to receive a splitting instruction for a database object, and determine a filter file corresponding to the splitting instruction;

[0150] The information obtaining module 502 is configured to obtain splitting information from the filter file, wherein the splitting information comprises: a to-be-split object, a value range of a target field and a splitting mode; the to-be-split object comprises a target database and / or a target table, the target field is a transaction field in the to-be-split object, and the splitting mode is a date mode, a feature field mode or a custom mode;

[0151] ​The segmentation module 503 is configured to perform a segmentation operation on the to-be-segmented object according to the target field, the value range of the target field, and the segmentation mode.

[0152] Optionally, the segmentation module 503 is specifically configured to:

[0153] perform a database segmentation operation on the target database according to the target field, the value range, and the segmentation mode, to obtain a plurality of sub-databases of the target database;

[0154] perform a table segmentation operation on the target table according to the target field, the value range, and the segmentation mode, to obtain a plurality of sub-tables of the target table.

[0155] Optionally, the segmentation mode is a time mode, the value range includes a target transaction code, and the segmentation information further includes a start time and an end time.

[0156] The segmentation module 503 is specifically configured to query, from the to-be-segmented object, a first database object in which a target field is the target transaction code and a time field is between the start time and the end time.

[0157] The segmentation module 503 is specifically configured to query, from the to-be-segmented object, a first database object in which a target field is the target transaction code and a time field is between the start time and the end time.

[0158] Optionally, the segmentation mode is a time mode, the value range includes a first transaction code and a second transaction code, and the segmentation information further includes a valid time.

[0159] The segmentation module 503 is specifically configured to query, from the to-be-segmented object, a second database object in which a target field is between the first transaction code and the second transaction code and a time field is the valid time.

[0160] The segmentation module 503 is specifically configured to query, from the to-be-segmented object, a second database object in which a target field is between the first transaction code and the second transaction code and a time field is the valid time.

[0161] Optionally, the segmentation mode is a time mode, and the segmentation information further includes a maximum interval of start and end dates.

[0162] The segmentation module 503 is specifically configured to perform a segmentation operation on the to-be-segmented object according to the target field, the value range of the target field, and the segmentation mode, including:

[0163] The segmentation module 503 is specifically configured to perform a segmentation operation on the to-be-segmented object according to the target field, the value range of the target field, and the segmentation mode, including:

[0164] extract the third database object from the to-be-split object to generate a third split object of the to-be-split object.

[0165] Optionally, the apparatus further comprises:

[0166] The query module 504 is configured to receive a query request for the to-be-split object.

[0167] The query module 504 is configured to receive a query request for the to-be-split object.

[0168] In a case where the query interval is not greater than the maximum interval of the start date and the end date, the query request is executed in the third split object.

[0169] In a case where the query interval is greater than the maximum interval of the start date and the end date, the query request is executed in the historical database corresponding to the to-be-split object.

[0170] Optionally, the split mode is a feature field mode, and the value range includes a target transaction code.

[0171] The split module 503 is specifically configured to query, from the to-be-split object, a fourth database object in which a target field is the target transaction code and a feature field is the feature value.

[0172] extract the fourth database object from the to-be-split object to generate a fourth split object of the to-be-split object.

[0173] Optionally, the split mode is a custom mode.

[0174] The split module 503 is specifically configured to:

[0175] The split module 503 is specifically configured to:

[0176] The split module 503 is specifically configured to query, from the to-be-split object, a fifth database object in which a target field is within the value range of the target field and a custom field is within the value range of the custom field.

[0177] extract the fifth database object from the to-be-split object to generate a fifth split object of the to-be-split object.

[0178] Optionally, the split information further includes a historical time interval.

[0179] The splitting module 503 is specifically configured to: from the to-be-split object, query a sixth database object in which a target field is within a value range of the target field, a self-defined field is within a value range of the self-defined field, and an interval between an effective date and a current date is less than the historical time interval;

[0180] The sixth database object is extracted from the to-be-split object to generate a sixth split object of the to-be-split object.

[0181] Optionally, the query module 504 is configured to receive a query request for the to-be-split object.

[0182] The query module 504 is configured to receive a query request for the to-be-split object.

[0183] In a case where the query interval is not greater than the historical data interval, the query request is executed in the sixth split object.

[0184] In a case where the query interval is greater than the historical time interval, the query request is executed in a historical database corresponding to the to-be-split object.

[0185] An embodiment of the present application provides an electronic device, comprising:

[0186] One or more processors;

[0187] A storage device configured to store one or more programs,

[0188] When the one or more programs are executed by the one or more processors, the one or more processors implement the method of any one of the above embodiments.

[0189] An embodiment of the present application provides a computer program product comprising a computer program which, when executed by a processor, implements the method for splitting a database object in the embodiment of the present application.

[0190] Reference is made below to Figure 6 which shows a structural schematic diagram of a computer system 600 of a terminal device suitable for being used to implement the embodiment of the present application. Figure 6 The terminal device shown is merely an example, and should not bring any limitation to the function and use range of the embodiment of the present application.

[0191] As Figure 6As shown, the computer system 600 includes a central processing unit (CPU) 601 which can perform various appropriate actions and processes according to programs stored in a read only memory (ROM) 602 or loaded into a random access memory (RAM) 603 from a storage section 608. In the RAM 603, various programs and data required for the operation of the system 600 are also stored. The CPU 601, the ROM 602, and the RAM 603 are connected to each other through a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.

[0192] Connected to the I / O interface 605 are an input section 606 including a keyboard, a mouse, etc.; an output section 607 including a display device such as a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN card, a modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the I / O interface 605 as necessary. A removable recording medium 611 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc. is attached to the drive 610 as necessary, so that a computer program read therefrom is installed into the storage section 608 as necessary.

[0193] In particular, the processes described above with reference to the flowcharts can be implemented as a computer software program according to the embodiments disclosed herein. For example, the embodiments disclosed herein include a computer program product comprising a computer program carried on a computer readable medium, the computer program comprising program code for performing the methods illustrated by the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via the communication section 609, and / or installed from the removable recording medium 611. When the computer program is executed by the central processing unit (CPU) 601, the above-described functions defined in the system of the present application are performed.

[0194] It should be noted that the computer-readable medium shown in the present application can be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may, for example, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or component, or any combination of the above. More specific examples of computer-readable storage media can include, but are not limited to, an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, the computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, device or component. In the present application, the computer-readable signal medium can include a data signal carried in a baseband or as a part of a carrier wave, which carries computer-readable program code. Such a propagated data signal can take various forms, including but not limited to an electromagnetic signal, an optical signal or any suitable combination of the above. The computer-readable signal medium can also be any computer-readable medium other than the computer-readable storage medium, which can send, propagate or transmit a program for use by or in conjunction with an instruction execution system, device or component. The program code contained on the computer-readable medium can be transmitted by any suitable medium, including but not limited to wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0195] The flowcharts and block diagrams in the drawings illustrate the possible implementation architectures, functions and operations of the systems, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowcharts or block diagrams can represent a module, a program segment, or a portion of code that contains one or more executable instructions for implementing the specified logical functions. It should also be noted that in some alternative implementations, the functions noted in the blocks can occur in different orders than that shown in the figures. For example, two blocks that are shown in succession can actually be executed substantially concurrently, or they can sometimes be executed in reverse order, depending on the functionality involved. It should also be noted that each block in the block diagrams or flowcharts, and combinations of blocks in the block diagrams or flowcharts, can be implemented by a dedicated hardware-based system that performs specified functions or operations, or can be implemented by a combination of special-purpose hardware and computer instructions.

[0196] The modules described in the embodiments of the present application can be implemented in the form of software or hardware. The described modules can also be arranged in a processor, for example, can be described as: instruction receiving module, information obtaining module and splitting module. In some cases, the names of these modules do not constitute a limitation on the modules themselves, for example, the instruction receiving module can also be described as "a module that receives a splitting instruction for a database object, and determines a filter file corresponding to the splitting instruction".

[0197] As another aspect, the present application also provides a computer readable medium, which can be included in the device described in the above embodiments, or can exist independently without being assembled into the device. The computer readable medium carries one or more programs, which, when executed by the device, cause the device to include:

[0198] receiving a splitting instruction for a database object, and determining a filter file corresponding to the splitting instruction;

[0199] obtaining splitting information from the filter file, the splitting information including: a to-be-split object, a value range of a target field and a splitting mode; wherein the to-be-split object includes a target database and / or a target table, the target field is a transaction field in the to-be-split object, and the splitting mode is a date mode, a characteristic field mode or a custom mode;

[0200] performing a splitting operation on the to-be-split object according to the target field, the value range of the target field and the splitting mode.

[0201] According to the technical scheme of the embodiments of the present application, the filter file corresponding to the splitting instruction is determined, the splitting information is obtained from the filter file, and the splitting operation is performed on the to-be-split object according to the splitting information. The splitting information such as the to-be-split object, the value range of the target field and the splitting mode can be set in the filter file according to specific needs. According to the splitting information, the database or the data table can be flexibly split.

[0202] In addition, the target field is a transaction field in the to-be-split object, and the target field can be determined according to the actual application of the to-be-split database object. For example, for a database object of a bill system, a bill identification field can be selected as the target field. For a database object of a transaction system, a transaction identification field can be selected as the target field. Taking the transaction field in the to-be-split object as the target field can improve the performance of cross-database operation, improve the degree of transaction refinement control, and meet more demanding and refined business requirements.

[0203] The foregoing detailed description has set forth various embodiments of the devices and / or processes via the use of specific terminology. However, embodiments thereof can be practiced with the exact description not being presented in detail. The term "device" should be understood to encompass devices operating in various modes, such as active mode, sleep mode, hibernate mode, and the like. The terms "coupled" and "connected," along with their derivatives, can be used. It should be understood that these terms are not intended as synonyms for each other. Rather, particular circuitry that can be said to be coupled or connected can be coupled and connected via some transmission medium.

Claims

1. A method of partitioning a database object, the method comprising: The method comprises the steps of: receiving a splitting instruction for a database object, and determining a filter file corresponding to the splitting instruction; the determining of the filter file corresponding to the splitting instruction comprises: determining instruction information corresponding to the splitting instruction; determining a filter file corresponding to the instruction information according to a corresponding relationship; wherein the instruction information comprises at least one of the following: a database, a data table, a transaction field, and a transaction field value; and the corresponding relationship comprises: a corresponding relationship between a database and a filter file, a corresponding relationship between a data table and a filter file, a corresponding relationship between a transaction field and a filter file, and a corresponding relationship between a transaction field, a transaction field value, and a filter file, which are set in a system; obtaining splitting information from the filter file, wherein the splitting information comprises: a to-be-split object, a value range of a target field, and a splitting mode; wherein the to-be-split object comprises: a target database and / or a target table, the target field is a transaction field in the to-be-split object, and the splitting mode is: a date mode, a characteristic field mode, or a custom mode; performing a splitting operation on the to-be-split object according to the target field, the value range of the target field, and the splitting mode; when the splitting mode is a custom mode, the method further comprises: receiving a custom field and a value range of the custom field input by a user for the filter file before the splitting operation on the to-be-split object according to the value range of the target field and the splitting mode; the performing of the splitting operation on the to-be-split object according to the target field, the value range of the target field, and the splitting mode comprises: querying a fifth database object from the to-be-split object, wherein the target field in the fifth database object is within the value range of the target field, and a custom field in the fifth database object is within the value range of the custom field; and extracting the fifth database object from the to-be-split object to generate a fifth split object of the to-be-split object.

2. The method of claim 1, wherein, the performing of the splitting operation on the to-be-split object according to the target field, the value range of the target field, and the splitting mode comprises: performing a database splitting operation on the target database according to the target field, the value range, and the splitting mode to obtain a plurality of databases of the target database; performing a table splitting operation on the target table according to the target field, the value range, and the splitting mode to obtain a plurality of tables of the target table.

3. The method of claim 1, wherein, when the splitting mode is a time mode, the value range comprises: a target transaction code, and the splitting information further comprises: a start time and an end time; the performing of the splitting operation on the to-be-split object according to the target field, the value range of the target field, and the splitting mode comprises: querying a first database object from the to-be-split object, wherein the target field in the first database object is the target transaction code, and a time field in the first database object is between the start time and the end time; and extracting the first database object from the to-be-split object to generate a first split object of the to-be-split object.

4. The method of claim 1, wherein, The segmentation mode is a time mode, and the value range includes a first transaction code and a second transaction code, and the segmentation information further includes a valid time; The segmentation operation on the to-be-segmented object according to the target field, the value range of the target field and the segmentation mode includes: Querying, from the to-be-segmented object, a second database object in which the target field is between the first transaction code and the second transaction code and the time field is the valid time; Extracting the second database object from the to-be-segmented object to generate a second segmented object of the to-be-segmented object.

5. The method of claim 1, wherein, The segmentation mode is a time mode, and the segmentation information further includes a maximum interval of start and end dates; The segmentation operation on the to-be-segmented object according to the target field, the value range of the target field and the segmentation mode includes: Querying, from the to-be-segmented object, a third database object in which the target field is within the value range and an interval between a start date and an end date is not greater than the maximum interval of start and end dates; Extracting the third database object from the to-be-segmented object to generate a third segmented object of the to-be-segmented object.

6. The method of claim 5, wherein, After the third database object is extracted from the to-be-segmented object to generate the third segmented object of the to-be-segmented object, the method further includes: Receiving a query request for the to-be-segmented object; Determining a start date and an end date corresponding to the query request and determining a query interval between the start date and the end date corresponding to the query request; In a case where the query interval is not greater than the maximum interval of start and end dates, executing the query request in the third segmented object; In a case where the query interval is greater than the maximum interval of start and end dates, executing the query request in a historical database corresponding to the to-be-segmented object.

7. The method of claim 1, wherein, The segmentation mode is a feature field mode, the value range includes a target transaction code, and the segmentation information further includes a feature field and a feature value; The segmentation operation on the to-be-segmented object according to the value range of the target field and the segmentation mode includes: Querying, from the to-be-segmented object, a fourth database object in which the target field is the target transaction code and the feature field is the feature value; Extracting the fourth database object from the to-be-segmented object to generate a fourth segmented object of the to-be-segmented object.

8. The method of claim 1, wherein, The segmentation information further includes a historical time interval; The segmentation operation on the to-be-segmented object according to the value range of the target field and the segmentation mode includes: Querying, from the to-be-segmented object, a sixth database object in which the target field is within the value range of the target field, a self-defined field is within the value range of the self-defined field, and an interval between an effective date and a current date is less than the historical time interval; Extracting the sixth database object from the to-be-segmented object to generate a sixth segmented object of the to-be-segmented object.

9. The method of claim 8, wherein, After the sixth database object is extracted from the to-be-segmented object to generate the sixth segmented object of the to-be-segmented object, the method further includes: receiving a query request for the to-be-split object; determining a valid date corresponding to the query request, and determining a query interval between the valid date corresponding to the query request and a current date; in a case where the query interval is not greater than a historical data interval, executing the query request in the sixth split object; in a case where the query interval is greater than the historical time interval, executing the query request in a historical library corresponding to the to-be-split object.

10. A database object partitioning device, characterized in that, comprising: an instruction receiving module, configured to receive a split instruction for a database object, and determine a filter file corresponding to the split instruction; the instruction receiving module is specifically configured to: determine instruction information corresponding to the split instruction; and determine the filter file corresponding to the instruction information according to a correspondence relationship; wherein the instruction information comprises at least one of the following: a database, a data table, a transaction field, and a transaction field value; and the correspondence relationship comprises a correspondence relationship between a database and a filter file, a correspondence relationship between a data table and a filter file, a correspondence relationship between a transaction field and a filter file, and a correspondence relationship between a transaction field, a transaction field value, and a filter file, which are set in a system; an information obtaining module, configured to obtain split information from the filter file, the split information comprising: a to-be-split object, a value range of a target field, and a split mode; wherein the to-be-split object comprises a target database and / or a target table, the target field is a transaction field in the to-be-split object, and the split mode is a date mode, a feature field mode, or a custom mode; a splitting module, configured to perform a split operation on the to-be-split object according to the target field, the value range of the target field, and the split mode; the split mode is a custom mode; and the splitting module is specifically configured to: receive a custom field and a value range of the custom field input by a user for the filter file; query a fifth database object from the to-be-split object, the fifth database object being such that the target field is within the value range of the target field, and the custom field is within the value range of the custom field; and extract the fifth database object from the to-be-split object to generate a fifth split object of the to-be-split object.

11. The apparatus of claim 10, wherein, the splitting module is specifically configured to: perform a database splitting operation on the target database according to the target field, the value range, and the split mode, to obtain a plurality of databases of the target database; perform a table splitting operation on the target table according to the target field, the value range, and the split mode, to obtain a plurality of tables of the target table.

12. An electronic device, comprising: comprising: one or more processors; a storage device configured to store one or more programs, when the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1-9.

13. A computer readable medium having stored thereon a computer program, characterized in that the program is executed by the processor to implement the method according to any one of claims 1-9.

14. A computer program product comprising a computer program, characterized in that, the computer program is executed by the processor to implement the method according to any one of claims 1-9.

Citation Information

Patent Citations

  • Data management method and data management device

    CN105868421A

  • Data storage method and device, computer equipment and storage medium

    CN110888872A