Data subscription method for time sequence database

By storing system tables of data subscription information in the timing database and generating an execution plan, the inefficiency problem of users monitoring data table changes in real time is solved, efficient data subscription and query is achieved, and users' time and cost are reduced.

CN120336326APending Publication Date: 2025-07-18山东浪潮数据库技术有限公司 +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510473595.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-16
Publication Date
2025-07-18

AI Technical Summary

Technical Problem

The lack of convenient methods in the prior art enables users to monitor changes in data tables in real time, resulting in inefficient query efficiency and high labor costs.

Method used

By storing system tables of data subscription-related information in a time series database, recording subscription rules based on user-defined rules, and storing or pushing the results to the publishing tool specified by the user when the data changes, and queries are combined with SQL statements to generate execution plans, supporting multiple data scanning methods and failure control mechanisms.

Benefits of technology

Improve query efficiency, reduce the number of queries and labor costs, and users can monitor table data changes through a SQL statement, saving time and cost.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120336326A_ABST
    Figure CN120336326A_ABST
Patent Text Reader

Abstract

The invention discloses a data subscription method for a time sequence database, and relates to the technical field of time sequence databases. The method comprises the following steps: storing a system table of data subscription related information through a database, defining a data subscription rule according to a user, recording the data subscription rule in the system table, and when data subscription is started and data in a corresponding data table is changed according to the data subscription rule, performing data subscription according to the data subscription rule. Storing or pushing a data change result to a publishing tool specified by the user, when the user queries the subscription data, analyzing a query condition input by the user, judging whether a query statement is legal or not, if yes, judging whether a queried data table exists or not and whether a filtering condition is met or not, and if not, sending the data change result to the publishing tool; and if yes, generating an execution plan from the SQL statement corresponding to the query condition, issuing the execution plan when subscription is started, and querying the corresponding data table.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention discloses a data subscription method for a time series database, which relates to the technical field of time series databases. Background Art

[0002] The database itself can complete some automated operations through means such as scheduled tasks or background tasks, facilitating the use of users. For users, when the data in a table is updated, they need to obtain the data changes in real time. However, there is currently no convenient and fast method to monitor the data tables that users care about, enabling users to directly query the data results and data changes from the database. Summary of the Invention

[0003] In view of the problems of the prior art, the present invention provides a data subscription method for a time series database, which reduces a large number of query times, improves query efficiency, and greatly reduces labor costs.

[0004] The specific solution proposed by the present invention is as follows:

[0005] The present invention provides a data subscription method for a time series database. A system table for storing data subscription-related information is used in the database.

[0006] According to the user-defined data subscription rules, the data subscription rules are recorded in the system table.

[0007] When the data subscription is enabled, according to the data subscription rules, when the data in the corresponding data table changes, the data change results are stored or pushed to the publishing tool specified by the user.

[0008] When the user queries the subscribed data, the query conditions input by the user are parsed. First, it is judged whether the query statement is legal. If so, it is judged whether the queried data table exists and whether the filtering conditions are met. If so, the SQL statement corresponding to the query conditions is generated into an execution plan, and the execution plan is issued when the subscription is enabled to query the corresponding data table.

[0009] Further, in the data subscription method for a time series database, the system table records the id, name, relevant parameters during subscription, and relevant information during execution of the user-defined data subscription. The relevant parameters during subscription include the filtering conditions defined by the user, the name of the table, the creation time, the creator, and the current status. The relevant information during execution includes the execution time, whether the execution is successful, and the error message if an error occurs.

[0010] Further, when querying the corresponding data table in the data subscription method of the time series database, the data scanning method is selected according to the situation. When in the scenario of only inserting data, the data scanning method of only scanning the inserted data and combining the previously stored data with the inserted data is adopted; when in the scenarios of downtime restart and resume from breakpoint, the data scanning method of rescaning the entire table every time data is inserted is adopted.

[0011] Further, in the data subscription method of the time series database, the maximum number of global attempts for data subscription failure is set. When the number of failures reaches the maximum number of global attempts for data subscription failure, the attempt to push data is stopped, and the start and end of data push are controlled through SQL statements, which are used to pause and resume the data push task, or delete the existing data push task.

[0012] The present invention also provides a data subscription device for a time series database, including a table management module and a subscription management module.

[0013] The table management module stores the system table related to data subscription information through the database, defines the data subscription rules according to the user, and records the data subscription rules in the system table.

[0014] When data subscription is enabled, the subscription management module stores or pushes the data change result to the publishing tool specified by the user when the data in the corresponding data table changes according to the data subscription rules.

[0015] When the user queries the subscribed data, the subscription management module parses the query conditions input by the user, first determines whether the query statement is legal, if so, determines whether the queried data table exists and whether it meets the filtering conditions. If so, it generates an execution plan for the SQL statement of the corresponding query condition, and issues the execution plan when the subscription is enabled to query the corresponding data table.

[0016] Further, the table management module of the data subscription device for the time series database records the id, name, relevant parameters during subscription, and relevant information during execution of the user-defined data subscription through the system table. The relevant parameters during subscription include the filtering conditions defined by the user, the name of the table, the creation time, the creator, and the current status. The relevant information during execution includes the execution time, whether the execution is successful, and the error message if an error occurs.

[0017] Further, when the subscription management module of the data subscription device for the time series database queries the corresponding data table, the data scanning method is selected according to the situation. When in the scenario of only inserting data, the data scanning method of only scanning the inserted data and combining the previously stored data with the inserted data is adopted; when in the scenarios of downtime restart and resume from breakpoint, the data scanning method of rescaning the entire table every time data is inserted is adopted.

[0018] Furthermore, the subscription management module of the data subscription device for the time series database sets the maximum number of global attempts for data subscription to fail. When the number of failures reaches the maximum number of global attempts for failure, the attempt to push data is stopped, and the start and end of data push are controlled through SQL statements, which are used to pause and resume the data push task, or delete the existing data push task.

[0019] The advantages of the present invention are as follows:

[0020] The present invention can quickly help users obtain the desired query results, saving a large amount of time for users. And it can help users save a large amount of cost of inputting SQL statements, so that users no longer need to query one by one to obtain the desired results. They can obtain the changes in the data of the monitored table through one SQL statement in one table. Compared with the existing time series database without publish-subscribe, it reduces the usage cost of users and also reduces the time required for users to input SQL statements. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] Figure 1 It is a schematic diagram of the process of creating a subscription rule for the method of the present invention.

[0022] Figure 2 It is a schematic diagram of the process of enabling data subscription.

[0023] Figure 3 It is a schematic diagram of the process of restarting data subscription. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0024] The present invention will be further described below in conjunction with the accompanying drawings and specific embodiments, so that those skilled in the art can better understand the present invention and be able to implement it, but the embodiments cited do not limit the present invention.

[0025] Embodiment 1

[0026] The present invention provides a data subscription method for a time series database, and a system table for storing data subscription-related information is used in the database.

[0027] Among them, the system table records the id, name, relevant parameters at the time of subscription, and relevant information during execution of the user-defined data subscription. The relevant parameters at the time of subscription include the filtering conditions defined by the user, the name of the table, the creation time, the creator, and the current status. The relevant information during execution includes the execution time, whether the execution is successful, and the error message if an error occurs. The system table writes the initial information when the user creates a data subscription, and updates the information related to execution when the data subscription is executed.

[0028] Data subscription rules are defined according to the user, and the data subscription rules are recorded in the system table. When data subscription is enabled, according to the data subscription rules, when the data in the corresponding data table changes, the data change results are stored or pushed to the publishing tool specified by the user. For example, if subscription p1 is created, the subscription rule is select a from t1where b>100, and this rule is recorded in the system table. When the data subscription is enabled, a query will be performed every time the data in table t1 changes. The query is the value of column a when b is greater than 100, and the result will be stored or pushed to the publishing tool specified by the user. When the user wants to know what the data is under a certain monitoring condition when the data table changes, it can be directly obtained, avoiding multiple queries and wasting the user's time.

[0029] When a user queries subscription data, the query conditions entered by the user are parsed to determine whether the query statement is legal. If so, it is determined whether the queried data table exists and whether it meets the filtering conditions. If so, an execution plan is generated for the SQL statement corresponding to the query condition. When the subscription is enabled, the execution plan is issued to query the corresponding data table.

[0030] When querying the corresponding data table, select the data scanning method according to the situation. When only inserting data, use the data scanning method that only scans the inserted data and combines the previously stored data with the inserted data, which can greatly improve efficiency; when in the scenario of downtime restart and breakpoint resumption, use the data scanning method that rescans the entire table each time data is inserted to accurately scan all data that meets the requirements. Users can manually control these two methods through data subscription task parameters.

[0031] And when the user pauses the push, or the database stops pushing data due to downtime or network problems, when the database data subscription function is restarted, the data that has not been pushed will be pushed again from the data that stopped pushing. If the user inserts data during the stop period, the maximum push quantity parameter can be set to control the amount of data. If this parameter is exceeded, the user can choose to report an error or push part of the data.

[0032] You can also set the maximum number of global failed attempts for data subscription. When the number of failures reaches the maximum number of global failed attempts, stop trying to push data. Use SQL statements to control the start and end of data push, pause and resume data push tasks, or delete existing data push tasks.

[0033] In addition, the front end can be used to view data subscription tasks, and all subscription tasks in the current system of the database can be viewed, including subscription names, subscription content, task creation time, creator, current task status, start execution time, end time, total execution times, failure times, failure reasons, number of failure attempts, etc.

[0034] Embodiment 2

[0035] The present invention also provides a data subscription device for a time series database, including a table management module and a subscription management module.

[0036] The table management module stores data subscription-related information in the system table of the database, defines data subscription rules according to the user, and records the data subscription rules in the system table.

[0037] When data subscription is enabled, the subscription management module stores or pushes the data change results to the publishing tool specified by the user when the data in the corresponding data table changes according to the data subscription rules.

[0038] When the user queries the subscribed data, the subscription management module parses the query conditions input by the user, first determines whether the query statement is legal, if so, determines whether the queried data table exists and whether it meets the filtering conditions. If so, it generates an execution plan for the SQL statement corresponding to the query conditions, and issues the execution plan when the subscription is enabled to query the corresponding data table.

[0039] Regarding the information interaction and execution process among the above-mentioned modules in the device, since they are based on the same concept as the method embodiment of the present invention, the specific content can be referred to the description in the method embodiment of the present invention and will not be elaborated here.

[0040] Similarly, the device of the present invention can quickly help the user obtain the desired query results, saving a large amount of time for the user. And it can help the user save a large amount of cost of inputting SQL statements, enabling the user to obtain the desired results without querying one by one. Through one SQL statement in a table, the user can obtain the changes in the data of the table to be monitored. Compared with the existing time series database without publish-subscribe, it reduces the user's usage cost and the time required for the user to input SQL statements.

[0041] It should be noted that not all steps and modules in the above-mentioned processes and device structures are necessary, and some steps or modules can be ignored according to actual needs. The execution order of each step is not fixed and can be adjusted according to needs. The system structures described in the above-mentioned embodiments can be physical structures or logical structures, that is, some modules may be implemented by the same physical entity, or some modules may be implemented by multiple physical entities respectively, or some components in multiple independent devices may be jointly implemented.

[0042] The above-described embodiments are merely preferred embodiments cited to fully illustrate the present invention, and the protection scope of the present invention is not limited thereto. Equivalent substitutions or transformations made by those skilled in the art in the technical field on the basis of the present invention are all within the protection scope of the present invention. The protection scope of the present invention is subject to the claims.

Claims

1. A method for subscribing to data in a time-series database, characterized in that The database stores the system table related to data subscription. According to the user-defined data subscription rules, and the data subscription rules are recorded in the system table, When data subscription is enabled, according to the data subscription rules, when the data in the corresponding data table changes, the data change results will be stored or pushed to the user-specified publishing tool. When a user queries subscription data, the query conditions entered by the user are parsed to determine whether the query statement is legal. If so, it is determined whether the queried data table exists and whether it meets the filtering conditions. If so, an execution plan is generated for the SQL statement corresponding to the query condition. When the subscription is enabled, the execution plan is issued to query the corresponding data table.

2. The data subscription method for a time series database according to claim 1, characterized in that The system table records the id, name, subscription-related parameters, and execution-related information of the user-defined data subscription. The subscription-related parameters include the user-defined filter conditions, table name, creation time, creator, and current status. The execution-related information includes the execution time, whether the execution is successful, and the error message if an error is reported.

3. The data subscription method for a time series database according to claim 1, wherein When querying the corresponding data table, select the data scanning method according to the situation. When in the scenario of only inserting data, adopt the data scanning method of only scanning the inserted data and combining the previously stored data with the inserted data; when in the scenario of downtime restart or breakpoint resumption, adopt the data scanning method of rescanning the entire table each time data is inserted.

4. A method for subscribing to data in a time series database according to claim 1, characterized in that Set the maximum number of global failed attempts for data subscription. When the number of failures reaches the maximum number of global failed attempts, stop trying to push data. Use SQL statements to control the start and end of data push, which is used to pause and resume data push tasks, or delete existing data push tasks.

5. A data subscription device for a time series database, characterized in that include: Table management module, subscription management module, The table management module stores the system table of data subscription related information in the database, defines the data subscription rules according to the user, and records the data subscription rules in the system table. When data subscription is enabled, the subscription management module stores or pushes the data change results to the user-specified publishing tool according to the data subscription rules when the data in the corresponding data table changes. When a user queries subscription data, the subscription management module parses the query conditions entered by the user, first determining whether the query statement is legal. If so, it determines whether the queried data table exists and whether it meets the filtering conditions. If so, it generates an execution plan for the SQL statement corresponding to the query conditions, and issues the execution plan when the subscription is enabled to query the corresponding data table.

6. The data subscription device for a time series database according to claim 5, characterized in that The table management module records the id, name, subscription-related parameters, and execution-related information of user-defined data subscriptions through system tables. The subscription-related parameters include user-defined filter conditions, table name, creation time, creator, and current status. The execution-related information includes execution time, whether the execution is successful, and error information if an error is reported.

7. A data subscription device for a time series database according to claim 5, wherein when the subscription management module queries the corresponding data table, it selects a data scanning method according to the situation. When in a scenario of only inserting data, it adopts a data scanning method that only scans the inserted data and combines the previously stored data with the inserted data; when in a scenario of downtime restart or resume from breakpoint, it adopts a data scanning method that re-scans the entire table every time data is inserted.

8. A data subscription device for a time series database according to claim 5, wherein the subscription management module sets the maximum number of global attempts for data subscription to fail. When the number of failures reaches the maximum number of global attempts for failure, it stops attempting to push data and controls the start and end of data pushing through SQL statements, which is used to pause and resume data pushing tasks, or delete existing data pushing tasks.