Time series data query method, system and server
By receiving user queries for time spans in the industrial monitoring system, calculating the sampling point time intervals, and generating a list of sampling times, the inconsistency problem of data at the same moment across different time spans is solved, achieving data consistency and reducing storage costs, and supporting accurate trend analysis and fault diagnosis.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-04
- Publication Date
- 2026-03-13
AI Technical Summary
In industrial production monitoring systems, the trend charts of data at the same moment are inconsistent across different time spans, leading to misjudgments of the severity of faults by maintenance personnel and delays in troubleshooting. Furthermore, existing technologies suffer from poor data correlation, large analysis errors, and high storage costs.
By receiving the target query time span input by the user, calculating the sampling point time interval and generating a list of sampling times, obtaining the backtracking time length of the backtracking window, extracting the data value with the closest timestamp from the original time series database, and generating trend chart data, the consistency of data at the same time under different spans is ensured.
It achieves data consistency at the same moment across different time spans, reduces storage costs, improves data timeliness, avoids operational misjudgments and analysis errors, and supports accurate fault diagnosis and trend analysis.
Smart Images

Figure CN121658729A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data processing technology, and in particular to a time-series data query method, system, and server. Background Technology
[0002] A trend chart is a statistical graph that uses time as the horizontal axis and the observed variable as the vertical axis to reflect the relationship between time and quantity, and to observe the trend and deviation of variable changes. In the software of Discrete Control Systems (DCS), trend chart data is obtained from historical or real-time data. Through sampling and filtering, sampled data is cached, and data within the time span is obtained according to the start and end times set for the trend chart for display. However, in industrial production monitoring systems, users often need to switch between different time spans on the same interactive interface to view the trend changes of the same monitoring indicator, and must ensure that the data values corresponding to the same physical moment are completely consistent to achieve accurate comparative analysis of data across different spans. However, the current trend chart generation method uses independent sampling aggregation rules for different time spans, which may result in the same physical moment being assigned to different sampling intervals, leading to inconsistencies in data at the same moment. For example, when tracing back industrial equipment failures, it is necessary to simultaneously verify whether the data at a certain failure moment in a 1-hour span is consistent with the data at the same moment in a 1-day span. If a fault occurs at a time when the temperature is 38℃ in the 1-hour trend chart but 40℃ in the 1-day trend chart, it may lead maintenance personnel to misjudge the severity of the fault and even delay the opportunity to troubleshoot. Summary of the Invention
[0003] This invention addresses the shortcomings of existing technologies by providing a time-series data query method, comprising the following steps: Receive the target query time span input by the user, wherein the target query time span includes the start time and the end time; Based on the target query time span and the size of the preset time span threshold, the sampling point time interval is calculated and a list of first sampling times is generated; Obtain the backtracking time length of the backtracking window. For each sampling moment, extract all original data values from the original time series database up to the previous backtracking time length from the sampling moment. Select the original data value whose timestamp is closest to the sampling moment as the target data value for that sampling moment. Sort the target data values of all sampling moments by time to generate trend chart data within the required query time span.
[0004] Preferably, the calculation of the sampling point time interval and the generation of the first sampling time list based on the target query time span compared with the preset time span threshold specifically includes: If the target query time span is not greater than the preset time span threshold, then the current sampling point time interval is obtained according to the first sampling density, and a first sampling time list for the target query time span is generated based on the current sampling point time interval. If the target query time span is greater than the preset time span threshold, the corresponding current sampling point time interval is determined according to the ratio between the target query time span and the preset time span threshold, and a first sampling time list for the target query time span is generated based on the current sampling point time interval.
[0005] Preferably, generating the list of first sampling moments within the target query time span specifically includes: The current sampling time interval is obtained by rounding up the ratio of the target query time span to the preset time span threshold. The ratio of the current target query time span to the current sampling point time interval is rounded up and then incremented by one to obtain the number of sampling points applicable to the current target query time span; A list of first sampling moments for the current target query time span is generated based on the number of sampling points and the sampling point time interval.
[0006] Preferably, the time-series data query method further includes: After receiving the user's input instruction to switch the time span, the start and end times of the new time span in the instruction are parsed to obtain the new query time span to be switched to; Based on the comparison of the new query time span with the preset time span threshold, the sampling point time interval is modified and a second sampling time list is generated; For each new sampling time in the second sampling time list, extract all original data values from the same original time series database up to the same backward time length from that sampling time, and select the original data value whose timestamp is closest to the sampling time as the target data value for the new sampling time; after sorting all the target data values of the new sampling times by time, generate the trend chart data within the new query time span to be switched.
[0007] Preferably, the backtracking time length of the backtracking window is determined based on the original update cycle of the target time series data to be queried, as input by the user.
[0008] This invention also discloses a time-series data query system, comprising: The instruction receiving module is used to receive the target query time span input by the user, wherein the target query time span includes the start time and the end time; The sampling time generation module is used to calculate the sampling point time interval and generate a first sampling time list based on the target query time span and the size of the preset time span threshold. The sampling data acquisition module is used to extract all original data values from the original time series database for each sampling time according to the backtracking time length of the acquired backtracking window, and select the original data value whose timestamp is closest to the sampling time as the target data value for that sampling time; after sorting the target data values of all sampling times by time, it generates trend chart data within the required query time span.
[0009] Preferably, the sampling time generation module specifically includes: The first list generation module is used to obtain the current sampling point time interval according to the first sampling density when the target query time span is not greater than the preset time span threshold, and generate a first sampling time list for the target query time span based on the current sampling point time interval. The second list generation module is used to determine the corresponding current sampling point time interval based on the ratio between the target query time span and the preset time span threshold when the target query time span is greater than the preset time span threshold, and to generate a first sampling time list for the target query time span based on the current sampling point time interval.
[0010] Preferably, the second list generation module is further configured to: round up the ratio of the target query time span to a preset time span threshold to obtain the current sampling point time interval; round up the ratio of the current target query time span to the current sampling point time interval and add one to obtain the number of sampling points applicable to the current target query time span; and generate a first sampling time list for the current target query time span based on the number of sampling points and the sampling point time interval.
[0011] The present invention also discloses a server, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of any of the methods described above.
[0012] The present invention also discloses a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of any of the methods described above.
[0013] The time-series data query method, system, and server disclosed in this invention receive a target query time span input by the user, calculate the sampling point time interval based on the target query time span and compare it with a preset time span threshold, and generate a first sampling time list; obtain the backtracking time length of the backtracking window, extract all original data values from the original time-series database for each sampling time to the previous backtracking time length, and select the original data value with the timestamp closest to the sampling time as the target data value for that sampling time; finally, after sorting the target data values of all sampling times by time, a trend chart data within the required query time span is generated. By using the same backtracking time length, the traditional data retrieval logic within the sampling interval is abandoned, ensuring the consistency of data sources for the same moment across different spans from the root, thus solving the data inconsistency problem. Furthermore, there is no redundant real-time data retrieval, no need to pre-store multi-span sampling data, and all span sampling data are generated by real-time querying of the original database, effectively reducing storage costs and avoiding deviations caused by differences between stored data and original data updates, thereby improving data timeliness.
[0014] Additional aspects and advantages of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. Attached Figure Description
[0015] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this application, illustrate exemplary embodiments of the invention and, together with their description, serve to explain the invention and do not constitute an undue limitation thereof. In the drawings: Figure 1 This is a schematic diagram of the process steps of a time-series data query method disclosed in an embodiment of the present invention.
[0016] Figure 2 This is a schematic diagram of step S2 disclosed in an embodiment of the present invention.
[0017] Figure 3 This is a schematic diagram illustrating the acquisition of the number of sampling points according to an embodiment of the present invention.
[0018] Figure 4 This is a schematic diagram of another process of the time-series data query method disclosed in an embodiment of the present invention. Detailed Implementation
[0019] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. All other embodiments obtained by those skilled in the art based on the described embodiments of the present invention without creative effort are within the scope of protection of the present invention.
[0020] Unless otherwise defined, the technical or scientific terms used herein shall have the ordinary meaning as understood by one of ordinary skill in the art to which this invention pertains. The terms “first,” “second,” and similar terms used in the specification and claims of this patent application do not indicate any order, quantity, or importance, but are merely used to distinguish different components. Similarly, the terms “an” or “a” and similar terms do not indicate a limitation of quantity, but rather indicate the presence of at least one.
[0021] In industrial production monitoring systems, users often need to switch between different time spans on the same interactive interface, such as 1 hour, 1 day, 7 days, and 31 days, to view the trend changes of the same monitoring indicator. It is crucial to ensure that the data values corresponding to the same physical moment (e.g., 15:05:05 on [Date in 2025]) are completely consistent to achieve accurate comparative analysis of data across different spans. For example, when tracing back industrial equipment failures, it is necessary to simultaneously verify whether the data at a certain time during a failure span is consistent with the data at the same time during a 1-hour span. If a failure moment shows a temperature of 38℃ in the 1-hour trend chart but 40℃ in the 1-day trend chart, it could lead to maintenance personnel misjudging the severity of the failure and even delaying troubleshooting. In existing technologies, multi-time-span data sampling and filtering mainly suffer from the following problems: 1. Inconsistent data at the same moment; 2. Poor data correlation: Sampling data for different spans are stored independently in different datasets. When a user switches from a 1-hour span to a 1-day span, the system needs to re-query and recalculate the data for that span from the original database, which not only increases query latency but may also further amplify the inconsistency of data at the same moment due to differences in calculation logic; 3. Large analysis errors across different spans: In industrial fault diagnosis, inconsistency of data at the same moment can lead to biased analysis conclusions; 4. Under different time spans, the actual time-series data recorded in the database consists of hundreds to millions of data points, but the resolution of display devices is limited, such as hundreds to thousands of pixels. Therefore, a limited number of data points need to be sampled / aggregated from the database to plot curves that represent the data change trend. However, current common aggregation methods can lead to inconsistencies in the values obtained at the same moment on the curves for different time spans.
[0022] To address the problem of large diagnostic errors caused by inconsistent data at the same moment across different time spans, this embodiment discloses a time-series data query method, as shown in the attached figure. Figure 1 As shown, it can specifically include the following content.
[0023] Step S1: Receive the target query time span input by the user, wherein the target query time span includes the start time and the end time.
[0024] By receiving the target query time span input by the user, the system captures the time boundary information in the query request, clearly defines the complete query interval including the start and end times, and delineates a clear range for all subsequent sampling and data processing operations. This ensures that all subsequent operations revolve around the user-specified time interval and avoids interference from irrelevant data.
[0025] Step S2: Based on the target query time span and the size of the preset time span threshold, calculate the sampling point time interval and generate the first sampling time list.
[0026] In this embodiment, as shown in the appendix Figure 2 As shown, step S2 can also specifically include the following:
[0027] Step S21: If the target query time span is not greater than the preset time span threshold, then obtain the current sampling point time interval according to the first sampling density, and generate a first sampling time list for the target query time span based on the current sampling point time interval.
[0028] In this embodiment, by adapting the first sampling density to the characteristics of short time dimensions, a standard for the time interval of sampling points is established, ensuring a deep match between the sampling strategy and the granular data requirements of short-span queries. In industrial monitoring scenarios, such short-span queries are often used to track real-time fluctuations or short-term trends of monitoring indicators at close range, such as parameter dynamics during equipment startup or short-term data observations during initial fault diagnosis. In these cases, it is necessary to retain the detailed features of the data through a reasonable sampling interval to avoid losing key fluctuation information due to excessively large intervals. The first sampling time list generated based on the time interval determined by the first sampling density can completely cover the target query time span specified by the user, and the sampling times are evenly distributed in the time dimension. The sampling time benchmark established by this list works in conjunction with the data filtering logic of the subsequent backtracking window. This enables data to be extracted from the original database at each sampling time in short-span scenarios based on unified rules. This provides a prerequisite guarantee for the consistency of data at the same physical moment when switching between different time spans. In turn, it supports operation and maintenance personnel in accurately analyzing changes in monitoring indicators within a short time dimension, such as identifying abnormal nodes in short-term data fluctuations and verifying the accuracy of fault time data within a short span. This avoids data analysis bias problems caused by non-standard sampling in short spans.
[0029] Step S22: If the target query time span is greater than the preset time span threshold, then the corresponding current sampling point time interval is determined according to the ratio between the target query time span and the preset time span threshold, and a first sampling time list for the target query time span is generated based on the current sampling point time interval.
[0030] In this embodiment, by proportionally relating the target query time span to a preset threshold, a sampling interval standard that meets the observation requirements of long-span data is established, generating a first sampling time list covering the complete long-cycle query interval. Such long-span queries are often used in industrial monitoring scenarios to observe the long-term operating trends of monitoring indicators, such as monthly changes in equipment operating conditions and quarterly parameter fluctuation patterns. The first sampling time list generated based on the sampling point time interval determined by this proportional relationship can achieve uniform coverage of the long-cycle query interval, ensuring that key time nodes required for long-term trend analysis are not missing. This supports maintenance personnel in accurately assessing the long-term operating status of equipment, such as identifying parameter fluctuation patterns within a monthly cycle and tracing related data from quarterly fault occurrence periods. Furthermore, the unified proportional correlation logic ensures that the sampling time generation rules for different long-span queries remain consistent. When subsequently combining data with the backtracking window time length, the sampling basis for the same physical moment under different long spans is identical, eliminating the problem of cross-span data deviation caused by differences in sampling logic from the source.
[0031] In this embodiment, the determined target query time span is analyzed and differentiated based on a preset time span determination criterion. This dynamically optimizes the time distribution interval of sampling points, ultimately generating a first sampling time list covering the entire query interval. This achieves deep adaptation between the sampling strategy and the characteristics of the query time span, ensuring complete coverage of the user-specified time interval through reasonable sampling point distribution, while effectively avoiding redundant computing resources due to overly dense sampling or missing key data due to overly sparse sampling.
[0032] Step S22 specifically includes: The current sampling point time interval is obtained by rounding up the ratio of the target query time span to a preset time span threshold. The number of sampling points applicable to the current target query time span is then obtained by rounding up the ratio of the current target query time span to the current sampling point time interval and adding one. A first sampling time list for the current target query time span is generated based on the number of sampling points and the sampling point time interval.
[0033] In one specific embodiment, 30 minutes and 1800 seconds is used as the critical threshold in an industrial monitoring scenario. Based on the length of the target time span, the number of sampling points is calculated in two modes to ensure that the same physical moment corresponds to a unique sampling point under different spans, while matching the resolution of the display device.
[0034] If the time span is ≤30 minutes (1800 seconds): a high-density sampling rule of 1 sampling point per second is adopted, and the number of sampling points = target time span (seconds) + 1, ensuring that the start and end times are included. For example, if the time span is 28 minutes, or 1680 seconds, the number of sampling points = 1680 + 1 = 1681, and each sampling point corresponds to "start time + 0 seconds", "start time + 1 second"... "start time + 1680 seconds of physical time".
[0035] If the time span is >30 minutes (1800 seconds): calculate in two steps to ensure that the sampling points are evenly spaced and cover the entire span: Step 1: Calculate the sampling interval = round up (target time span (seconds) / 1800). For example: 7803 seconds ÷ 1800 ≈ 4.335, round up to get 5 seconds; Step 2: Calculate the number of sampling points = round up (target time span (seconds) / sampling interval) + 1. (See attached image) Figure 3 As shown, for example: 7803 seconds ÷ 5 seconds = 1560.6, round up and add 1 = 1562, which is the number of sampling points. Each sampling point corresponds to "start time + 0 seconds", "start time + 5 seconds"... "start time + 7805 seconds", ensuring coverage up to the end time.
[0036] Ultimately, by first defining the sampling point time interval suitable for long-span scales, and then determining the number of sampling points that can completely cover the query interval, an ordered list of first sampling times is generated. The sampling point time intervals determined through rounding avoid both excessively dense intervals leading to a surge in data volume and increased system computation and storage burden, and excessively sparse intervals preventing the loss of key trend nodes within long periods. The addition of one during point calculation ensures that the sampling time list completely includes the start and end times of the query interval, avoiding missing data at the beginning and end of the time series, allowing the generated trend chart to fully reflect the indicator changes throughout the entire long span. Simultaneously, the standardized rounding and point calculation logic maintains consistent sampling time generation rules for queries with different long spans. When subsequently using the same backtracking window for data retrieval, the sampling basis for the same physical time across different long spans remains completely consistent. Furthermore, the generated sampling time list is evenly and orderly distributed over time, ensuring that maintenance personnel can clearly observe long-term trends and providing accurate data for scenarios such as long-term equipment condition assessment and fault backtracking analysis.
[0037] Step S3: Obtain the backtracking time length of the backtracking window. For each sampling time, extract all original data values from the original time series database up to the previous backtracking time length from the sampling time. Select the original data value whose timestamp is closest to the sampling time as the target data value for that sampling time. Sort all the target data values of the sampling times by time to generate trend chart data within the required query time span.
[0038] In this embodiment, the backtracking window time length for the adapted scenario is obtained, and a clear range of raw data extraction is defined for each previously generated sampling moment. All raw data within a specific time frame backtracking from the original time series database for that sampling moment is locked. Then, the raw data closest to the sampling moment timestamp is determined as the target value through filtering rules. Finally, all target values are organized in chronological order to form trend chart data that meets the query requirements. The sampling moment is transformed into a trend chart node with actual data support. Simultaneously, relying on the original database and unified filtering rules, underlying execution guarantees are provided for data consistency at the same sampling moment across different time spans. Regardless of the query time span, for sampling points at the same physical moment, as long as the same backtracking window and filtering rules are used, completely consistent target data can be obtained from the same original time series database, completely solving the core problem of data inconsistency at the same moment across different spans. Furthermore, the target data sorted by time can continuously and completely reflect the change trajectory of monitoring indicators within the query span. The generated trend chart can accurately present the fluctuation characteristics and trend of the indicators, effectively supporting maintenance personnel to conduct key tasks such as industrial monitoring indicator analysis and fault diagnosis through visualized trend charts, reducing the risk of misjudgment caused by data problems.
[0039] Specifically, for each sampling point at physical time T0, the data is locked according to the following logic to ensure data consistency at the same time across different spans: Data extraction: Extract all raw data from the original database within the time period from T0-W to T0, where W is the backtracking window length; Data filtering: Prioritize data with a quality stamp of GOOD. If multiple GOOD data exist, select the data value with the timestamp closest to T0; If there is no GOOD data from T0-W to T0 (i.e., all are in BAD state), select the most recent GOOD data value before T0-W and mark it with a fault filling indicator to ensure data continuity; Anomaly handling: If the number of data in the window exceeds 100, sort by timestamp and take the most recent T0 value of the middle 100 data to balance efficiency and accuracy.
[0040] In this embodiment, the backtracking time length of the backtracking window is determined based on the original update cycle of the target time series data to be queried, input by the user.
[0041] In another specific embodiment, the backtracking time length of the backtracking window can be obtained through the following steps.
[0042] Step S101: Obtain the multicast period of the time-series data to be queried. The multicast period is the original update period of the time-series data in the module. Specifically, the original update period of the time-series data in the module is either the pre-set update period of the basic variable data of the distributed control system in the industrial monitoring system, or the data acquisition update period pre-configured and adjusted by each module according to the current application scenario.
[0043] Specifically, the multicast period T is the original update period of the time-series data, which is a default value preset in the industrial monitoring system. It can be adjusted according to the actual scenario. For simple DCS variables such as temperature and pressure sensor direct data, the default multicast period T = 1 second. The multicast period of other modules is preset according to the actual application scenario and can be adjusted.
[0044] Step S102: Determine the module failure coefficient based on the module type of the time series data to be queried and the historical data quality of the module, wherein the module failure coefficient is adapted to the module failure characteristics; determine the quality correction factor based on the effective data density of the module in the preset historical period.
[0045] In this embodiment, when determining the module fault coefficient, it is necessary to first obtain the specific type of the module to which the time-series data to be queried belongs. This can be done by calling the module management function of the industrial monitoring system to read the attribute information pre-registered in the system for the module, thus clarifying whether it belongs to a simple variable module, functional block module, or third-party data acquisition module of the distributed control system. Based on the confirmed module type, the corresponding module basic coefficient is retrieved from the system's built-in basic coefficient configuration matrix. This basic coefficient is pre-set based on the data update rules, operational stability characteristics, and industrial application requirements of different modules, with different basic coefficient configurations corresponding to different categories of modules. Historical data quality stamp records of the module within a preset historical period are extracted. These quality stamps record in detail the status information during the data generation process, including fault states such as controller disconnection and network disconnection, as well as the status indicators of normal and valid data. Based on these quality stamp records, the cumulative occurrence duration of various faults of the module within the preset historical period is statistically analyzed. Then, combined with the proportion of the cumulative fault duration in the entire preset historical period, the previously obtained module basic coefficients are adaptively adjusted to ultimately form a module fault coefficient that can accurately match the fault characteristics of the module.
[0046] In obtaining the quality correction factor, it is necessary to first determine the preset historical period for data density analysis. This period must align with the standard timeframe requirements for data quality assessment in the industrial monitoring field. From the historical data storage unit of the industrial monitoring system, all data records of the module to which the queried time-series data belongs within the preset historical period are retrieved. These records are then categorized and sorted according to their quality status, filtering out valid and invalid data. Valid data is data with a quality stamp indicating a normal state, while invalid data includes data marked with various fault states such as controller disconnection or network disconnection. The number of valid data records within the preset historical period is compared to the total number of data records within that period. By calculating the proportion of valid data to the total number of data records, the effective data density of the module within the preset historical period is obtained. Based on the calculated effective data density, and referring to the system's pre-set correction factor generation rules, the corresponding quality correction factor is determined. This ensures that the correction factor objectively reflects the validity of the module's historical data, providing adjustment parameters for the data quality dimension in the subsequent accurate calculation of the backtracking window duration.
[0047] In this embodiment, the module failure coefficient is determined based on the module type where the time-series data to be queried is located and the historical data quality of that module. Specifically, it may include the following:
[0048] Step S1021: Obtain the module type for collecting the time series data to be queried, and query the corresponding module basic coefficients according to the module type. The module basic coefficients can be pre-configured based on the update characteristics and stability of the time series data collected by the module.
[0049] Step S1022: Extract the historical data quality stamp of the module within a preset historical period interval, obtain the fault duration within the preset historical period interval based on the historical data quality stamp, and obtain the fault impact coefficient based on the proportion of the fault duration within the historical period interval.
[0050] The historical data quality stamp is used to identify the quality status and fault type of each historical data. The quality status includes valid status and fault status, and the fault type includes, but is not limited to, controller disconnection and network disconnection.
[0051] Step S1023: Determine the module fault coefficient of the current module based on the module basic coefficient and the fault impact coefficient.
[0052] Specifically, a basic coefficient K0 can be set according to the module type, and then dynamically corrected by combining historical data quality stamps, so that the final range of K0 falls within the 10-30 range (ensuring that the calculation results of subsequent windows are within the 10-100 second range). When setting the basic coefficient K0, if it is a simple DCS variable, the basic coefficient is K0=15, ensuring stable data updates and eliminating the need for an excessively large basic window. If it is another module, such as a functional module or third-party collected data, the basic coefficient K0 is preset according to the module's data update characteristics and stability. In this embodiment, the basic coefficient K0 value for the functional module can be K0=20 to ensure adaptation to module characteristics. The dynamic correction method for historical data quality stamps can extract the historical data quality stamps of this module over the past month and record the fault type: controller disconnection (BAD|OFF), network disconnection (BAD|NETERROR), and normal / valid (GOOD). The fault impact coefficient α is calculated using the following formula: α = 1 + (Total fault duration / Total 30-day duration) * 10. Where the total fault duration is the cumulative duration of BAD|OFF and BAD|NETERROR, and the value of α ranges from 1 to 11. The more frequent the faults, the larger α is, and the larger the module fault coefficient K is, ensuring that K falls within the range of 10-30.
[0053] The final module failure coefficient K = module base coefficient K0 * α. K is adjusted by α to adapt to the module failure characteristics. In addition, the value of K can be retained to one decimal place for easy subsequent calculation.
[0054] In this embodiment, the quality correction factor is determined based on the effective data density of the module within a preset historical period, which may specifically include: The effective data ratio is obtained based on the effective state data volume and the total data volume within a preset historical period interval. A quality correction factor is calculated based on the effective data ratio to correct the backtracking window. The quality correction factor is configured to correspond to the effective data ratio and increases as the effective data ratio decreases, and is used to increase the backtracking window.
[0055] Specifically, the backtracking window can be further adjusted based on the density of valid data in historical data to ensure that there is valid data within the backtracking window. The formula for the quality correction factor β is as follows: β = 1 + (1 - percentage of valid data) * 2.
[0056] The percentage of valid data = the amount of GOOD status data in the past month / the total amount of data. The quality correction factor β ranges from 1 to 3. The β value is rounded to one decimal place. The lower the percentage of valid data, the larger the β and the larger the window, to avoid missing valid data.
[0057] Step S103: After correcting the multicast period of the current time-series data to be queried using the quality correction factor and module failure coefficient, the initial window duration is obtained. The initial window duration is then adjusted according to the set adjustment rules to obtain the final backtracking window duration.
[0058] In this embodiment, the initial window duration W0 is calculated, where W0 = multicast period T * module failure coefficient K * quality correction factor β. The initial window duration W0 is rounded to obtain the intermediate window duration W1. It is then determined whether the intermediate window duration W1 is within the set duration range. If the duration of the intermediate window is within the set duration range, the duration of the intermediate window is used as the final backtracking window duration; if the duration of the intermediate window is less than the set duration range, the preset minimum window duration is obtained as the final backtracking window duration; if the duration of the intermediate window is greater than the set duration range, the preset maximum window duration is obtained as the final backtracking window duration.
[0059] Specifically, the initial window duration W0 = multicast period T * module failure coefficient K * quality correction factor β. The calculation result is rounded to the nearest integer, while ensuring that W0 falls within the range of 10-100 seconds. If the rounded intermediate window duration W1 is less than 10 seconds, it is forcibly set to 10 seconds; if W1 is greater than 100 seconds, it is forcibly set to 100 seconds. This is to adapt to the data characteristics of different modules and facilitate system time dimension calculations.
[0060] The following two specific examples will be used to illustrate this.
[0061] For example, if it is a simple variable in DCS, then T is assumed to be 1 second. If the total fault duration in the past month accounts for 5%, then α = 1 + 0.05 * 10 = 1.5. If the effective data percentage is 98%, then β = 1 + (1 - 0.98) * 2 = 1.04. Then W0 = 1 * 15 * 1.5 * 1.04 ≈ 23.4 seconds, which is rounded to 23 seconds, falling within the 10-100 second range, suitable for scenarios with low fault frequency and good data quality.
[0062] • If it is a certain functional block module, the default is T=5 seconds, the module's basic coefficient K0=20, and the total fault duration in the past month accounts for 2%, then α=1+0.02*10=1.2. If the effective data percentage is 95%, then β=1+(1-0.95)*2=1.1. Then W0=5*20*1.2*1.1=132 seconds, which is rounded to 132 seconds. If it exceeds 100 seconds, it is forcibly set to 100 seconds to adapt to scenarios with low-frequency updates and the need to limit the upper limit of the window.
[0063] In this embodiment, as shown in the appendix Figure 4 As shown, this time-series data query method may also include the following:
[0064] Step S4: After receiving the user's input instruction to switch the time span, parse the start and end times of the new time span in the switching instruction to obtain the new query time span to be switched.
[0065] Step S5: Based on the new query time span and the size of the preset time span threshold, modify the sampling point time interval and generate a second sampling time list.
[0066] Step S6: For each new sampling time in the second sampling time list, extract all original data values from the same original time series database up to the same backtracking time length from the sampling time, and select the original data value whose timestamp is closest to the sampling time as the target data value of the new sampling time; after sorting all the target data values of the new sampling times by time, generate the trend chart data within the new query time span to be switched.
[0067] When a user switches between different time spans, the system ensures data consistency through the following process: receiving the switching instruction, determining the new target time span and the current query module type; generating a list of physical times of sampling points according to the dynamic sampling point calculation rules; calling the historical database to obtain the quality stamp data of the module for the past month, and calculating the backtracking window time length W in combination with the module's preset multicast period (the original update period of the time series data); for each sampling point time T0, performing data extraction and filtering from T0-W to T0, and locking the data value; sorting the data by timestamp, generating a trend chart and displaying it. At the same time T0, under different spans, the same integer W window and filtering logic are used to extract data, ensuring that the data values are completely consistent.
[0068] Specifically, in time-series data queries, when a user switches time spans, the time boundaries of the new query time span are clarified by parsing the switching command. Then, sampling parameters are dynamically adjusted based on preset thresholds to generate a list of sampling times that adapts to the new span. Finally, a unified backtracking window length and data filtering logic are reused to extract target data from the original database. In span switching scenarios, the data processing logic and core rules remain consistent, connecting with the previous basic query process, and the processing logic will not change due to span changes. By parsing the time information in the switching command, it is ensured that the new query time span fully matches the user's needs, avoiding trend analysis misalignment caused by time boundary deviations. The second list of sampling times generated based on adjusting the sampling point time interval based on preset thresholds can adapt to the time scale characteristics of the new span. More importantly, data is always extracted from the same original time-series database, and the same backtracking window length and filtering logic for selecting the closest timestamp data are used as in the initial query. This completely eliminates the problem of data inconsistency at the same physical moment caused by differences in data sources or changes in calculation rules in traditional span switching, providing a reliable basis for cross-span comparative analysis by operations and maintenance personnel. Meanwhile, there is no need to pre-store multi-span sampling data. By adjusting sampling parameters in real time and reusing core filtering rules, the query latency during span switching is greatly shortened, avoiding user waiting. Finally, the trend chart data generated by sorting by time can completely and accurately reflect the change trajectory of monitoring indicators within the new span.
[0069] In another embodiment, a time-series data query system is also disclosed, comprising: an instruction receiving module, a sampling time generation module, and a sampling data acquisition module. The instruction receiving module receives a target query time span input by a user, the target query time span including a start time and an end time. The sampling time generation module calculates the sampling point time interval and generates a first sampling time list based on a comparison of the target query time span with a preset time span threshold. The sampling data acquisition module, according to the acquired backtracking window's backtracking time length, extracts all original data values from the original time-series database for each sampling time from the sampling time to the previous backtracking time length, selects the original data value with the timestamp closest to the sampling time as the target data value for that sampling time, and generates trend chart data within the required query time span by sorting the target data values of all sampling times by time.
[0070] In this embodiment, the sampling time generation module specifically includes a first list generation module and a second list generation module. The first list generation module is used to obtain the current sampling point time interval based on a first sampling density when the target query time span is not greater than the preset time span threshold, and generate a first sampling time interval list for the target query time span based on the current sampling point time interval. The second list generation module is used to determine the corresponding current sampling point time interval based on the ratio between the target query time span and the preset time span threshold when the target query time span is greater than the preset time span threshold, and generate a first sampling time interval list for the target query time span based on the current sampling point time interval.
[0071] In this embodiment, the second list generation module is further configured to: round up the ratio of the target query time span to a preset time span threshold to obtain the current sampling point time interval; round up the ratio of the current target query time span to the current sampling point time interval and add one to obtain the number of sampling points applicable to the current target query time span; and generate a first sampling time list for the current target query time span based on the number of sampling points and the sampling point time interval.
[0072] The functions of the aforementioned time-series data query system basically correspond to the steps of the time-series data query method disclosed in the previous embodiments, so they will not be described in detail here. For details, please refer to the embodiments of the time-series data query method disclosed above. It should be noted that the embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other.
[0073] In other embodiments, a server is also disclosed, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the various steps of the timing data query method described in the above embodiments. The processor may be a central processing unit, or other general-purpose processors, digital signal processors, application-specific integrated circuits (ASICs), off-the-shelf programmable gate arrays (OPGs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc. The processor is the control center of the server device, connecting various parts of the entire server device via various interfaces and lines. The memory can be used to store the computer program and / or modules. The processor implements various functions of the server device by running or executing the computer program and / or modules stored in the memory, and by calling data stored in the memory. The memory may mainly include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function, etc. Furthermore, the memory may include high-speed random access memory (RAM) and non-volatile memory, etc.
[0074] If the time-series data query method is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments of the present invention can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a portable hard drive, a magnetic disk, an optical disk, a computer memory, etc.
[0075] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
[0076] In summary, the above description is only a preferred embodiment of the present invention. All equivalent changes and modifications made within the scope of the claims of the present invention should be covered by the present invention.
Claims
1. A time-series data query method, characterized in that, Includes the following steps: Receive the target query time span input by the user, wherein the target query time span includes the start time and the end time; Based on the target query time span and the size of the preset time span threshold, the sampling point time interval is calculated and a list of first sampling times is generated; Obtain the backtracking time length of the backtracking window. For each sampling moment, extract all original data values from the original time series database up to the previous backtracking time length from the sampling moment. Select the original data value whose timestamp is closest to the sampling moment as the target data value for that sampling moment. Sort the target data values of all sampling moments by time to generate trend chart data within the required query time span.
2. The time-series data query method according to claim 1, characterized in that, Based on the target query time span and the preset time span threshold, the sampling point time interval is calculated and a first sampling time list is generated, specifically including: If the target query time span is not greater than the preset time span threshold, then the current sampling point time interval is obtained according to the first sampling density, and a first sampling time list for the target query time span is generated based on the current sampling point time interval. If the target query time span is greater than the preset time span threshold, the corresponding current sampling point time interval is determined according to the ratio between the target query time span and the preset time span threshold, and a first sampling time list for the target query time span is generated based on the current sampling point time interval.
3. The time-series data query method according to claim 2, characterized in that, The corresponding current sampling point time interval is determined based on the ratio between the target query time span and the preset time span threshold, and a list of first sampling moments within the target query time span is generated based on the current sampling point time interval, specifically including: The current sampling time interval is obtained by rounding up the ratio of the target query time span to the preset time span threshold. The ratio of the current target query time span to the current sampling point time interval is rounded up and then incremented by one to obtain the number of sampling points applicable to the current target query time span; A list of first sampling moments for the current target query time span is generated based on the number of sampling points and the sampling point time interval.
4. The time-series data query method according to claim 3, characterized in that, Also includes: After receiving the user's input instruction to switch the time span, the start and end times of the new time span in the instruction are parsed to obtain the new query time span to be switched to; Based on the comparison of the new query time span with the preset time span threshold, the sampling point time interval is modified and a second sampling time list is generated; For each new sampling time in the second sampling time list, extract all original data values from the same original time series database up to the same backward time length from that sampling time, and select the original data value whose timestamp is closest to the sampling time as the target data value for the new sampling time; after sorting all the target data values of the new sampling times by time, generate the trend chart data within the new query time span to be switched.
5. The time-series data query method according to claim 4, characterized in that: The backtracking time length of the backtracking window is determined based on the original update cycle of the target time series data to be queried, as input by the user.
6. A time-series data query system, characterized in that, include: The instruction receiving module is used to receive the target query time span input by the user, wherein the target query time span includes the start time and the end time; The sampling time generation module is used to calculate the sampling point time interval and generate a first sampling time list based on the target query time span and the size of the preset time span threshold. The sampling data acquisition module is used to extract all original data values from the original time series database for each sampling time according to the backtracking time length of the acquired backtracking window, and select the original data value whose timestamp is closest to the sampling time as the target data value for that sampling time; after sorting the target data values of all sampling times by time, it generates trend chart data within the required query time span.
7. The time-series data query system according to claim 6, characterized in that, The sampling time generation module specifically includes: The first list generation module is used to obtain the current sampling point time interval according to the first sampling density when the target query time span is not greater than the preset time span threshold, and generate a first sampling time list for the target query time span based on the current sampling point time interval. The second list generation module is used to determine the corresponding current sampling point time interval based on the ratio between the target query time span and the preset time span threshold when the target query time span is greater than the preset time span threshold, and to generate a first sampling time list for the target query time span based on the current sampling point time interval.
8. The time-series data query system according to claim 7, characterized in that, The second list generation module is further configured to: round up the ratio of the target query time span to a preset time span threshold to obtain the current sampling point time interval; round up the ratio of the current target query time span to the current sampling point time interval and add one to obtain the number of sampling points applicable to the current target query time span; and generate a first sampling time list for the current target query time span based on the number of sampling points and the sampling point time interval.
9. A server, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, it implements the steps of the method as described in any one of claims 1-5.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, it implements the steps of the method as described in any one of claims 1-5.