A solution to quickly provide massive data query services

By creating TTL tables in the massive data query system and performing data deduplication processing, ClickHouse solves the real-time and efficiency problems when data is updated, achieves millisecond-level response and real-time data query, and ensures the accuracy and efficiency of data updates. .

CN112632068BActive Publication Date: 2024-09-13SHENZHEN YINSHENG E-PAY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202011529950.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-12-22
Publication Date
2024-09-13
Estimated Expiration
2040-12-22

AI Technical Summary

Technical Problem

Existing massive data query systems have real-time and efficiency issues when updating data. In particular, ClickHouse cannot achieve low latency when data is frequently modified or deleted, and may lead to redundant data during queries.

Method used

By creating a TTL table, adding identification fields for data deduplication and updating, and triggering synchronization operations when the set time or the number of data reaches a certain amount, the updated and deleted data are converted into insert data and inserted into ClickHouse, and views are created to filter deletions. Record and delete expired data regularly based on version number.

Benefits of technology

It realizes millisecond-level response to query requests, can query updated data in real time, solves the problem of redundant data before the update is triggered, and ensures that deleted data can still be found after deletion.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112632068B
    Figure CN112632068B
Patent Text Reader

Abstract

The present invention discloses a solution for quickly providing massive data query services, and relates to the technical field of data query; the method comprises the following steps: S1, creating a TTL table; S2, adding an identification field for data deduplication update in the TTL table; S3, triggering a synchronous data addition operation when a set time interval or the number of data items reaches a set number; S4, converting updated and deleted data into insert data, and inserting it into ClickHouse; S5, creating a corresponding view, selecting the field with the largest version number as the display field, and filtering out deleted records; S6, modifying the length of time the TTL table retains data according to business needs, and regularly deleting expired data according to the version number; the beneficial effects of the present invention are: updated data can be queried in real time, and required data can be returned according to needs, solving the problem of multiple redundant data appearing before the update is triggered.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data query, and more specifically, to a solution for rapidly providing mass data query services. Background Art

[0002] The rapid development of business has led to a rapid increase in data volume, which has gradually become a bottleneck in providing service efficiency. For a relational database with tens of millions of tables, it is basically impossible to display data in seconds.

[0003] Currently, Hbase, ElasticSearch, Druid, Tidb, Mongodb, and ClickHouse are the most common storage platforms for massive data. Among them:

[0004] (1) HBase: Column-based storage imposes significant limitations on data reading. The real-time performance of queries is generally poor, and all queries must rely on keys. HBase is not suitable for application scenarios with complex data structures and that require complex queries.

[0005] (2) ElasticSearch: Field types cannot be modified, writing performance is low, and high-performance resource consumption. If elasticSearch is used for searching, the format may need to be modified. When performing aggregation, ES cannot be 100% accurate because it uses an approximate algorithm.

[0006] (3) Druid: does not support data updates; currently deduplication is not accurate and does not support association operations.

[0007] (4) Tidb: It has very high requirements for the hardware of the production environment and requires SSD solid-state drives. It also has very high requirements for the use of CPU, memory, and network.

[0008] (5) Mongodb: The data is isolated from the CDH cluster, which may lead to data silos as the business grows. The split migration of blocks will affect the system performance when the data volume is large.

[0009] (6) ClickHouse: Lacks the ability to modify or delete existing data at a high frequency and with low latency; can only be used to delete or modify data in batches.

[0010] ClickHouse has outstanding advantages in high-throughput writing, disk storage, high compression ratio, multi-core parallel processing, fast response to query requests, and support for complex data types. ClickHouse is chosen as the data storage to provide data query services.

[0011] However, there are still some problems: the lack of high-frequency, low-latency modification or deletion of existing data. Although the MergeTree series of table engines supports data updates, the update is triggered only when the partitions are merged. It can only guarantee eventual consistency. Before the partitions are merged, a lot of redundant data may be queried. Summary of the invention

[0012] In order to overcome the deficiencies of the prior art, the present invention provides a solution for quickly providing massive data query services, which can query updated data in real time and return required data as required, solving the problem of multiple redundant data appearing before the update is triggered.

[0013] The technical solution adopted by the present invention to solve the technical problem is: a solution for quickly providing mass data query services, and the improvement thereof is that the method comprises the following steps:

[0014] S1. Create a TTL table;

[0015] S2. Add an identification field for data deduplication update in the TTL table;

[0016] S3: When the set interval time or the number of data items reaches the set number, the synchronous data addition operation is triggered;

[0017] S4. Convert updated and deleted data into insert data and insert it into ClickHouse.

[0018] S5. Create a corresponding view, select the field with the largest version number as the display field, and filter out deleted records;

[0019] S6. Modify the length of time the TTL table retains data according to business needs, and delete expired data regularly based on the version number.

[0020] Furthermore, in step S1, a TTL table of the ReplacingMergeTree engine is created according to business requirements.

[0021] Furthermore, in step S2, the primary key is used as the identification field.

[0022] Furthermore, in step S2, in each set of data, the row with the largest version number field create_time identifies the latest data, and the default value of the version number field create_time is the insertion time of the data.

[0023] Furthermore, in step S2, a custom deletion flag bit deleteflag is set, 0 represents undeleted data, and 1 represents deleted data.

[0024] Further, in step S4,

[0025] When updating data, a new row of data is inserted, and the version number field create_time is the latest insertion time of the system. The modified field value is obtained by querying the largest version number field create_time;

[0026] When deleting data, a new row of data is inserted into the data, and the version number field create_time is the latest insertion time of the system. The deleteeflag is changed to 1, and the rest are 0. The deleted data can be divided by querying the deleteeflag status of the largest version number field create_time.

[0027] Furthermore, in step S3, the time is set to 1 minute.

[0028] Furthermore, in step S3, the number of data items is set to 5000.

[0029] The beneficial effects of the present invention are: it can respond to query requests in milliseconds; it can query updated data in real time and return required data according to demand, solving the problem of multiple redundant data appearing before the update is triggered; deleted data can still be found after the deletion operation. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] Figure 1 The present invention is a flowchart of a solution for rapidly providing massive data query services.

[0031] Figure 2 This is a diagram showing an embodiment of a solution for quickly providing massive data query services according to the present invention.

[0032] Figure 3 The present invention is a flowchart of a solution for rapidly providing massive data query services. DETAILED DESCRIPTION

[0033] The present invention is further described below in conjunction with the accompanying drawings and embodiments.

[0034] The following will clearly and completely describe the concept, specific structure and technical effects of the present invention in combination with the embodiments and drawings, so as to fully understand the purpose, characteristics and effects of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, other embodiments obtained by technicians in this field without creative work are all within the scope of protection of the present invention. In addition, all the connection / connection relationships involved in the patent do not refer to the direct connection of components, but refer to the formation of a better connection structure by adding or reducing connection accessories according to the specific implementation situation. The various technical features in the invention can be combined interchangeably without conflicting with each other.

[0035] Example 1

[0036] Reference Figure 1 , Figure 2 As shown, the present invention discloses a solution for quickly providing a massive data query service. Specifically, the method includes the following steps:

[0037] S1. Create a TTL table;

[0038] In step S1, a TTL table of the ReplacingMergeTree engine is created according to business requirements;

[0039] S2. Add an identification field for data deduplication and update in the TTL table. In this embodiment, the primary key is used as the identification field. In addition, in each group of data, the row with the largest version number field create_time identifies the latest data. The default value of the version number field create_time is the insertion time of the data. A custom deletion flag bit deleteflag is set, where 0 represents not deleted and 1 represents deleted data.

[0040] S3, triggering the synchronous data addition operation at the interval set time; in this embodiment, the set time is 1 minute;

[0041] S4, convert the updated and deleted data into insert data and insert it into ClickHouse; in step S4,

[0042] When updating data, a new row of data is inserted, and the version number field create_time is the latest insertion time of the system. The modified field value is obtained by querying the largest version number field create_time;

[0043] When deleting data, a row of new data in the insert data, the version number field create_time is the latest insertion time of the system, deleteflag is changed to 1, and the rest are 0. The deleted data can be divided by querying the deleteflag status of the largest version number field create_time;

[0044] Combination Figure 1 As shown, the data comes from databases such as Mongddb, Oracle, and Hive. After synchronizing the incremental data through tools such as DateX or waterdrop, the operation in the above step S4 is performed;

[0045] S5. Create a corresponding view, select the field with the largest version number as the display field, and filter out deleted records;

[0046] In this embodiment, the following procedures are performed:

[0047] CREATE VIEW view_table_a AS

[0048] SELECT uniqueId,

[0049] argMax(column1,create_time)AS column1,

[0050] argMax(column2,create_time)AS column2,

[0051] argMax(columnN,create_time)AS columnN from table GROUP BY uniqueIdHAVING deleted=0;

[0052] S6. Modify the length of time the TTL table retains data according to business needs, and delete expired data regularly based on the version number.

[0053] Example 2

[0054] Reference Figure 2 , Figure 3 As shown, the present invention discloses a solution for quickly providing a massive data query service. Specifically, the method includes the following steps:

[0055] S1. Create a TTL table;

[0056] In step S1, a TTL table of the ReplacingMergeTree engine is created according to business requirements;

[0057] S2. Add an identification field for data deduplication and update in the TTL table; in this embodiment, the primary key is used as the identification field;

[0058] In addition, in each set of data, the row with the largest version number field create_time identifies the latest data. The default value of the version number field create_time is the insertion time of the data. The custom deletion flag bit deleteflag, 0 represents not deleted, and 1 represents deleted data.

[0059] S3. When the number of data items reaches a set number, a synchronous data addition operation is triggered; in this embodiment, the set number of data items is 5000;

[0060] S4, convert the updated and deleted data into insert data and insert it into ClickHouse; in step S4,

[0061] When updating data, a new row of data is inserted, and the version number field create_time is the latest insertion time of the system. The modified field value is obtained by querying the largest version number field create_time;

[0062] When deleting data, a new row of data is inserted into the data, and the version number field create_time is the latest insertion time of the system. The deleteeflag is changed to 1, and the rest are 0. The deleted data can be divided by querying the deleteeflag status of the largest version number field create_time.

[0063] Combination Figure 1 As shown, the data comes from databases such as Mongddb, Oracle, and Hive. After synchronizing the incremental data through tools such as DateX or waterdrop, the operation in the above step S4 is performed;

[0064] S5. Create a corresponding view, select the field with the largest version number as the display field, and filter out deleted records;

[0065] In this embodiment, the following procedures are performed:

[0066] CREATE VIEW view_table_a AS

[0067] SELECT uniqueId,

[0068] argMax(column1,create_time)AS column1,

[0069] argMax(column2,create_time)AS column2,

[0070] argMax(columnN,create_time)AS columnN from table GROUP BY uniqueIdHAVING deleted=0;

[0071] S6. Modify the length of time the TTL table retains data according to business needs, and delete expired data regularly based on the version number.

[0072] In combination with the above embodiments, the present invention discloses a solution for quickly providing massive data query services, which has the following advantages: first, it can respond to query requests in milliseconds; second, it can query updated data in real time, and return the required data according to demand, solving the problem of multiple redundant data appearing before the update is triggered; third, the deleted data can still be found after the deletion operation; fourth, it solves the problem that ClickHouse's row-by-row insert or small batch insert, update, and delete operations continuously perform asynchronous data merging at the bottom layer, affecting query performance.

[0073] The above is a specific description of the preferred implementation of the present invention, but the invention is not limited to the embodiments. Those skilled in the art can make various equivalent modifications or substitutions without violating the spirit of the present invention. These equivalent modifications or substitutions are all included in the scope defined by the claims of this application.

Claims

1. A solution for quickly providing massive data query services, characterized in that: The method comprises the following steps: S1. Create a TTL table; S2. Add an identification field for data deduplication update in the TTL table; S3: When the set interval time or the number of data items reaches the set number, the synchronous data addition operation is triggered; S4. Convert updated and deleted data into insert data and insert it into ClickHouse. S5. Create a corresponding view, select the field with the largest version number as the display field, and filter out deleted records; S6. Modify the length of time the TTL table retains data according to business needs, and delete expired data regularly based on the version number.

2. A solution for rapidly providing mass data query services according to claim 1, characterized in that: In step S1, a TTL table of the ReplacingMergeTree engine is created according to business requirements.

3. A solution for rapidly providing mass data query services according to claim 1, characterized in that: In step S2, the primary key is used as the identification field.

4. A method for quickly providing mass data query services according to claim 1, characterized in that: In step S2, in each set of data, the row with the largest version number field create_time identifies the latest data, and the default value of the version number field create_time is the insertion time of the data.

5. A method for quickly providing mass data query services according to claim 4, characterized in that: In step S2, a custom deletion flag is set to deleteflag, where 0 represents undeleted data and 1 represents deleted data.

6. A method for quickly providing mass data query services according to claim 5, characterized in that: In step S4, When updating data, a new row of data is inserted, and the version number field create_time is the latest insertion time of the system. The modified field value is obtained by querying the largest version number field create_time; When deleting data, a new row of data is inserted into the data, and the version number field create_time is the latest insertion time of the system. The deleteeflag is changed to 1, and the rest are 0. The deleted data can be divided by querying the deleteeflag status of the largest version number field create_time.

7. A method for quickly providing mass data query services according to claim 1, characterized in that: In step S3, the time is set to 1 minute.

8. A method for quickly providing mass data query services according to claim 1, characterized in that: In step S3, the number of data items is set to 5000.