Model-based data fragmentation and table division method and system
Through the model-based data sharding and table sharding method, semantic SQL and model definition query objects are used to solve the performance and functional limitations of sharding and table sharding in massive data scenarios in the existing technology, and achieve efficient data retrieval and Improved response performance, suitable for complex business scenarios.
Patent Information
- Application Number
- CN202310153054.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-22
- Publication Date
- 2024-08-23
AI Technical Summary
Existing sharding and table sharding solutions have functional limitations and low performance when processing distributed transaction Improve retrieval efficiency and response performance.
Adopt a model-based data sharding and table sharding method, build a query API through semantic SQL, use the model to define query objects for sharding and table sharding, divide hot data and cold data according to business needs, and use column slicing during the sharding process. and sharded tables to optimize data storage and retrieval.
It achieves improved retrieval performance in massive data transaction process processing, reduces development difficulty and the number of lines of code, can significantly improve query efficiency and meet complex business rules, supports cross-database joint query SQL syntax, and improves the system's response performance.
Smart Images

Figure CN118535567A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of database technology, and in particular to a model-based data sharding and table sharding method and system, and more particularly to a sharding and table sharding design method for a production data flow scenario of a manufacturing enterprise. Background Art
[0002] Sharding and table partitioning of data is a solution to the performance problems caused by large amounts of data. The mainstream sharding and table partitioning solutions on the market, such as Shardingshpere, Mycat, and partitiontable of various commercial databases, are all aimed at transparent application use, and improve overall performance by configuring strategies at the database level, optimizing retrieval, and achieving parallel query as much as possible.
[0003] The existing sharding and table sharding technology has great limitations in actual use, especially in distributed transaction XA and cross-shard merge query. These limitations include:
[0004] Functional limitations: does not support specific scenario functions, and does not support cross-database query SQL syntax;
[0005] Poor performance: It requires a large amount of data memory calculation, and the retrieval efficiency and speed are very slow.
[0006] In order to solve these problems, and at the same time be able to be effectively applied in specific application scenarios, and to improve the response performance of specific businesses through sharding and table sharding technology, a new sharding and table sharding solution is needed to solve specific scenario problems.
[0007] A company's marketing system stores all sales order data and logistics transportation data, including number, type, transportation method, splitting and bundling information, and specific sales process data, including agency companies, split orders, and other massive data information. This data information is not only used for big data analysis, but also needs to be processed for transaction processes. In the process scenario, there are very high requirements for data sorting, deduplication, avoiding double spending, and maintaining consistency. It is impossible to optimize data through simple sharding and table sharding.
[0008] Patent document CN102254352B (application number: 201110191528.8) discloses a quadrilateral mesh generation method based on model slicing and splicing. It includes the following steps: 1) inputting a mesh model; 2) slicing the model into sub-models according to the user's requirements for the target quadrilateral mesh; analyzing and comparing the sub-models to find the target sub-model with semantic information; 3) generating direction fields and density fields on all sub-models according to the user's requirements for the target quadrilateral mesh and the semantic information of each target sub-model; 4) establishing an energy equation and obtaining an optimized density field and boundary subdivision degrees of freedom according to the semantic information of each target sub-model and the generated direction field and density field; 5) using the obtained optimized density field and boundary subdivision degrees of freedom, independently quadrilateral meshing each sub-model, and then splicing them together to form the target quadrilateral mesh. This patent only provides a model-based slicing idea, splitting the mesh model into sub-models, analyzing and comparing the sub-models, and finding the target sub-model with semantic information. At the same time, this study only targets the model sharding scenario of images, and is not applicable to the data sharding of transactional databases in massive data scenarios. Therefore, it cannot solve the problem of data sharding and table sharding. Summary of the invention
[0009] In view of the defects in the prior art, the object of the present invention is to provide a model-based data sharding and table subdivision method and system.
[0010] A data sharding and table partitioning method based on a model provided by the present invention includes:
[0011] Step S1: Use semantic SQL to build a query API;
[0012] Step S2: using the model to define the query object to obtain the query object model;
[0013] Step S3: using the query object model to retrieve application data through the query API for sharding and table division;
[0014] The query object model obtains query objects based on annotations.
[0015] Preferably, the step S1 adopts: writing SQL according to the language rules of Java, and using semantic SQL to build a query API;
[0016] The query API includes: .select, .from, .join, and .where.
[0017] Preferably, in the process of sharding and table partitioning, application data is divided into hot data and cold data according to actual preset business needs and usage frequency; the hot data is saved in the real-time table; and the cold data is saved in the historical table.
[0018] Preferably, the query object model includes: @XModel annotation, @CombineModel annotation and @ShardingModel annotation;
[0019] The @XModel annotation includes: defining the table name, defining the table space schema, and defining the data source database;
[0020] The @CombineModel annotation includes: defining the sub-table name, defining the table space schema, and defining the data source database;
[0021] The @ShardingModel annotation includes: history table name history, sharding mode type and sharding rule rule.
[0022] Preferably, the step S3 adopts:
[0023] When the number of columns is greater than the preset value, the columns are split to form multiple sub-columns.
[0024] When the number of table rows is greater than the preset value, a shard table is used to form multiple data shards.
[0025] A data sharding and table subdivision system based on a model is provided according to the present invention, comprising:
[0026] Module M1: Use semantic SQL to build query API;
[0027] Module M2: Obtain query object model using model definition query object;
[0028] Module M3: Use the query object model to retrieve application data through the query API for sharding and table division;
[0029] The query object model obtains query objects based on annotations.
[0030] Preferably, the module M1 adopts: writing SQL according to the language rules of Java, and using semantic SQL to build a query API;
[0031] The query API includes: .select, .from, .join, and .where.
[0032] Preferably, in the process of sharding and table partitioning, application data is divided into hot data and cold data according to actual preset business needs and usage frequency; the hot data is saved in the real-time table; and the cold data is saved in the historical table.
[0033] Preferably, the query object model includes: @XModel annotation, @CombineModel annotation and @ShardingModel annotation;
[0034] The @XModel annotation includes: defining the table name, defining the table space schema, and defining the data source database;
[0035] The @CombineModel annotation includes: defining the sub-table name, defining the table space schema, and defining the data source database;
[0036] The @ShardingModel annotation includes: history table name history, sharding mode type and sharding rule rule.
[0037] Preferably, the module M3 adopts:
[0038] When the number of columns is greater than the preset value, the columns are split to form multiple sub-columns.
[0039] When the number of table rows is greater than the preset value, a shard table is used to form multiple data shards.
[0040] Compared with the prior art, the present invention has the following beneficial effects:
[0041] 1. The present invention implements a sharding and table-splitting solution combined with business scenarios to solve the performance problem of massive data transaction process processing;
[0042] 2. The present invention can significantly improve the retrieval performance while reducing the number of lines of development code;
[0043] 3. The development difficulty and number of lines of code based on the present invention are significantly reduced. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] Other features, objects and advantages of the present invention will become more apparent from the detailed description of non-limiting embodiments made with reference to the following drawings:
[0045] Figure 1 This is a schematic diagram of the model-based data sharding and table partitioning system. DETAILED DESCRIPTION
[0046] The present invention is described in detail below in conjunction with specific embodiments. The following embodiments will help those skilled in the art to further understand the present invention, but are not intended to limit the present invention in any form. It should be noted that, for those of ordinary skill in the art, several changes and improvements can also be made without departing from the concept of the present invention. These all belong to the protection scope of the present invention.
[0047] Example 1
[0048] A data sharding and table partitioning method based on a model provided by the present invention includes:
[0049] Step S1: Use semantic SQL to build a query API;
[0050] Step S2: using the model to define the query object to obtain the query object model;
[0051] Step S3: using the query object model to retrieve application data through the query API for sharding and table division;
[0052] The query object model obtains query objects based on annotations.
[0053] Specifically, the step S1 adopts: writing SQL according to the language rules of Java, and using semantic SQL to build a query API;
[0054] The query API includes: .select, .from, .join, and .where.
[0055] Specifically, in the process of sharding and table partitioning, application data is divided into hot data and cold data according to actual business needs and usage frequency of preset services; the hot data is saved in the real-time table; and the cold data is saved in the historical table.
[0056] Specifically, the query object model includes: @XModel annotation, @CombineModel annotation and @ShardingModel annotation;
[0057] The @XModel annotation includes: defining the table name, defining the table space schema, and defining the data source database;
[0058] The @CombineModel annotation includes: defining the sub-table name, defining the table space schema, and defining the data source database;
[0059] The @ShardingModel annotation includes: history table name history, sharding mode type and sharding rule rule.
[0060] Specifically, the step S3 adopts:
[0061] When the number of columns is greater than the preset value, the columns are split to form multiple sub-columns.
[0062] When the number of table rows is greater than the preset value, a shard table is used to form multiple data shards.
[0063] A data sharding and table subdivision system based on a model is provided according to the present invention, comprising:
[0064] Module M1: Use semantic SQL to build query API;
[0065] Module M2: Obtain query object model using model definition query object;
[0066] Module M3: Use the query object model to retrieve application data through the query API for sharding and table division;
[0067] The query object model obtains query objects based on annotations.
[0068] Specifically, the module M1 adopts: writing SQL according to the language rules of Java, and using semantic SQL to build a query API;
[0069] The query API includes: .select, .from, .join, and .where.
[0070] Specifically, in the process of sharding and table partitioning, application data is divided into hot data and cold data according to actual business needs and usage frequency of preset services; the hot data is saved in the real-time table; and the cold data is saved in the historical table.
[0071] Specifically, the query object model includes: @XModel annotation, @CombineModel annotation and @ShardingModel annotation;
[0072] The @XModel annotation includes: defining the table name, defining the table space schema, and defining the data source database;
[0073] The @CombineModel annotation includes: defining the sub-table name, defining the table space schema, and defining the data source database;
[0074] The @ShardingModel annotation includes: history table name history, sharding mode type and sharding rule rule.
[0075] Specifically, the module M3 adopts:
[0076] When the number of columns is greater than the preset value, the columns are split to form multiple sub-columns.
[0077] When the number of table rows is greater than the preset value, a shard table is used to form multiple data shards.
[0078] Example 2
[0079] Embodiment 2 is a preferred embodiment of Embodiment 1
[0080] The present invention provides a sharding and table sharding method for a production data flow scenario of a manufacturing enterprise. Different from the existing technical methods, it adopts a model-based design concept to obtain data sharding metadata. Different from the current database sharding and table sharding that adopts a transparent query design concept, this process has better query performance.
[0081] The sharding and table-splitting method for the production data flow scenario of the manufacturing enterprise is as follows: Figure 1 As shown, including:
[0082] Step 1: Use semantic SQL to build a query API.
[0083] Step 2: Define the query object using the model,
[0084] Step 3: Retrieve sub-table data,
[0085] Step 4: Retrieve shard data.
[0086] The step 1 adopts:
[0087] Semantic SQL query building API: Provides a set of SQL semantic APIs, including .select, .from, .join, .where, etc., which can completely write SQL according to Java language rules.
[0088] For details, please refer to Table 1.
[0089]
[0090] The step 2 adopts: providing a set of model definition APIs, which can define the metadata information of sharding and table division on the model, isolating the complexity in the actual use process. In the process of sharding and table division, the application data is divided into hot data (real-time table) and cold data (historical table) according to the actual business needs and the frequency of use. In this way, most of the queries in the scene can retrieve a real-time table with a controllable order of magnitude, and the expired data that is no longer frequently used can be moved to the historical table.
[0091] The defined model includes @XModel annotation, including name (table name), schema (tablespace), and database (data source). And @CombineModel annotation, including name (table name), schema (tablespace), and database (data source) of the sharding table. And @ShardingModel annotation, mainly including history (historical table name), type (sharding mode, the default is the real-time table / historical table mode, and it also supports multi-sharding mode), and rule (sharding rule, for the scenario of data segmentation, the sharding rule is used to determine the shard location of the data).
[0092] The step 3 adopts:
[0093] Retrieve data from a separate table: For tables with a large number of columns, split the columns to form multiple separate tables. In this process, this component provides a calculation formula for the space occupied by a column and a table with a suitable range. Provides a definition method for the separate column model through the @Model and @CombineModel annotations. The @CombineModel annotation defines the definition information of the table after the separate columns, including the table name, the table space where the table is located, and the data source where the table is located.
[0094] Retrieve sharded data: For tables with a large number of rows, shard tables are used to form multiple data shards. In this process, the @ShardingModel annotation is provided, where the @ShardingModel annotation defines the sharding mode, such as sharding by current table / historical table, or sharding by key fields such as company, account set, regional company, etc.
[0095] The present invention completely completes the functional components required for sharding a large table, and provides a usage API for scenarios including adding, deleting, modifying, and querying. It also adopts a sharding method that fits the specific design of the business. Different from the mainstream transparent sharding design concept currently on the market, the sharding method that fits the business emphasizes the use effect of the business. In order to maximize the satisfaction of business needs, while greatly improving the retrieval performance through sharding and sharding, this example provides business-specific definition methods on the sharding and sharding API. This definition of sharding and sharding rules can support quite complex business rule definitions, for example:
[0096] A scenario: The completion status of the work order is equal to 40; and the data has been discarded. The data table to be discarded is used to determine whether the data has been discarded. If the data has a completion time greater than 3 months, it will be entered into the history table.
[0097] The definition rules in this scenario cannot be supported by the current open source software on the market, including ShardingSpere, Mycat, or commercial sharding software (DB2 partition table) provided by manufacturers.
[0098] Example 3
[0099] Embodiment 3 is a preferred embodiment of Embodiment 1 and / or Embodiment 2.
[0100] A marketing system has 14 business scenarios, and the data volume of a single table is greater than 4 GB. For real-time process business scenarios, such an order of magnitude will bring performance pressure. In order to achieve the performance goals of page jump time <= 3s and accurate search feedback time <= 1s, sharding and table splitting measures are needed to reduce the data volume of a single table and improve retrieval efficiency.
[0101] The specific process of sharding and table partitioning is as follows:
[0102] According to the large table performance evaluation method, evaluate the data volume of the current business system table, divide the table with storage space greater than 4 GB, and evaluate the archiving cycle according to the data increment.
[0103] According to the archiving cycle, formulate an effective archiving strategy, which needs to ensure that a large number of business scenarios can be completed in the real-time table.
[0104] Write the model according to the real-time table, historical table, and archiving strategy, and clearly define the real-time table and historical table names in the model definition. Write the sharding rules according to the archiving strategy.
[0105] Develop specific business query logic and data storage logic based on the model's SQL semantic API.
[0106] After actual project verification, the present invention can significantly improve the retrieval performance while reducing the number of development code lines:
[0107] On the SODS11 order management page of a marketing system, it takes about 10 minutes to query the result data using the sales product L0 as the query condition. After investigation, it was found that the TSOSOA1 contract table has 237 fields and 580,000 data items; the TSOSOA4 contract sub-item table has 495 fields and more than 5.5 million data items. The number of columns in the table is large, and the sorting speed after query retrieval is very slow. By adopting the model-based sub-table query method of the present invention, the query time for the same result is reduced to within 3 seconds;
[0108] The UC_LI_MATERIAL material table has about 38.39 million data; the XSSO.TSOSOA4 contract system order table has 5.51 million data; in the scenario of associated query, the performance of specific conditions is very low. For example, when a relatively large account set is used as a condition: FIN_USER_NUM = '899999', the performance will drop sharply, and the actual query time is more than 28 minutes. By adopting the model-based sharding method of the present invention, the query time for the same result is finally reduced to within 3 seconds.
[0109] And in this improvement process, the development difficulty and the number of lines of code have decreased significantly, as shown in the following table:
[0110]
[0111] Those skilled in the art know that, in addition to implementing the system, device and its various modules provided by the present invention in a purely computer-readable program code, it is entirely possible to implement the same program in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers and embedded microcontrollers by logically programming the method steps. Therefore, the system, device and its various modules provided by the present invention can be considered as a hardware component, and the modules included therein for implementing various programs can also be considered as structures within the hardware component; the modules for implementing various functions can also be considered as both software programs for implementing the method and structures within the hardware component.
[0112] The above describes the specific embodiments of the present invention. It should be understood that the present invention is not limited to the above specific embodiments, and those skilled in the art can make various changes or modifications within the scope of the claims, which does not affect the essence of the present invention. In the absence of conflict, the embodiments of the present application and the features in the embodiments can be combined with each other arbitrarily.
Claims
1. A data sharding and table partitioning method based on a model, characterized in that: include: Step S1: Use semantic SQL to build a query API; Step S2: using the model to define the query object to obtain the query object model; Step S3: using the query object model to retrieve application data through the query API for sharding and table division; The query object model obtains query objects based on annotations.
2. The data sharding and table partitioning method based on the model according to claim 1 is characterized in that: The step S1 adopts: writing SQL according to the language rules of Java, and using semantic SQL to build a query API; The query API includes: .select, .from, .join, and .where.
3. The data sharding and table partitioning method based on the model according to claim 1 is characterized in that: In the process of sharding and table partitioning, application data is divided into hot data and cold data according to the actual needs of the preset business and the frequency of use; the hot data is saved in the real-time table; and the cold data is saved in the historical table.
4. The data sharding and table partitioning method based on the model according to claim 1 is characterized in that: The query object model includes: @XModel annotation, @CombineModel annotation and @ShardingModel annotation; The @XModel annotation includes: defining the table name, defining the table space schema, and defining the data source database; The @CombineModel annotation includes: defining the sub-table name, defining the table space schema, and defining the data source database; The @ShardingModel annotation includes: history table name history, sharding mode type and sharding rule rule.
5. The data sharding and table partitioning method based on the model according to claim 1 is characterized in that: The step S3 adopts: When the number of columns is greater than the preset value, the columns are split to form multiple sub-columns. When the number of table rows is greater than the preset value, a shard table is used to form multiple data shards.
6. A data sharding and table partitioning system based on a model, characterized in that: include: Module M1: Use semantic SQL to build query API; Module M2: Obtain query object model using model definition query object; Module M3: Use the query object model to retrieve application data through the query API for sharding and table division; The query object model obtains query objects based on annotations.
7. The model-based data sharding and table-splitting system according to claim 6, characterized in that: The module M1 adopts: writing SQL according to the language rules of Java and using semantic SQL to build a query API; The query API includes: .select, .from, .join, and .where.
8. The model-based data sharding and table splitting system according to claim 6, characterized in that: In the process of sharding and table partitioning, application data is divided into hot data and cold data according to the actual needs of the preset business and the frequency of use; the hot data is saved in the real-time table; and the cold data is saved in the historical table.
9. The model-based data sharding and table-splitting system according to claim 6, characterized in that: The query object model includes: @XModel annotation, @CombineModel annotation and @ShardingModel annotation; The @XModel annotation includes: defining the table name, defining the table space schema, and defining the data source database; The @CombineModel annotation includes: defining the sub-table name, defining the table space schema, and defining the data source database; The @ShardingModel annotation includes: history table name history, sharding mode type and sharding rule rule.
10. The model-based data sharding and table-splitting system according to claim 6, characterized in that: The module M3 adopts: When the number of columns is greater than the preset value, the columns are split to form multiple sub-columns. When the number of table rows is greater than the preset value, a shard table is used to form multiple data shards.
Citation Information
Patent Citations
Query method for ECP platform data access through Filter model and annotation extension
CN106933564A
API application method and system of BI system based on structured query language
CN112286957A
Multi-data-source data query method and system
CN112818001A
An API interface generation method and device, an API interface calling method and device and electronic equipment
CN113448985A
Data processing method and device
CN114064690A
