Order system data fragmentation method and system

By using modulus operation in the order system to generate shard index values ​​and splicing them to the end of the order number, the problem of low data shard positioning efficiency in the order system is solved, and the ability to quickly read order information is realized.

CN118939652AInactive Publication Date: 2024-11-12FUJIAN TQ ONLINE INTERACTIVE INC
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410964360.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-18
Publication Date
2024-11-12
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

In the order system, the rapid growth of data volume leads to limited capacity of single tables, degraded query performance, and inefficient in finding user order lists, making it impossible to quickly locate data shards.

Method used

Generate the shard index value by using the user ID to perform modulo operation when creating an order, and convert it into an X-bit string and splicing it at the end of the order number and deposit it into the corresponding database; when reading, cut the shard from the end of the order number, and then convert it into an X-bit string. Index value, determine the target database, and achieve rapid positioning of order data.

Benefits of technology

It realizes the ability to quickly read and process order information, simplifies the query process of order data, and improves efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118939652A_ABST
    Figure CN118939652A_ABST
Patent Text Reader

Abstract

The invention relates to an order system data fragmentation method and system, and the method comprises the steps: carrying out the modulo operation of the fragmentation number N through employing a user ID when an order is created, obtaining a fragmentation index value, converting the fragmentation index value into an X-bit character string form, if the number is less than X bits, supplementing 0, and if the number is less than X bits, carrying out the fragmentation operation; the generated X-bit fragment index value character string is spliced to the tail of the order number, and finally the order data is stored in a database corresponding to the fragment index value; when order data is read, an X-bit character string is intercepted from the tail of an order number and converted into a number to obtain a fragment index value, a target database is determined through the fragment index value, corresponding order data is read from a corresponding database, or modulo operation is performed on the fragment number N by using a user ID to directly obtain the fragment index value. And accessing the corresponding database through the fragment index value to obtain the order data related to the user, so that the order information can be quickly read and processed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of order query, and in particular to a method and system for data sharding of an order system. Background Art

[0002] When the order system faces a rapid increase in data volume, the capacity limitation of a single table becomes a significant problem. In this case, a single table may not be able to carry large amounts of data, resulting in poor query performance, slower write speeds, and even longer system response times. To address these challenges, data sharding by order number becomes an effective solution, which horizontally splits the data and stores it in multiple database tables. Each shard node is only responsible for the read and write operations of part of the data, thereby reducing the pressure on the single table.

[0003] However, although this method solves the problem of data sharding storage of orders, it will encounter difficulties when searching for a user's order list, because the system does not know in which data shard the user's order is created. It can only traverse all order shards to search, which will result in extremely low efficiency. Summary of the invention

[0004] In order to overcome the problem of low query efficiency after order data is fragmented and stored in the prior art, the purpose of the present invention is to provide a method and system for data fragmentation of an order system, which can quickly read and process order information.

[0005] The present invention is implemented by the following scheme:

[0006] A method for sharding order system data, the method steps are as follows:

[0007] Step 1: When creating an order, first use the user ID to perform a modulo operation on the number of shards N to obtain a shard index value, then convert the shard index value into an X-digit string. If it is less than X digits, add 0 in front. The generated X-digit shard index value string will be concatenated to the end of the order number, and finally store the order data in the database corresponding to the shard index value;

[0008] Step 2: When order data needs to be read according to the order number, first extract the X-digit string from the end of the order number and convert it into a number to obtain the shard index value. The target database is determined by the shard index value, and the corresponding order data is read from the corresponding database.

[0009] Step 3: If you need to read order data based on the user ID, use the user ID to perform a modulo operation on the number of shards N to directly obtain the shard index value. Use the shard index value to access the corresponding database and obtain the order data related to the user.

[0010] Furthermore, when it is necessary to read order data according to the user ID, the user checks his or her order record on the order page and reads the order data according to the user ID.

[0011] Furthermore, the conversion to a number to obtain a shard index value is specifically as follows: starting from the leftmost side of the intercepted X-bit string, each character is traversed one by one, and those that are 0 are removed until a non-zero character appears, and the remaining characters are converted using a string-to-integer library, and finally the number obtained is the shard index value.

[0012] A system for data sharding of an order system, the system comprising: a data processing module, an order number reading module and a user ID reading module;

[0013] When the data processing module is used to create an order, it first uses the user ID to perform a modulo operation on the number of shards N to obtain a shard index value, and then converts the shard index value into an X-bit string. If it is less than X bits, 0 is added in front. The generated X-bit shard index value string will be spliced ​​to the end of the order number, and finally the order data is stored in the database corresponding to the shard index value;

[0014] The order number reading module is used to first extract an X-digit string from the end of the order number and convert it into a number to obtain a shard index value when it is necessary to read order data according to the order number, determine the target database through the shard index value, and read the corresponding order data from the corresponding database;

[0015] The user ID reading module is used to perform a modulo operation on the number of shards N using the user ID if order data needs to be read according to the user ID, directly obtain a shard index value, and then access the corresponding database through the shard index value to obtain order data related to the user.

[0016] Furthermore, in the user ID reading module, when it is necessary to read order data according to the user ID, the user checks his or her order record on the order page and reads the order data according to the user ID.

[0017] Furthermore, the order number reading module converts it into a number to obtain the shard index value as follows: start from the leftmost side of the truncated X-bit string and traverse each character one by one, remove the 0 characters, and stop when a non-zero character appears. The remaining characters are converted using a string-to-integer library, and finally the number obtained is the shard index value.

[0018] The beneficial effects of the present invention are:

[0019] The present invention provides a method and system for sharding order system data. Through the design of order number and user ID, the database to which an order belongs can be determined simply and efficiently, and the database storing the order data can be quickly and accurately located through the sharding index value at the end of the order number, thereby realizing the ability to quickly read and process order information. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] Figure 1 is a flow chart of the method of the present invention;

[0021] Figure 2 It is a structural block diagram of the system of the present invention. DETAILED DESCRIPTION

[0022] The present invention will be further described below in conjunction with the accompanying drawings.

[0023] See also Figure 1 , a method for data sharding of an order system, the method steps are as follows:

[0024] Step 1: When creating an order, first use the user ID to perform a modulo operation on the number of shards N to obtain a shard index value, then convert the shard index value into an X-digit string. If it is less than X digits, add 0 in front. The generated X-digit shard index value string will be concatenated to the end of the order number, and finally store the order data in the database corresponding to the shard index value;

[0025] Step 2: When order data needs to be read according to the order number, first extract the X-digit string from the end of the order number and convert it into a number to obtain the shard index value. The target database is determined by the shard index value, and the corresponding order data is read from the corresponding database.

[0026] Step 3: If you need to read order data based on the user ID, use the user ID to perform a modulo operation on the number of shards N to directly obtain the shard index value. Use the shard index value to access the corresponding database and obtain the order data related to the user.

[0027] The present invention will be further described below in conjunction with a specific embodiment:

[0028] A method for sharding order system data, the method comprising the following steps:

[0029] Step 1. In a preferred embodiment of the present invention, X is 2. When creating an order, the user ID is first used to perform a modulo operation on the number of shards N to obtain a shard index value. The shard index value is then converted into a 2-bit string. If it is less than 2 digits, 0 is added in front. The generated 2-bit shard index value string is concatenated to the end of the order number and becomes part of the order number. Finally, the order data is stored in the database corresponding to the shard index value.

[0030] Assume that a user with user ID 889880 places an order in the mall system. The system first uses user ID 889880 to perform a modulo operation on the number of shards N. Assuming N is 12, the shard index value is equal to 889880%12=8. Then the shard index value 8 is converted into a 2-bit string. If it is less than 2 bits, 0 is added to get "08". The timestamp 1719139840191 is used as the order number, and the shard index value "08" is spliced ​​at the end of the order number to become a part of the order number, resulting in 171913984019108. Finally, the data with order number 171913984019108 is stored in the DB_8 database.

[0031] Step 2: When the order data needs to be read according to the order number, the system first extracts a 2-digit string from the end of the order number and converts it into a number, that is, it iterates through each character one by one from the leftmost side of the extracted 2-digit string, removes 0 characters, and stops when a non-0 character appears. The remaining characters are converted using the string-to-integer library to obtain the shard index value. Through this shard index value, the target database can be determined, and then the order data can be read from the corresponding database.

[0032] When the system needs to read order data based on the order number, it first extracts the 2-digit string "08" from the end of the order number 171913984019108, and converts it into a number to get 8, that is, the shard index value = 8. Through this shard index value, it can be determined that the target database is DB_8, and then the database is linked to read the data of the order. Step 3: If the order data needs to be read based on the user ID, the user ID is used to perform a modulo operation on the number of shards N to directly obtain the shard index value; then, the corresponding database is accessed through the shard index value to obtain the order data related to the user.

[0033] When a user with user ID 889880 views his order record on the My Orders page, the system needs to read the order data based on the user ID. The system uses the user ID 889880 to perform a modulo operation on the shard quantity 12, that is, 889880%12 to obtain a shard index value = 8. Through this shard index value, it can be determined that the target database is DB_8, and then this database is linked to read the user's order data.

[0034] See also Figure 2 , a system for data sharding of an order system, the system comprising: a data processing module, an order number reading module and a user ID reading module;

[0035] When the data processing module is used to create an order, it first uses the user ID to perform a modulo operation on the number of shards N to obtain a shard index value, and then converts the shard index value into an X-bit string. If it is less than X bits, 0 is added in front. The generated X-bit shard index value string will be spliced ​​to the end of the order number, and finally the order data is stored in the database corresponding to the shard index value;

[0036] The order number reading module is used to first extract an X-digit string from the end of the order number and convert it into a number to obtain a shard index value when it is necessary to read order data according to the order number, determine the target database through the shard index value, and read the corresponding order data from the corresponding database;

[0037] The user ID reading module is used to perform a modulo operation on the number of shards N using the user ID if order data needs to be read according to the user ID, directly obtain a shard index value, and then access the corresponding database through the shard index value to obtain order data related to the user.

[0038] In one embodiment of the present invention, in the user ID reading module, when it is necessary to read order data according to the user ID, the user checks his or her order record on the order page and reads the order data according to the user ID.

[0039] In one embodiment of the present invention, the order number reading module converts it into a number to obtain a shard index value as follows: starting from the leftmost side of the intercepted X-bit string, each character is traversed one by one, and those that are 0 are removed until a non-zero character appears, and the remaining characters are converted using a string-to-integer library, and finally the number obtained is the shard index value.

[0040] In a preferred embodiment of the present invention, X in the data processing module is 2, but not limited thereto, X can take other values, allowing customization of any number of bits.

[0041] In summary, the present invention provides a method and system for sharding order system data. Through the design of order number and user ID, the database to which the order belongs can be determined simply and efficiently, and the database storing the order data can be quickly and accurately located through the shard index value at the end of the order number, thereby realizing the ability to quickly read and process order information.

[0042] The above description is only a preferred embodiment of the present invention. All equivalent changes and modifications made according to the scope of the patent application of the present invention should fall within the scope of the present invention.

Claims

1. A method for sharding order system data. It is characterized in that The method steps are as follows: Step 1: When creating an order, first use the user ID to perform a modulo operation on the number of shards N to obtain a shard index value, then convert the shard index value into an X-digit string. If it is less than X digits, add 0 in front. The generated X-digit shard index value string will be concatenated to the end of the order number, and finally store the order data in the database corresponding to the shard index value; Step 2: When order data needs to be read according to the order number, first extract the X-digit string from the end of the order number and convert it into a number to obtain the shard index value. The target database is determined by the shard index value, and the corresponding order data is read from the corresponding database. Step 3: If you need to read order data based on the user ID, use the user ID to perform a modulo operation on the number of shards N to directly obtain the shard index value. Use the shard index value to access the corresponding database and obtain the order data related to the user.

2. A method for sharding order system data according to claim 1, It is characterized in that In step 3, when the order data needs to be read according to the user ID, the user checks his or her order record on the order page and reads the order data according to the user ID.

3. According to claim 1, a method for data sharding of an order system, It is characterized in that The conversion to a number to obtain a shard index value is specifically as follows: each character is traversed one by one from the leftmost side of the intercepted X-bit string, and those that are 0 are removed until a non-zero character appears, and the remaining characters are converted using a string-to-integer library, and finally the number obtained is the shard index value.

4. A system for sharding order system data. It is characterized in that The system includes: a data processing module, an order number reading module and a user ID reading module; When the data processing module is used to create an order, it first uses the user ID to perform a modulo operation on the number of shards N. Thus, a shard index value is obtained, and then the shard index value is converted into an X-bit string. If it is less than X bits, 0 is added in front. The generated X-bit shard index value string will be concatenated to the end of the order number. Finally, the order data is stored in the database corresponding to the shard index value. The order number reading module is used to first extract an X-digit string from the end of the order number and convert it into a number to obtain a shard index value when it is necessary to read order data according to the order number, determine the target database through the shard index value, and read the corresponding order data from the corresponding database; The user ID reading module is used to perform a modulo operation on the number of shards N using the user ID if order data needs to be read according to the user ID, directly obtain a shard index value, and then access the corresponding database through the shard index value to obtain order data related to the user.

5. A system for sharding order system data according to claim 4, It is characterized in that In the user ID reading module, when it is necessary to read order data according to the user ID, the user checks his or her order record on the order page and reads the order data according to the user ID.

6. A system for sharding order system data according to claim 4, It is characterized in that In the order number reading module, the conversion of the number into a number to obtain the shard index value is as follows: starting from the leftmost side of the intercepted X-bit string, each character is traversed one by one, and those that are 0 are removed until a non-zero character appears, and the remaining characters are converted using a string-to-integer library, and finally the number obtained is the shard index value.

Citation Information

Patent Citations

  • Order data processing method and device, computer equipment and storage medium

    CN115115433A

  • Phrase Indexing

    US20210034649A1