Order database automatic table partitioning method, device, equipment and storage medium

Through the automatic subtable method of order database, the order data is converted and historical data is reassigned using the attribute configuration table, which solves the problem of processing multi-attribute order data and unsegmented historical data, and improves the rationality of the subtable and data retrieval performance of the database.

CN117235074BActive Publication Date: 2025-08-26CHINA UNITED NETWORK COMM GRP CO LTD +2
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311261305.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-09-27
Publication Date
2025-08-26
Estimated Expiration
2043-09-27

AI Technical Summary

Technical Problem

The prior art cannot be applied to complex order data with multiple attributes, and cannot process untitled historical data, resulting in inefficient data query and may cause database crash.

Method used

By obtaining data operation instructions, using the attribute configuration table to convert order data, implementing multi-attribute classification storage, and reallocating the untitled historical data, and writing data into the corresponding attribute subtitles using preset subtitles.

Benefits of technology

It improves the rationality and data retrieval performance of database subtables, avoids database crashes, and improves data query efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117235074B_ABST
    Figure CN117235074B_ABST
Patent Text Reader

Abstract

The present application provides a method, apparatus, device and storage medium for automatic table partitioning of an order database. For the newly added order data, the order attribute information is converted according to a preset attribute configuration table to obtain a converted order attribute instance table, and the order attribute instance table is written into a general attribute table and an attribute sub-table corresponding to the creation date of the order data. By using the attribute configuration table to convert the order data, classified storage of multiple attributes is achieved. For the query historical data, the historical creation time of the historical data is obtained based on the historical data identifier, and the historical data is written into the attribute sub-table corresponding to the historical creation date according to a preset table partitioning rule. The historical data table name in the query historical data instruction is replaced with the table name of the sub-table where the historical data is located. By cutting over the existing data, the historical data is redistributed, the rationality of the database table partitioning is improved, and the data retrieval performance is enhanced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a method, device, equipment and storage medium for automatically partitioning an order database. Background Art

[0002] With the development of information technology, enterprises are generating more and more data during operations and production. If all the data is stored in a single table, it will often exceed the storage threshold of the table. In other words, when traditional relational databases operate on massive amounts of data, the retrieval performance will drop sharply when the data volume exceeds a certain level, and it will be unable to meet the needs of fast query and data insertion. In addition, various problems may occur when performing data queries, such as server resource exhaustion, processing timeouts due to excessive data transmission volume, etc., which will ultimately lead to the query being unable to complete and the query result structure being much larger than expected.

[0003] In the existing technology, concurrent requests are distributed to different databases and data tables through the database and table sharding strategy. For example, when the amount of data in a table in the database is too large, the data in the table is divided according to certain rules, such as by time interval, and stored in multiple tables with the same structure. When the data is subsequently operated, it is no longer necessary to operate on a large table. Instead, the pressure is distributed to multiple tables to improve execution efficiency, thereby solving the problems of poor database retrieval performance and slow database response caused by large data volumes and high concurrency. This technology uses the database's own capabilities to solve the problem of sharded table and paging query.

[0004] However, for production orders, their data has complex attribute fields. The existing table sharding technology does not take into account the problem of multiple attributes of a single order. It only divides the data table according to simple time intervals. When performing data queries, it will still occupy the database connection for a long time. If there are multiple identical operations, it may even cause the database system to crash. In addition, the existing table sharding technology is based on rule design in the early stage of database establishment, and cannot reprocess data that was not sharded in the past. Therefore, when it comes to historical data queries in unsharded tables, it still needs to face the disadvantages of excessive data transmission volume, such as low query efficiency. Summary of the Invention

[0005] The present application provides a method, device, equipment and storage medium for automatically partitioning an order database into tables, which is used to solve the problem that the existing technology is not applicable to complex order data with multiple attributes and cannot process historical data that has not been partitioned into tables, resulting in low data query efficiency.

[0006] In a first aspect, the present application provides a method for automatically partitioning an order database, comprising:

[0007] Obtaining data operation instructions, wherein the data operation instructions include adding new order data and querying historical data, the order data includes an order identifier and order attribute information, and the historical data includes a historical data identifier;

[0008] For the newly added order data, convert the order attribute information according to a preset attribute configuration table to obtain a converted order attribute instance table, and write the order attribute instance table into a general attribute table. The attribute configuration table is used to configure attribute query information according to the order attribute information;

[0009] While writing the order attribute instance table into the general attribute table, the creation date of the order data is obtained based on the order identifier, and the order attribute instance table of the order data is written into the attribute sub-table corresponding to the creation date according to a preset sub-table rule, wherein the sub-table rule is used to divide the order data according to the time interval to which the creation date of the order data belongs;

[0010] For the query historical data, the historical creation time of the historical data is obtained based on the historical data identifier, and the historical data is written into the attribute sub-table corresponding to the historical creation date according to the preset sub-table rules, and the historical data table name in the query historical data instruction is replaced with the attribute sub-table name where the historical data is located.

[0011] Optionally, in the above method, the attribute query information includes an attribute code and an attribute name, and converting the order attribute information according to a preset attribute configuration table to obtain a converted order attribute instance table includes:

[0012] Obtaining, according to the order attribute information, the attribute code and attribute name corresponding to the order attribute information in the attribute configuration table;

[0013] The attribute code and the attribute name are added to the order data in a preset data structure to generate the order attribute instance table.

[0014] Optionally, in the above method, obtaining the creation date of the order data based on the order identifier includes:

[0015] Extracting the first text content in the order identifier;

[0016] Segmenting the first text content according to a preset first segmentation rule to obtain a first key field corresponding to the order identifier, wherein the first segmentation rule is used to divide the text content into different fields;

[0017] A creation date of the order data is generated based on the first key field.

[0018] Optionally, in the above method, obtaining the historical creation time of the historical data based on the historical data identifier includes:

[0019] Extracting the second text content in the historical data identifier;

[0020] Segmenting the second text content according to a preset second segmentation rule to obtain a second key field corresponding to the historical data identifier, wherein the second segmentation rule is used to divide the text content into different fields;

[0021] A creation date of the historical data is generated based on the second key field.

[0022] Optionally, in the above method, writing the order attribute instance table of the order data into the attribute sub-table corresponding to the creation date according to a preset sub-table rule includes:

[0023] According to the table sharding rule, obtain the target attribute sharding table corresponding to the creation date of the order data;

[0024] The order attribute instance table of the order data is written into the target attribute sub-table.

[0025] Optionally, the method described above, before writing the order attribute instance table of the order data into the attribute sub-table corresponding to the creation date according to the preset sub-table rule, further includes:

[0026] Determine whether a target attribute sub-table already exists for the creation date of the order data;

[0027] If not, based on the time interval of the table sub-table rule and the existing attribute sub-table, a new sub-table is created as the target attribute sub-table, which has a time interval that does not overlap with the existing attribute sub-table.

[0028] Optionally, the method described above, after replacing the historical data table name in the historical data query instruction with the name of the attribute sub-table where the historical data is located, further includes:

[0029] Determine whether there is a historical data table name that has not been replaced with the attribute sub-table name where the historical data is located;

[0030] If not, delete the general attribute table.

[0031] In a second aspect, the present application provides an automatic table partitioning device for an order database, comprising:

[0032] An instruction acquisition module is used to acquire data operation instructions, wherein the data operation instructions include adding new order data and querying historical data, the order data includes an order identifier and order attribute information, and the historical data includes a historical data identifier;

[0033] An order attribute information conversion module is configured to convert the order attribute information of the newly added order data according to a preset attribute configuration table, obtain a converted order attribute instance table, and write the order attribute instance table into a general attribute table. The attribute configuration table is used to configure attribute query information according to the order attribute information.

[0034] An order data table partitioning module is configured to, while writing the order attribute instance table into the general attribute table, obtain a creation date of the order data based on the order identifier, and write the order attribute instance table of the order data into an attribute sub-table corresponding to the creation date according to a preset table partitioning rule, wherein the table partitioning rule is configured to partition the order data according to the time interval specified by the creation date of the order data;

[0035] The historical data table sub-module is used to obtain the historical creation time of the historical data based on the historical data identifier for the query historical data, write the historical data into the attribute sub-table corresponding to the historical creation date according to the preset table sub-rules, and replace the historical data table name in the historical data query instruction with the attribute sub-table name where the historical data is located.

[0036] In a third aspect, the present application provides an electronic device comprising a memory, a processor, and computer-executable instructions stored in the memory and executable on the processor. When the processor executes the computer-executable instructions, the method for automatically partitioning an order database as described in any one of the first aspects above is implemented.

[0037] In a fourth aspect, the present application provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the method for automatically partitioning an order database according to any one of the first aspects.

[0038] The present application provides an automatic table partitioning method, apparatus, device and storage medium for an order database, which obtains data operation instructions, wherein the data operation instructions include adding new order data and querying historical data, the order data includes an order identifier and order attribute information, and the historical data includes a historical data identifier; for the newly added order data, the order attribute information is converted according to a preset attribute configuration table to obtain a converted order attribute instance table, and the order attribute instance table is written into a general attribute table, and the attribute configuration table is used to configure attribute query information according to the order attribute information; while writing the order attribute instance table into the general attribute table, the creation date of the order data is obtained based on the order identifier, and all the order data are partitioned according to the preset table partitioning rules. The order attribute instance table is written into the attribute sub-table corresponding to the creation date, and the sub-table rule is used to divide the order data according to the time interval to which the creation date of the order data belongs. The order data is converted by using the attribute configuration table to realize the classified storage of multiple attributes; for the query historical data, the historical creation time of the historical data is obtained based on the historical data identifier, and the historical data is written into the attribute sub-table corresponding to the historical creation date according to the preset sub-table rule, and the historical data table name in the query historical data instruction is replaced with the attribute sub-table name where the historical data is located. By cutting over the existing data, the historical data is redistributed, the rationality of the database sub-table is improved, and the data retrieval performance is improved. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0040] Figure 1 Schematic diagram of the application scenario of the method for automatically partitioning order database tables provided in the embodiment of the present application.

[0041] Figure 2 This is a flowchart of the method for automatically partitioning an order database into tables provided in an embodiment of the present application.

[0042] Figure 3 A schematic diagram of the automatic table partitioning device for an order database provided in an embodiment of the present application.

[0043] Figure 4 A schematic diagram of the structure of an electronic device based on an automatic table partitioning device for an order database provided in an embodiment of the present application.

[0044] The above drawings illustrate specific embodiments of the present application, which will be described in more detail below. These drawings and the textual description are not intended to limit the scope of the present application in any way, but rather to illustrate the concepts of the present application to those skilled in the art by reference to specific embodiments. DETAILED DESCRIPTION

[0045] Exemplary embodiments will be described in detail herein, with examples illustrated in the accompanying drawings. In the following description, when referring to the drawings, identical numerals in different figures represent identical or similar elements, unless otherwise indicated. The embodiments described in the following exemplary embodiments are not intended to represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.

[0046] In the related art, the database storage of production order system software is generally stored in a relational database (such as MySQL). When a single MySQL database table exceeds 10 million to 20 million records, the database's search performance and responsiveness will significantly decline. Current sharding solutions are based on the sharding design made during the initial database construction. However, for historical data, it is impossible to switch from a non-sharded table to a sharded table. Moreover, existing sharding methods simply divide the data by time interval, without taking into account the multiple attributes of a single order.

[0047] In response to the above technical problems, the embodiments of the present application aim to propose a method, device, equipment and storage medium for automatic table partitioning of an order database. The core concept of this method is to use an attribute configuration table to convert order data, realize multi-attribute classified storage, and cutover the existing data to realize the redistribution of historical data, thereby improving the rationality of database table partitioning and enhancing data retrieval performance.

[0048] In order to better understand the solution of the embodiment of the present application, an application scenario involved in the embodiment of the present application is first introduced below.

[0049] See also Figure 1 , Figure 1 This is a schematic diagram of an application scenario of the method for automatically partitioning an order database provided in an embodiment of the present application. Figure 1 As shown, it includes a device 100 and a server 200. The device 100 can be used to generate order data and can also be used to send operation instructions such as adding new orders and querying historical data to the server 200. The device 100 can include a personal computer, a tablet computer, a smart panel, etc., and the embodiments of the present application are not limited here.

[0050] The server 200 can be used to perform corresponding operations in response to instructions from the device end 100. Specifically, for instructions for adding new orders, the server 200 converts the order attribute information according to a preset attribute configuration table, obtains the converted order attribute instance table, writes the order attribute instance table into the general attribute table, and at the same time, obtains the creation date of the order data based on the order identifier, and writes the order attribute instance table of the order data into the attribute sub-table corresponding to the creation date according to the preset sub-table rule; for instructions for historical data query, the server 200 obtains the historical creation time of the historical data based on the historical data identifier, writes the historical data into the attribute sub-table corresponding to the historical creation date according to the preset sub-table rule, and replaces the historical data table name in the historical data query instruction with the attribute sub-table name where the historical data is located.

[0051] The following specific embodiments describe in detail the technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.

[0052] Figure 2 This is a flow chart of the method for automatically partitioning the order database provided in the embodiment of the present application. Figure 2 As shown, the method of this embodiment includes:

[0053] S201: Acquire data operation instructions, where the data operation instructions include adding new order data and querying historical data. The order data includes an order identifier and order attribute information, and the historical data includes a historical data identifier.

[0054] The execution subject of the embodiment of the present application can be a server, or an automatic table partitioning system for an order database in the server, wherein the automatic table partitioning system for an order database can be implemented through software.

[0055] In this embodiment, different table partitioning strategies can be used for newly added data and historical data. New data can be directly partitioned more finely based on its attribute information. Historical data can also be partitioned in different ways without changing its data structure. It is understood that both the order identifier and the historical data identifier can be a string of ID numbers used to distinguish newly added order data from historical data.

[0056] S202: For the newly added order data, convert the order attribute information according to a preset attribute configuration table to obtain a converted order attribute instance table, and write the order attribute instance table into a general attribute table. The attribute configuration table is used to configure attribute query information according to the order attribute information.

[0057] Understandably, in a relational database, modifying the table structure for large amounts of data can impact system performance and inconvenience field queries. Therefore, when adding new order data for attribute identification, a pre-set attribute configuration table can be used to convert the newly added order data without modifying the table structure or developing corresponding attribute code.

[0058] Specifically, after the front-end user places an order, the newly added order data is first saved, and then the corresponding attribute list in the newly added order data is converted once according to the attribute configuration table, and then falls into the order attribute instance table.

[0059] S203: While writing the order attribute instance table into the general attribute table, the creation date of the order data is obtained based on the order identifier, and the order attribute instance table of the order data is written into the attribute sub-table corresponding to the creation date according to a preset sub-table rule, wherein the sub-table rule is used to divide the order data according to the time interval to which the creation date of the order data belongs.

[0060] It can be understood that according to the setting rules of the order identifier, generally speaking, the text content in the order identifier contains information such as the creation date of the order data, such as "Order 202301...", "202304...", etc. Therefore, the creation date of the order data can be obtained by extracting the target field in the order identifier.

[0061] In this step, the corresponding sub-table can be selected based on the order data's creation date. This allows for a dual write to the attribute table based on S202. This does not affect the original query of the attribute table, and automatically writes the attribute year table, making it easier for all subsequent queries to switch to querying attributes in the year table. Specifically, the intervals can be divided by year. For example, all order data from 2022 can be written to the 2022 table, and all order data from 2023 can be written to the 2023 table.

[0062] S204: For the query historical data, obtain the historical creation time of the historical data based on the historical data identifier, write the historical data into the attribute sub-table corresponding to the historical creation date according to the preset sub-table rule, and replace the historical data table name in the query historical data instruction with the attribute sub-table name where the historical data is located.

[0063] In this embodiment, historical data is not necessarily written into the general attribute table according to attributes. More commonly, the historical data referred to in this embodiment is historical data that has not yet been divided into tables. For this part of historical data, it can be written into the attribute sub-table corresponding to the historical creation date through its historical data identifier. Accordingly, when the order database automatic sub-table system receives a query request for historical data, it replaces its historical data table name with the sub-table corresponding to the historical creation date in the interceptor executed by the Structured Query Language (SQL) based on the historical data identification parameters of the query. That is, the name of the attribute sub-table where the historical data is located.

[0064] The method for automatically partitioning an order database provided by this embodiment obtains data operation instructions, wherein the data operation instructions include adding new order data and querying historical data, the order data includes an order identifier and order attribute information, and the historical data includes a historical data identifier; for the newly added order data, the order attribute information is converted according to a preset attribute configuration table to obtain a converted order attribute instance table, and the order attribute instance table is written into a general attribute table, and the attribute configuration table is used to configure attribute query information according to the order attribute information; while writing the order attribute instance table into the general attribute table, the creation date of the order data is obtained based on the order identifier, and the order attributes of the order data are converted according to the preset partitioning rules. The instance table is written into the attribute sub-table corresponding to the creation date, and the sub-table rule is used to divide the order data according to the time interval to which the creation date of the order data belongs. The order data is converted by using the attribute configuration table to realize the classified storage of multiple attributes; for the query historical data, the historical creation time of the historical data is obtained based on the historical data identifier, and the historical data is written into the attribute sub-table corresponding to the historical creation date according to the preset sub-table rule, and the historical data table name in the query historical data instruction is replaced with the attribute sub-table name where the historical data is located. By cutting over the existing data, the historical data is redistributed, the rationality of the database sub-table is improved, and the data retrieval performance is improved.

[0065] The following is a detailed description of the technical solution of the above-mentioned method for automatically partitioning the order database.

[0066] In a possible implementation, the attribute query information includes attribute codes and attribute names. The automatic table partitioning method for order database provided in this embodiment generates an order attribute instance table through the attribute codes and attribute names corresponding to the attribute configuration table and order attribute information.

[0067] Specifically, the order attribute information is converted according to a preset attribute configuration table to obtain a converted order attribute instance table, including: obtaining the attribute code and attribute name corresponding to the order attribute information in the attribute configuration table according to the order attribute information; adding the attribute code and the attribute name to the order data in a preset data structure to generate the order attribute instance table.

[0068] In this embodiment, attribute query information can include attribute codes and attribute names. That is, based on the order attribute information in the newly added order data, attribute codes and attribute names can be added accordingly. For example, if the order attribute information in a newly added order data item is "Product 1," and the attribute code corresponding to "Production Line A" in the preset attribute configuration table is 0001 and the attribute name is Production Line A, then "Attribute Code: 0001" and "Attribute Name: Production Line A" are added to the corresponding locations in the newly added order data item to generate an order attribute instance table, facilitating subsequent table partitioning.

[0069] In this embodiment, the order attribute instance table is generated by the attribute code and attribute name corresponding to the attribute configuration table and the order attribute information. When adding new attributes, there is no need to modify the table structure and develop corresponding attribute codes, which will not affect the stability of system performance.

[0070] In a possible implementation, the method for automatically partitioning an order database provided in this embodiment partitions the first text content in the order identifier and generates the creation date of the order data according to the obtained first key field.

[0071] Specifically, obtaining the creation date of the order data based on the order identifier includes: extracting the first text content in the order identifier; segmenting the first text content according to a preset first segmentation rule to obtain a first key field corresponding to the order identifier, and the first segmentation rule is used to divide the text content into different fields; generating the creation date of the order data based on the first key field.

[0072] It's understood that the order identifier can be a string of text characters that follows certain encoding rules, such as "date + attribute + serial number," to distinguish between orders. Based on this encoding rule, a first segmentation rule can be derived to extract the text content containing the date information, thereby obtaining the creation date of the order data.

[0073] In this embodiment, by segmenting the first text content in the order identifier and generating the creation date of the order data according to the obtained first key field, the order data can be efficiently and accurately divided, thereby performing a table splitting operation.

[0074] In a possible implementation, the method for automatically partitioning an order database table provided in this embodiment generates a creation date of the historical data based on the obtained second key field by partitioning the second text content in the historical data identifier.

[0075] Specifically, obtaining the historical creation time of the historical data based on the historical data identifier includes: extracting the second text content in the historical data identifier; segmenting the second text content according to a preset second segmentation rule to obtain a second key field corresponding to the historical data identifier, and the second segmentation rule is used to divide the text content into different fields; generating the creation date of the historical data based on the second key field.

[0076] It is understood that the historical data identifier can be a string of text characters that follows certain encoding rules, such as "date + serial number," to distinguish each historical data item. Based on this encoding rule, a second segmentation rule can be derived to extract the text content containing the date information to obtain the creation date of the historical data.

[0077] In this embodiment, by segmenting the second text content in the historical data identifier and generating the creation date of the historical data according to the obtained second key field, the historical data can be efficiently and accurately divided, thereby performing a table splitting operation.

[0078] In a possible implementation, the method for automatically sharding an order database provided in this embodiment obtains a target attribute sharding table according to the creation date of the order data, and then writes the order attribute instance table into the target attribute sharding table.

[0079] Specifically, the order attribute instance table of the order data is written into the attribute sub-table corresponding to the creation date according to the preset sub-table rule, including: obtaining the target attribute sub-table corresponding to the creation date of the order data according to the sub-table rule; and writing the order attribute instance table of the order data into the target attribute sub-table.

[0080] Taking into account that the attribute sub-table is constructed according to the time interval, the target attribute sub-table for the order data creation date may not have been constructed yet. Therefore, before writing the order attribute instance table of the order data into the attribute sub-table corresponding to the creation date according to the preset sub-table rule, it also includes: judging whether a target attribute sub-table already exists for the creation date of the order data; if not, based on the time interval of the sub-table rule and the existing attribute sub-table, creating a new sub-table that does not overlap with the time interval of the existing sub-table as the target attribute sub-table.

[0081] It is understandable that a timed trigger script of a relational database can be used to create new sub-tables at preset time intervals. For example, if the table is divided by year, a sub-table such as "Attribute 1-2022", "Attribute 2-2022", etc. is created on the first day of the year; or if the table is divided by month, a sub-table such as "Attribute 1-202201", "Attribute 2-202201", etc. is created on the first day of each month.

[0082] Furthermore, depending on the added attributes, it is possible to first detect whether there is a sub-table with a corresponding time interval for the attribute. If so, no sub-table is created; otherwise, a new sub-table is created.

[0083] In this embodiment, by obtaining the target attribute sub-table according to the creation date of the order data and then writing the order attribute instance table into the target attribute sub-table, the attribute chronology table can be automatically written, making it convenient for all subsequent queries to switch to the chronology table query attribute.

[0084] In a possible implementation, considering that the existence of the general attribute table is unnecessary after all historical data have been replaced to their corresponding attribute sub-tables, in order not to waste resources, after the historical data table name in the historical data query instruction is replaced with the attribute sub-table name where the historical data is located, it also includes: determining whether there is a historical data table name that has not been replaced with the attribute sub-table name where the historical data is located; if not, deleting the general attribute table.

[0085] It is understandable that the order attribute instance table of each order data is written into the target attribute sub-table and the total attribute table at the same time, on the one hand, for the integrity of the data, and on the other hand to prevent errors, but this may cause data redundancy and waste data resources; thus, after all historical data table names are replaced with the name of the attribute sub-table where the historical data is located, that is, each sub-table is complete, and subsequent new order data can also be written directly into the corresponding sub-table, the total attribute table is no longer necessary, and the total attribute table can be deleted at this time.

[0086] In this embodiment, by detecting whether the table names of the historical data are replaced with the table names of the attribute sub-tables where the historical data are located, the general attribute table is deleted to save data resources and improve response efficiency.

[0087] It should be noted that for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that this application is not limited by the order of the actions described, because according to this application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in this specification are all optional embodiments, and the actions and modules involved are not necessarily required by this application.

[0088] It should be further noted that, although the various steps in the flowchart are shown in sequence as indicated by the arrows, these steps are not necessarily performed in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and these steps may be performed in other orders. Moreover, at least a portion of the steps in the flowchart may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily performed at the same time, but may be performed at different times. The execution order of these sub-steps or stages is not necessarily to be performed in sequence, but may be performed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.

[0089] Figure 3 This is a schematic diagram of the automatic table partitioning device for the order database provided in the embodiment of the present application. Figure 3 As shown, the automatic table partitioning device for the order database includes:

[0090] Instruction acquisition module 31, used to acquire data operation instructions, the data operation instructions include adding new order data and querying historical data, the order data includes order identification and order attribute information, and the historical data includes historical data identification;

[0091] An order attribute information conversion module 32 is configured to convert the order attribute information of the newly added order data according to a preset attribute configuration table, obtain a converted order attribute instance table, and write the order attribute instance table into a general attribute table. The attribute configuration table is used to configure attribute query information according to the order attribute information.

[0092] An order data table partitioning module 33 is configured to, while writing the order attribute instance table into the general attribute table, obtain the creation date of the order data based on the order identifier, and write the order attribute instance table of the order data into the attribute sub-table corresponding to the creation date according to a preset table partitioning rule, wherein the table partitioning rule is configured to partition the order data according to the time interval specified by the creation date of the order data;

[0093] The historical data table sub-table module 34 is used to obtain the historical creation time of the historical data based on the historical data identifier for the query historical data, write the historical data into the attribute sub-table corresponding to the historical creation date according to the preset table sub-table rules, and replace the historical data table name in the historical data query instruction with the sub-table name where the historical data is located.

[0094] In a possible design, the attribute query information includes an attribute code and an attribute name, and the order attribute information conversion module 32 is specifically configured to:

[0095] Obtaining, according to the order attribute information, the attribute code and attribute name corresponding to the order attribute information in the attribute configuration table;

[0096] The attribute code and the attribute name are added to the order data in a preset data structure to generate the order attribute instance table.

[0097] In one possible design, the order data sub-table module 33 is specifically used to:

[0098] Extracting the first text content in the order identifier;

[0099] Segmenting the first text content according to a preset first segmentation rule to obtain a first key field corresponding to the order identifier, wherein the first segmentation rule is used to divide the text content into different fields;

[0100] A creation date of the order data is generated based on the first key field.

[0101] In one possible design, the historical data table sub-module 34 is specifically used to:

[0102] Extracting the second text content in the historical data identifier;

[0103] Segmenting the second text content according to a preset second segmentation rule to obtain a second key field corresponding to the historical data identifier, wherein the second segmentation rule is used to divide the text content into different fields;

[0104] A creation date of the historical data is generated based on the second key field.

[0105] In one possible design, the order data sub-table module 33 is specifically used to:

[0106] According to the table sharding rule, obtain the target attribute sharding table corresponding to the creation date of the order data;

[0107] The order attribute instance table of the order data is written into the target attribute sub-table.

[0108] In one possible design, the order data sub-table module 33 is further specifically used to:

[0109] Determine whether a target attribute sub-table already exists for the creation date of the order data;

[0110] If not, based on the time interval of the table sub-table rule and the existing attribute sub-table, a new sub-table with a time interval that does not overlap with the existing sub-table is created as the target attribute sub-table.

[0111] In one possible design, the historical data table sub-module 34 is further specifically used for:

[0112] Determine whether there is a historical data table name that has not been replaced with the attribute sub-table name where the historical data is located;

[0113] If not, delete the general attribute table.

[0114] It should be understood that the above-described device embodiments are merely illustrative, and the device of the present application may also be implemented in other ways. For example, the division of units / modules in the above-described embodiments is merely a logical functional division, and actual implementations may employ other division methods. For example, multiple units, modules, or components may be combined or integrated into another system, or some features may be omitted or not implemented.

[0115] In addition, unless otherwise specified, the functional units / modules in the various embodiments of the present application may be integrated into a single unit / module, each unit / module may exist physically separately, or two or more units / modules may be integrated together. The aforementioned integrated units / modules may be implemented in the form of hardware or software program modules.

[0116] Figure 4 This is a schematic diagram of the structure of an electronic device based on an automatic table partitioning device for an order database according to an embodiment of the present application. Figure 4 As shown, the electronic device of this embodiment includes: at least one processor 40 ( Figure 4 Only one is shown in the figure) a processor, a memory 41, and a computer program stored in the memory 41 and executable on at least one processor 40. When the processor 40 executes the computer program, the steps in any of the above-mentioned method embodiments are implemented.

[0117] The electronic device may include, but is not limited to, a processor 40 and a memory 41. Those skilled in the art will understand that Figure 4 These are merely examples of electronic devices and do not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the electronic device may also include input and output devices, network access devices, etc.

[0118] The processor 40 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. A general-purpose processor may be a microprocessor or any conventional processor.

[0119] The specific implementation process of the processor 401 can be found in the above method embodiment. Its implementation principle and technical effects are similar and will not be repeated here in this embodiment.

[0120] In some embodiments, the memory 41 may be an internal storage unit of the electronic device, such as the memory of the electronic device. In other embodiments, the memory 41 may also be an external storage device of the electronic device, such as a plug-in hard disk equipped on the electronic device, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card, etc. Furthermore, the memory 41 may also include both an internal storage unit of the electronic device and an external storage device. The memory 41 is used to store an operating system, application programs, a boot loader (BootLoader), data, and other programs, such as the program code of a computer program. The memory 41 may also be used to temporarily store data that has been output or is about to be output.

[0121] An embodiment of the present application further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.

[0122] The computer-readable storage medium mentioned above can be implemented by any type of volatile or non-volatile memory device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk, or optical disk. The computer-readable storage medium can be any available medium that can be accessed by a general-purpose or special-purpose computer.

[0123] An exemplary readable storage medium is coupled to the processor so that the processor can read information from the readable storage medium and write information to the readable storage medium. Of course, the readable storage medium can also be an integral part of the processor. The processor and the readable storage medium can be located in an application specific integrated circuit (ASIC). Of course, the processor and the readable storage medium can also exist as discrete components in the above-mentioned electronic device.

[0124] Those skilled in the art will appreciate that all or part of the steps in the above-described method embodiments can be implemented using hardware associated with program instructions. The aforementioned program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above-described method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.

[0125] In the above embodiments, the description of each embodiment has its own emphasis. For parts not described in detail in a particular embodiment, please refer to the relevant description of other embodiments. The technical features of the above embodiments can be combined in any way. To keep the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0126] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present application that follow the general principles of the present application and include common knowledge or customary techniques in the art not disclosed herein. The description and examples are to be considered as exemplary only, and the true scope and spirit of the present application are indicated by the following claims.

[0127] It should be understood that the present application is not limited to the exact structure described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.

Claims

1. A method for automatically partitioning an order database, characterized in that: include: Obtaining data operation instructions, wherein the data operation instructions include adding new order data and querying historical data, the order data includes an order identifier and order attribute information, and the historical data includes a historical data identifier; For the newly added order data, convert the order attribute information according to a preset attribute configuration table to obtain a converted order attribute instance table, and write the order attribute instance table into a general attribute table. The attribute configuration table is used to configure attribute query information according to the order attribute information; While writing the order attribute instance table into the general attribute table, the creation date of the order data is obtained based on the order identifier, and the order attribute instance table of the order data is written into the attribute sub-table corresponding to the creation date according to a preset sub-table rule, wherein the sub-table rule is used to divide the order data according to the time interval to which the creation date of the order data belongs; For the query historical data, the creation date of the historical data is obtained based on the historical data identifier, and the historical data is written into the attribute sub-table corresponding to the creation date according to the preset sub-table rule, and the historical data table name in the query historical data instruction is replaced with the attribute sub-table name where the historical data is located.

2. The method according to claim 1, characterized in that The attribute query information includes an attribute code and an attribute name. The order attribute information is converted according to a preset attribute configuration table to obtain a converted order attribute instance table, including: Obtaining, according to the order attribute information, the attribute code and attribute name corresponding to the order attribute information in the attribute configuration table; The attribute code and the attribute name are added to the order data in a preset data structure to generate the order attribute instance table.

3. The method according to claim 1, characterized in that The obtaining the creation date of the order data based on the order identifier includes: Extracting the first text content in the order identifier; Segmenting the first text content according to a preset first segmentation rule to obtain a first key field corresponding to the order identifier, wherein the first segmentation rule is used to divide the text content into different fields; A creation date of the order data is generated based on the first key field.

4. The method according to claim 1, wherein The acquiring the creation date of the historical data based on the historical data identifier includes: Extracting the second text content in the historical data identifier; Segmenting the second text content according to a preset second segmentation rule to obtain a second key field corresponding to the historical data identifier, wherein the second segmentation rule is used to divide the text content into different fields; A creation date of the historical data is generated based on the second key field.

5. The method according to claim 1, characterized in that Writing the order attribute instance table of the order data into the attribute sub-table corresponding to the creation date according to the preset sub-table rule includes: According to the table sharding rule, obtain the target attribute sharding table corresponding to the creation date of the order data; The order attribute instance table of the order data is written into the target attribute sub-table.

6. The method according to claim 5, characterized in that Before writing the order attribute instance table of the order data into the attribute sub-table corresponding to the creation date according to the preset sub-table rule, the method further includes: Determine whether a target attribute sub-table already exists for the creation date of the order data; If not, based on the time interval of the table sub-table rule and the existing attribute sub-table, a new sub-table with a time interval that does not overlap with the existing sub-table is created as the target attribute sub-table.

7. The method according to claim 1, characterized in that After replacing the historical data table name in the historical data query instruction with the attribute sub-table name where the historical data is located, the method further includes: Determine whether there is a historical data table name that has not been replaced with the attribute sub-table name where the historical data is located; If not, delete the general attribute table.

8. An automatic table partitioning device for an order database, characterized in that: include: An instruction acquisition module is used to acquire data operation instructions, wherein the data operation instructions include adding new order data and querying historical data, the order data includes an order identifier and order attribute information, and the historical data includes a historical data identifier; An order attribute information conversion module is configured to convert the order attribute information of the newly added order data according to a preset attribute configuration table, obtain a converted order attribute instance table, and write the order attribute instance table into a general attribute table. The attribute configuration table is used to configure attribute query information according to the order attribute information. An order data table partitioning module is configured to, while writing the order attribute instance table into the general attribute table, obtain a creation date of the order data based on the order identifier, and write the order attribute instance table of the order data into an attribute sub-table corresponding to the creation date according to a preset table partitioning rule, wherein the table partitioning rule is configured to partition the order data according to the time interval to which the creation date of the order data belongs; The historical data table sub-module is used to obtain the creation date of the historical data based on the historical data identifier for the query historical data, write the historical data into the attribute sub-table corresponding to the creation date according to the preset table sub-rules, and replace the historical data table name in the historical data query instruction with the table name of the sub-table where the historical data is located.

9. An electronic device, characterized in that: include: a processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 7 when executed by a processor.

Citation Information

Patent Citations

  • Service data processing method and device, server and storage medium

    CN112634012A

  • Order query method and device, storage medium and electronic device

    CN114328520A