A real-time update method for data assets under database table changes
By partitioning the database and setting update priorities, real-time monitoring and updating of data table changes solves the problem in the existing technology of being unable to real-time monitor and update of database table changes, achieving data accuracy and timeliness, and reducing resource consumption. and manual intervention costs.
Patent Information
- Application Number
- CN202410866175.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-01
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2044-07-01
AI Technical Summary
Existing technology cannot monitor dynamic changes in database tables in real time and update data in a timely manner, resulting in data inaccuracy and timeliness issues, and cannot adapt to business decision-making and operational needs in a big data environment.
By partitioning the database and setting update priorities, real-time monitoring of data table changes is performed, and data updates are performed using temporary storage areas and counting strategies to ensure that data and database tables are synchronized and resource consumption is reduced.
It realizes real-time monitoring and dynamic updating of database tables, ensuring data accuracy and timeliness, reducing manual intervention costs, improving efficiency, and saving time and resources.
Smart Images

Figure CN118394772B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of database technology, and in particular to a method for real-time updating of data assets when a database table changes. Background Art
[0002] In the era of big data, data is constantly emerging and growing exponentially, making data the core value of organizations and enterprises. Database management systems (DBMS) play a key role in storing, managing, and providing access to these massive amounts of data. However, existing database management systems are mainly designed for static or fixed table structures and cannot adapt to dynamic changes in database tables.
[0003] Traditional data collection methods are usually based on fixed collection strategies and structures, and cannot adapt to changes in metadata of database tables in real time, resulting in inconsistencies between the collected metadata and the actual database, reducing the accuracy and timeliness of the data. Especially in a big data environment, this untimely and inaccurate data collection will have a serious impact on business decisions and operations.
[0004] Chinese patent application publication number: CN117971848A discloses a database update method and device, a computer-readable storage medium and an electronic device. The database update method includes: dividing the database data into multiple data groups according to the operation cycle, and there is no data dependency relationship between the data groups; parsing the operation information of updating the database into individual field operations, and determining the processing priority of each field operation according to the operation type; aggregating the field operations corresponding to the same data group according to the processing priority, so that each data group obtains a queue including data operations with different processing priorities; and executing each queue concurrently to update the database data according to the execution results. The disclosure can improve the efficiency of database update and maintenance.
[0005] Chinese Patent Authorization Announcement No.: CN114048269B discloses a method and device for synchronously updating metadata in a distributed database. The distributed database includes multiple database nodes, wherein the first node stores the first master copy of the target replication table, and the remaining multiple second nodes store the first backup copy of the target replication table, and a full synchronization protocol is used between the first master copy and the first backup copy. The first node can receive an update request related to the first metadata of the first data table in the distributed database, and write the update information related to the first metadata to the first master copy according to the update request, so that the update information is synchronized to the first backup copies of the multiple second nodes based on the full synchronization protocol, so that the multiple second nodes can obtain the updated data of the first metadata according to the update information when using the first metadata.
[0006] Therefore, the existing technology cannot meet the requirements of real-time, dynamic and efficient monitoring of database table changes and instant data update. The present invention aims to solve these problems and provide a real-time data update method for dynamic changes in database tables to ensure that data and database tables remain synchronized.
[0007] Traditional data collection methods cannot monitor the dynamic changes of database tables in real time and update the corresponding data in time after the table changes. The current database management system and data collection technology are mainly oriented to fixed table structures and are difficult to adapt to dynamically changing database tables.
[0008] Existing technologies cannot provide a solution to monitor database table changes in real time, dynamically and efficiently and update data instantly. This highlights the urgent need for innovative methods to achieve real-time updates of data under database table changes in the era of big data. Summary of the invention
[0009] To this end, the present invention provides a real-time update method for data assets under database table changes, which is used to overcome the problem in the prior art that traditional data acquisition methods cannot monitor the dynamic changes of database tables in real time, and cannot update corresponding data immediately, resulting in the inability to ensure the accuracy and timeliness of data, thereby leading to the waste of database update resources.
[0010] To achieve the above object, the present invention provides a method for real-time updating of data assets under database table changes, comprising:
[0011] Set up several partitions of the database according to the data source;
[0012] Get the usage frequency of the corresponding data source in each partition within a single update cycle;
[0013] Setting the update priority of the corresponding partition according to the usage frequency and generating a corresponding ranking;
[0014] According to the order, a temporary storage area is set and associated with a corresponding partition;
[0015] The temporary storage area responds to the data table change instruction and updates the corresponding partition according to the partition association at the end of a single update cycle, and determines the new usage frequency of the corresponding data source in each partition during the update cycle;
[0016] Resetting the order of each partition according to the new usage frequency;
[0017] The partition is related to the type of database. For a single partition, the corresponding data can be completely read in the database.
[0018] The sorting is performed in ascending order according to the update priority;
[0019] The data table change instruction includes several operations on the assets in the database.
[0020] Furthermore, the process of setting the plurality of partitions includes:
[0021] determining a number of data sources for the database;
[0022] According to the data source, the database is set to a plurality of areas corresponding to the data source;
[0023] Among them, for a single area, it corresponds to a single data source.
[0024] Furthermore, when obtaining the usage frequency, the items pointing to the corresponding partition are recorded within the update period, and a counting strategy is set outside the database;
[0025] Wherein, the counting strategy responds to a single excitation item and performs cumulative counting on the partitions corresponding to the item;
[0026] The single-shot triggering project is a project identified by the database as being executable.
[0027] Further, for a single partition, when the database establishes the temporary storage area according to the update priority, the asset changes in the partition are stored in the corresponding temporary storage area;
[0028] The temporary storage area updates the asset changes to the corresponding partition in response to the update cycle.
[0029] Further, at the end of the single update cycle, each partition that is to be changed is independently set in the database, and,
[0030] When the number of updates reaches a threshold, the partition that has not been changed is set to read-only.
[0031] Furthermore, when setting the update priority for each partition, a detection strategy for collecting database table or database changes is also provided according to the database table;
[0032] The detection strategy responds to a number of operations on the database table and uses the results of the operations to update the partition, and,
[0033] Respond to several operations on the database, and use the results of the operations at the end of the update cycle to set the update priority of the corresponding partition in the next update cycle.
[0034] Furthermore, for the single update cycle, the cumulative counts and final change results of each partition in the current update cycle are recorded according to the detection strategy, and the final change results are output to the corresponding partitions at the end of the current update cycle, and the update priority is set according to the cumulative counts.
[0035] Furthermore, the process of resetting each partition includes:
[0036] Sort the partitions according to the accumulated counts;
[0037] Mark the partitions that have changed;
[0038] Push into stack in the order described;
[0039] Each partition that has changed is popped out of the stack according to the above order and re-ordered.
[0040] Further, for a single partition in a single update cycle, the detection strategy also provides a temporary storage area for the partition;
[0041] The capacity of the temporary storage area is proportional to the corresponding partition.
[0042] Furthermore, after resetting each partition according to the new usage frequency, the method further includes:
[0043] The activation status of each partition is monitored at a preset inspection cycle, and the inactivated partitions are named in order.
[0044] Compared with the prior art, the beneficial effect of the present invention lies in that, by partitioning the database and setting priorities for each database partition, the data in the database is divided and corresponding update methods are set, which effectively improves the response speed of the database data and effectively saves the resource consumption of database updates.
[0045] Furthermore, by recording project changes, the database is recorded, which effectively saves the resources consumed by database changes and saves the computing power of data calls, thereby further saving resource consumption for database updates.
[0046] Furthermore, by solidifying data assets that have not changed for a long time, the reading speed of the corresponding data assets is improved, which effectively reduces the capacity of readable and writable data assets and saves read and write space, thereby further saving resource consumption for database updates.
[0047] Furthermore, by setting the update priority, each partition in the database is recorded and adjusted accordingly, which effectively improves the utilization rate of data assets and avoids data loss caused by changes in data tables, thereby further saving resource consumption for database updates.
[0048] Furthermore, by setting up temporary storage to make centralized changes to the database, the risk of data assets caused by real-time changes to the database is avoided, and the resource consumption of database updates is further saved.
[0049] In particular, the present invention can also:
[0050] (1) Real-time update: The present invention can monitor the changes in the database table in real time and update the corresponding data immediately to ensure the accuracy and timeliness of the data.
[0051] (2) Dynamic adaptability: Through real-time monitoring and dynamic updating, the present invention can adapt to dynamic changes in database table metadata and keep data synchronized with the database table.
[0052] (3) Reduce costs: The automated data update process reduces the cost of manual intervention, improves efficiency, and saves time and resources for the enterprise. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] Figure 1 It is a flow chart of the method for real-time updating of data assets when the database table changes according to the present invention;
[0054] Figure 2 A flowchart for setting update priority for an embodiment of the present invention;
[0055] Figure 3 A schematic diagram of the structure of real-time data update when a database table changes according to an embodiment of the present invention;
[0056] Figure 4 The figure is a schematic diagram of the real-time data update process when the database table changes according to an embodiment of the present invention. DETAILED DESCRIPTION
[0057] In order to make the objects and advantages of the present invention more clearly understood, the present invention is further described below in conjunction with embodiments; it should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0058] The preferred embodiments of the present invention are described below with reference to the accompanying drawings. It should be understood by those skilled in the art that these embodiments are only used to explain the technical principles of the present invention and are not intended to limit the protection scope of the present invention.
[0059] It should be noted that, in the description of the present invention, terms such as "up", "down", "left", "right", "inside" and "outside" indicating directions or positional relationships are based on the directions or positional relationships shown in the drawings. This is merely for the convenience of description and does not indicate or imply that the device or element must have a specific orientation, be constructed and operated in a specific orientation. Therefore, it cannot be understood as a limitation on the present invention.
[0060] In addition, it should be noted that in the description of the present invention, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal communication of two components. For those skilled in the art, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0061] See also Figure 1 As shown, it is a flow chart of the method for real-time updating of data assets under database table changes of the present invention, including:
[0062] Step S1, setting several partitions of the database according to the data source;
[0063] Step S2, obtaining the usage frequency of the corresponding data source in each partition within a single update cycle;
[0064] Step S3, setting the update priority of the corresponding partition according to the usage frequency, and generating the corresponding ranking;
[0065] Step S4, setting a temporary storage area according to the sorting and associating it with the corresponding partition;
[0066] Step S5, the temporary storage area responds to the data table change instruction, and updates the corresponding partition according to the partition association at the end of a single update cycle, and determines the new usage frequency of the update cycle;
[0067] Step S6, resetting each partition according to the new usage frequency;
[0068] The partition is related to the type of database. For a single partition, the corresponding data can be fully read in the database.
[0069] The sorting is in ascending order according to the update priority;
[0070] The data table change instruction includes several operations on the assets in the database.
[0071] Specifically, the process of setting the plurality of partitions includes:
[0072] determining a number of data sources for the database;
[0073] According to the data source, the database is set to a plurality of areas corresponding to the data source;
[0074] Among them, for a single area, it corresponds to a single data source.
[0075] Specifically, when obtaining the usage frequency, the items pointing to the corresponding partition are recorded during the update cycle, and a counting strategy is set outside the database;
[0076] The counting strategy responds to a single excitation item and accumulates the counts of the partitions corresponding to the item;
[0077] Single-shot projects are projects that the database identifies as being implementable.
[0078] By recording project changes, the database is recorded, which effectively saves the resources consumed by database changes and saves the computing power of data calls, thereby further saving resource consumption for database updates.
[0079] Specifically, for a single partition, the database stores the asset changes in the partition in the corresponding temporary storage area according to when the temporary storage area is established;
[0080] The temporary storage area updates asset changes to the corresponding partitions in response to the update cycle.
[0081] Specifically, at the end of a single update cycle, each partition that is subject to change is set independently in the database, and,
[0082] When the update count threshold is reached, the unchanged partitions are set to read-only.
[0083] By solidifying data assets that have not changed for a long time, the reading speed of the corresponding data assets is improved, which effectively reduces the capacity of readable and writable data assets and saves read and write space, thereby further saving resource consumption for database updates.
[0084] Specifically, when setting the update priority for each partition, a detection strategy for collecting database table or database changes is also provided according to the database table;
[0085] The detection strategy responds to some operation on the database table and uses the result of the operation to update the partition, and,
[0086] Respond to several operations on the database, and use the results of the operations at the end of the update cycle to set the update priority of the corresponding partition in the next update cycle.
[0087] Specifically, for a single update cycle, the detection strategy records the cumulative counts and final change results of each partition within the update cycle, and outputs the final change results to the corresponding partition at the end of the update cycle, and,
[0088] Set the update priority based on the accumulated count.
[0089] See also Figure 2 As shown, it is a flow chart of setting the update priority according to an embodiment of the present invention, when the update priority is set according to the accumulated count, it includes:
[0090] Step St1, sorting each partition according to the accumulated count;
[0091] Step St2, marking each partition that has changed;
[0092] Step St3, stack in order.
[0093] By setting the update priority, each partition in the database is recorded and adjusted accordingly, which effectively improves the utilization rate of data assets and avoids data loss caused by changes in data tables, thereby further saving resource consumption for database updates.
[0094] Specifically, for a single partition in a single update cycle, the detection strategy also has a temporary storage area for the partition;
[0095] The capacity of the temporary storage area is proportional to the corresponding partition.
[0096] By setting up temporary storage to make centralized changes to the database, we can avoid the data asset risks caused by real-time changes to the database and further save resource consumption for database updates.
[0097] Specifically, it also includes:
[0098] Step S7, monitoring the activation status of each partition at a preset inspection cycle, and sequentially calling out the inactivated partitions.
[0099] The present invention provides a detection middleware, which realizes real-time monitoring of database tables and dynamic updating of data through data source identification, monitoring, data and metadata analysis and change notification modules.
[0100] Using the above method, in implementation:
[0101] 1. Identify the database tables that need to be monitored through the data source identification module and link them according to the database type.
[0102] 2. Use the monitoring module to monitor the structure and data of the database table in real time and detect changes. The monitoring module can record the timestamp of the last monitored database table status and compare it with the current status. If the two timestamps are inconsistent, it means that the database table has changed, and the log content can be analyzed to determine whether there are changes in structure or data. Both methods are suitable for various databases.
[0103] 3. The data and metadata analysis module analyzes the data and metadata of the database table to obtain change information. Once a change in the database table is detected, a notification is sent through the change notification module to trigger real-time update of the data.
[0104] 4. Intelligent data source identification and monitoring: Introduce machine learning algorithms to realize intelligent data source identification and monitoring modules. Through the learning and pattern recognition of historical data, the system can automatically identify the database tables that need to be monitored, improving the intelligence level and adaptive ability of monitoring.
[0105] 5. Monitoring module based on machine learning: Combined with machine learning technology, a prediction model for database table changes is established to achieve intelligent analysis and early warning of change behaviors. The monitoring module can accurately predict the possibility of data changes, effectively reduce false positives and false negatives, and improve the accuracy and efficiency of monitoring.
[0106] 6. Event-driven real-time change notification: Introducing an event-driven architecture, the change notification module is designed as an asynchronous event processing system. When the monitoring module detects a change in the database table, it immediately triggers the corresponding event, and implements real-time change notification and processing through an event-driven mechanism, improving the system's response speed and real-time performance.
[0107] See also Figure 3 and Figure 4 As shown, they are respectively a structural schematic diagram of real-time data update under database table changes according to an embodiment of the present invention and a schematic diagram of the real-time data update process under database table changes according to an embodiment of the present invention.
[0108] The present invention can be used for adapting various data sources:
[0109] First, use the data source identification module to identify the various database tables that need to be monitored. The conditions for whether to monitor are configured in the conf configuration file. Add the configuration to monitor. These database tables may come from different data sources and may have different data formats and structures. Through data source adaptation, ensure that the database tables in various data sources can be identified and monitored. After the various data sources are adapted, the system will print log records, maintain a long connection to the monitored database, and output the monitoring process.
[0110] Embodiment 1:
[0111] This embodiment is applied to data management of online retail business;
[0112] In an online retail business, data includes product information, order data, user information, etc. These data may be stored in different data sources. Assume that the system needs to monitor three key data tables: product information, order data, and user information.
[0113] 1. Data source:
[0114] Product information table: stored in the enterprise's relational database (such as MySQL).
[0115] Order data table: Stored in the cloud service provider's NoSQL database (such as MongoDB).
[0116] User information table: stored in the enterprise's custom file storage system.
[0117] 2. Data source adaptation:
[0118] For the product information table, the database connection information and monitoring conditions are specified through the configuration file, so that the system can adapt to the MySQL database and realize real-time monitoring of the product information table.
[0119] For the order data table, set the corresponding connection information and monitoring conditions through the configuration file, adapt the MongoDB database, and ensure that the order data table can be monitored.
[0120] The user information table specifies the connection information through the configuration file and adapts to the custom file storage system to realize the monitoring of the user information table.
[0121] 3. Monitoring process:
[0122] The configuration file contains the monitoring conditions for the three tables. After the system is started, the data source identification module establishes a connection according to the configuration and starts monitoring the database tables in the three data sources.
[0123] The system will regularly check tables that meet the monitoring conditions, maintain a long connection with the database table, and record relevant logs for debugging and monitoring.
[0124] Embodiment 2:
[0125] This embodiment is data source adaptation;
[0126] 1. Relational database (such as MySQL):
[0127] Adaptation steps:
[0128] Configuration file settings: Specify database connection information in the configuration file, including database type, host address, port, user name, password, etc.
[0129] [MySQLDataSource]
[0130] type = MySQL
[0131] host = localhost
[0132] port = 3306
[0133] username = username
[0134] password = password
[0135] database = database
[0136] Data source adapter module: Write a data source adapter module to establish a connection with the MySQL database based on the information in the configuration file and perform related monitoring and data acquisition operations.
[0137] 2. NoSQL databases (such as MongoDB):
[0138] Adaptation steps:
[0139] Configuration file settings: Specify the MongoDB connection information in the configuration file, including the host address, port, user name, password, etc.
[0140] [MongoDBDataSource]
[0141] type = MongoDB
[0142] host = localhost
[0143] port = 27017
[0144] username = username
[0145] password = password
[0146] database = database
[0147] Data source adapter module: Write a data source adapter module to establish a connection with the MongoDB database based on the information in the configuration file and perform related monitoring and data acquisition operations.
[0148] 3. File system:
[0149] Adaptation steps:
[0150] Configuration file settings: Specify the file system path and format and other information in the configuration file.
[0151] [FileSystemDataSource]
[0152] type = FileSystem
[0153] path = / path / to / your / files
[0154] format = CSV
[0155] Data source adapter module: Write a data source adapter module to read the data in the file system according to the information in the configuration file to implement monitoring and data acquisition operations.
[0156] Log parsing: Log parsing technology is used to monitor the changes in database tables in real time through the monitoring module. Database systems often record database operation logs, including changes to table structures. By parsing these logs, changes in database tables can be detected in a timely manner. The parsing process is as follows:
[0157] 1. After the system establishes a connection with the server database, it captures the database operation log. The database management system usually records various operations on the database, including changes in the table structure and the addition, deletion and modification of data. The log is usually stored in a specific format, such as a binary log file or a text file.
[0158] 2. Once the database operation log is obtained, the parsing module begins parsing the log records. This includes identifying the type of log records, such as DDL (Data Definition Language) records, DML (Data Manipulation Language) records, etc.
[0159] 3. The parsing module extracts information related to changes in the database table. For DDL records, this may include changes in the table structure, such as the addition, deletion, modification of columns, changes in indexes, etc. For DML records, this may include the addition, deletion, and update of data.
[0160] 4. The parsing module will compare the status before and after the change to determine the specific content of the change. This may involve the table structure, number of data rows, field values, timestamps, etc. before and after the comparison. If there is a difference, it can be confirmed that a change has occurred.
[0161] 5. Once a change is confirmed, the parsing module can record the corresponding events, such as timestamp, change type (DDL or DML), specific content of the change, etc.
[0162] Comparative Example 1: Database table change monitoring for online retail business;
[0163] Taking Example 1 as a benchmark, in the above online retail business, we need to monitor the structural changes and data changes of the database table.
[0164] 1. Database operation log:
[0165] For the product information table, the database system records the DDL log, including changes in the table structure (such as the addition of a new product attribute field).
[0166] The database system of the order data table records the DML log, including the addition, deletion, and modification operations of the order data.
[0167] Since the user information table is stored in the file system, there may be no direct database operation log, so other means may be needed to monitor it.
[0168] 2. Monitoring and analysis process:
[0169] After the system establishes a connection with the database, it captures database operation logs periodically.
[0170] The log parsing module extracts relevant information based on the type of log record. For DDL records, it extracts information about changes in the table structure; for DML records, it extracts information about data changes.
[0171] The parsing module compares the status before and after the change, such as the table structure, number of data rows, field values, etc. before and after the comparison, to determine the specific content of the change.
[0172] Once a change is confirmed, the parsing module records the corresponding event, including the timestamp, change type, and specific content of the change.
[0173] Metadata update: Use the metadata parsing module to parse the metadata of the database table and obtain change information, which includes: changes in table structure - addition, deletion, modification, index change, etc., data changes - addition, deletion, update, etc. Monitor changes in the database table, send notifications through the change notification module, and trigger real-time updates of the data. During the update process, according to the metadata information obtained by parsing, the data is updated accordingly to ensure synchronization with the database table.
[0174] In implementation, the present invention can also process large-scale data and improve the algorithms and technologies of monitoring efficiency:
[0175] 1. Incremental monitoring:
[0176] Anomaly detection method based on machine learning. This method uses machine learning models to train data, and then monitors by detecting abnormal behavior of the data, thereby improving monitoring efficiency and accuracy.
[0177] Working principle:
[0178] Use historical data to train machine learning models, such as using supervised learning or unsupervised learning algorithms.
[0179] The trained model can recognize patterns in normal data and detect anomalous data or events that do not fit the normal patterns.
[0180] Embodiment 3:
[0181] a) Unsupervised Learning Model
[0182] The historical data are clustered using the K-means clustering algorithm to divide the data points into multiple clusters.
[0183] For new data, the distance or similarity between it and each cluster is calculated to determine whether it belongs to an abnormal cluster.
[0184] b) Supervised learning model:
[0185] Train an anomaly detection model using supervised learning algorithms such as random forests, support vector machines, etc.
[0186] Label historical data as normal or abnormal samples and train models to identify anomalies in new data.
[0187] Advantages and application scenarios:
[0188] Improve monitoring efficiency: Machine learning models are able to learn complex data patterns to detect anomalies more accurately, avoiding the limitations of traditional incremental monitoring.
[0189] Applicable to complex environments: Applicable to monitoring needs in large-scale data or complex data environments, such as network traffic, database operations, etc.
[0190] 2. Efficient data structure and index:
[0191] Adaptive index optimization is used to achieve dynamic adjustment of data structure and index, dynamically optimizing database index according to actual data access mode and workload to improve query performance and reduce maintenance cost. Compared with traditional static index, this optimization strategy has higher flexibility and adaptability, and can automatically adjust index to adapt to changing data environment.
[0192] By using the above method, it is possible to achieve:
[0193] a) Real-time data monitoring: Adaptive index optimization requires real-time monitoring of data access patterns and query requests in the database. The characteristics and trends of data access are understood by collecting and analyzing actual data access patterns, including frequency, range, sequence, and other information.
[0194] b) Dynamic index adjustment: Dynamically adjust the database index structure based on real-time monitored data access patterns. For example, add or delete indexes for specific fields, adjust index types or index parameters to optimize query performance and response time.
[0195] c) Intelligent optimization strategy: Develop an intelligent index optimization strategy to select the appropriate index configuration based on different data characteristics and workloads. This may involve using different index types (such as B-tree, hash index, full-text index, etc.) or optimizing index parameters (such as fill factor, block size, etc.).
[0196] d) Adaptive adjustment: Index optimization strategies should be adaptive and able to automatically adapt to changes in data and workload. For example, when data distribution or access patterns change, adaptive index optimization can adjust the index structure in a timely manner to ensure stable and efficient query performance.
[0197] e) Performance evaluation and monitoring: After implementing adaptive index optimization, it is necessary to continuously evaluate and monitor the performance and effect of the index. By regularly collecting and analyzing the performance indicators of the index, the optimization strategy can be adjusted in a timely manner to ensure the high performance and stability of the database system.
[0198] f) Actual application scenarios: Adaptive index optimization is suitable for application scenarios with high query performance requirements and constantly changing data access patterns, such as product search in e-commerce platforms, user relationship query in social networks, and real-time data analysis in IoT systems.
[0199] 3. Parallel processing:
[0200] Parallelize the monitoring and analysis process to process multiple data sources or multiple change events simultaneously to increase the overall processing speed.
[0201] Embodiment 4:
[0202] Use multi-threaded or distributed architecture to monitor multiple data sources simultaneously, assign monitoring and analysis tasks to different processing units, and improve processing efficiency.
[0203] 4. Event-based triggering mechanism:
[0204] Irregular polling may lead to unnecessary performance overhead. Use an event-based trigger mechanism to trigger monitoring and update operations only when changes occur.
[0205] Working principle:
[0206] a) Event-driven mechanism: The event-based trigger mechanism is to subscribe to or listen to specific events in the system instead of regularly polling data changes. When an event occurs, the system will immediately trigger the corresponding processing flow, thereby achieving real-time response and processing.
[0207] b) System notification or trigger: Database systems or operating systems usually provide event notification mechanisms or trigger functions that can trigger related operations when specific events occur. These events can be data updates, file changes, network messages, etc.
[0208] c) No need for polling: Unlike regular polling, event-based triggering does not require regular querying or scanning of data sources. Instead, the system receives notifications when events occur and immediately processes them accordingly, avoiding unnecessary resource waste and delays.
[0209] Embodiment 5:
[0210] a) Database triggers: In relational databases, triggers can be used to define actions that are triggered when specific data operations (such as insert, update, and delete) occur. For example, when a database table is updated, a trigger can automatically trigger monitoring and update operations without the need for regular polling.
[0211] b) File system monitoring: The operating system provides a file system monitoring mechanism, such as inotify in Linux system, which can monitor file change events (such as file creation, modification, deletion, etc.). Applications can subscribe to these events and perform corresponding operations when events occur, without having to continuously poll the file status.
[0212] Its advantages are:
[0213] a) Real-time response: Event-based triggering mechanism enables real-time response and processing, avoiding the delay and resource waste caused by periodic polling.
[0214] b) Reduce system load: There is no need to continuously monitor or scan data sources, which saves system resources and reduces system load.
[0215] c) Improve efficiency: Event-driven processing enables the system to handle data changes more efficiently, improving the overall efficiency and performance of the system.
[0216] 5. Use compression algorithm:
[0217] For monitoring logs or large-scale data, the use of compression algorithms can reduce data transmission and storage overhead and improve efficiency. When transmitting monitoring logs, use compression algorithms (such as Gzip or Snappy) to compress the logs to reduce the amount of data transmission; when storing monitoring data, use column storage and compression algorithms to reduce storage space occupancy.
[0218] a) Application content:
[0219] Monitoring log compression: For the log data generated by the monitoring system, a compression algorithm is used to compress the log content. The logs generated by the monitoring system may contain a large amount of text information. Compression can reduce the size of the log file, saving storage space and transmission bandwidth.
[0220] Data transmission content compression: During the data asset monitoring process, if the monitoring data needs to be transmitted to other systems or stored on a remote server, a compression algorithm can be used to compress the data to reduce the amount of transmitted data and reduce network transmission costs and delays.
[0221] Storage data compression: For monitoring data that needs to be stored for a long time, a compression algorithm can be used to compress and store the data. The compressed data takes up less storage space, reduces storage costs, and can also improve data reading efficiency and access speed.
[0222] b) Compress content:
[0223] Log data generated by the monitoring system: The monitoring system will generate a large amount of log data to record various events, operations and results during the monitoring process. These log data can be compressed using compression algorithms (such as gzip, Snappy, etc.) to reduce the size of the log file and save storage space.
[0224] Transmitted monitoring data: During the monitoring process, the system may need to transmit the monitored data to other systems or remote servers for further processing or storage. The transmitted monitoring data can be compressed using a compression algorithm to reduce the size of the data transmission, reduce network bandwidth consumption and transmission delay.
[0225] c) Benefits of compression:
[0226] Save storage space: Compressing the log data generated by the monitoring system can significantly reduce storage space usage, save costs and extend the storage cycle.
[0227] Reduce network transmission volume: Compressing the transmitted monitoring data can reduce the data transmission volume and improve data transmission efficiency, which is especially suitable for environments with limited network bandwidth.
[0228] Speed up data transmission: The compressed data transmission speed is faster, which reduces the time cost of data transmission and improves data processing efficiency and real-time performance.
[0229] Improve system performance: Reducing the amount of data can reduce the system load and improve the overall performance and response speed of the system.
[0230] Ensure data security: Compressing data can enhance data security and reduce the risk of data leakage, especially playing a protective role during data transmission and storage.
[0231] Please continue reading Figure 3 As shown, in the application, you can build a data source adapter module, a detection middleware, and an asset update module respectively:
[0232] 1. Data source adaptation: The data source identification module is used to classify the database tables that need to be monitored. They are classified according to the database model into relational database, non-relational database, object-oriented database and XML database, and connections are established with the corresponding server databases.
[0233] 2. Real-time monitoring of database tables: Start the monitoring module to monitor the metadata of database tables in real time and detect changes.
[0234] 3. Parse metadata: Use the metadata parsing module to parse the metadata of the database table and obtain change information.
[0235] 4. Initiate real-time update notification: Once changes in the database table are detected, a notification is sent through the change notification module to trigger real-time update of the data.
[0236] 5. Update data in real time: Update data in real time according to the changed information and keep it synchronized with the database table.
[0237] Utilizing the above method, the present invention can:
[0238] (1) Real-time update: The present invention can monitor the changes in the database table in real time and update the corresponding data immediately to ensure the accuracy and timeliness of the data.
[0239] (2) Dynamic adaptability: Through real-time monitoring and dynamic updating, the present invention can adapt to dynamic changes in database table metadata and keep data synchronized with the database table.
[0240] (3) Reduce costs: The automated data update process reduces the cost of manual intervention, improves efficiency, and saves time and resources for the enterprise.
[0241] So far, the technical solutions of the present invention have been described in conjunction with the preferred embodiments shown in the accompanying drawings. However, it is easy for those skilled in the art to understand that the protection scope of the present invention is obviously not limited to these specific embodiments. Without departing from the principle of the present invention, those skilled in the art can make equivalent changes or substitutions to the relevant technical features, and the technical solutions after these changes or substitutions will fall within the protection scope of the present invention.
[0242] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for real-time updating of data assets under database table changes, characterized in that: include: Set up several partitions of the database according to the data source; Get the usage frequency of the corresponding data source in each partition within a single update cycle; Setting the update priority of the corresponding partition according to the usage frequency and generating a corresponding ranking; According to the order, a temporary storage area is set and associated with a corresponding partition; The temporary storage area responds to the data table change instruction and updates the corresponding partition according to the partition association at the end of a single update cycle, and determines the new usage frequency of the corresponding data source in each partition during the update cycle; Resetting the order of each partition according to the new usage frequency; The partition is related to the type of database. For a single partition, the corresponding data can be completely read in the database. The sorting is performed in ascending order according to the update priority; The data table change command includes several operations on the assets in the database; Wherein, for the single update cycle, the process of performing the plurality of operations is to record the accumulated counts and final change results of each partition in the current update cycle according to the detection strategy, and output the final change results to the corresponding partition at the end of the current update cycle; When obtaining the usage frequency, recording the items pointing to the corresponding partition within the update period, and setting a counting strategy outside the database; The counting strategy responds to a single excitation item and accumulates the counts of the partitions corresponding to the item; The single excitation project is a project identified by the database as being implementable; For a single partition, when the database establishes the temporary storage area according to the update priority, the asset changes in the partition are stored in the corresponding temporary storage area; The temporary storage area updates the asset changes to the corresponding partition in response to the update cycle.
2. The method for real-time updating of data assets under database table changes according to claim 1 is characterized in that: The process of setting the plurality of partitions includes: determining a number of data sources for the database; According to the data source, the database is set to a plurality of areas corresponding to the data source; Among them, for a single area, it corresponds to a single data source.
3. The method for real-time updating of data assets under database table changes according to claim 1 is characterized in that: At the end of the single update cycle, each partition that is to be changed is independently set in the database, and, When the number of updates reaches a threshold, the partition that has not been changed is set to read-only.
4. The method for real-time updating of data assets under database table changes according to claim 2 is characterized in that: When setting the update priority for each partition, a detection strategy for collecting database table or database changes is also provided according to the database table; The detection strategy responds to a number of operations on the database table and uses the results of the operations to update the partition, and, Respond to several operations on the database, and use the results of the operations at the end of the update cycle to set the update priority of the corresponding partition in the next update cycle.
5. The method for real-time updating of data assets under database table changes according to claim 4 is characterized in that: For the single update cycle, the update priority is set according to the accumulated count.
6. The method for real-time updating of data assets under database table changes according to claim 5 is characterized in that: The process of resetting each partition includes: Sort the partitions according to the accumulated counts; Mark the partitions that have changed; Push into stack in the order described; Each partition that has changed is popped out of the stack according to the above order and re-ordered.
7. The method for real-time updating of data assets under database table changes according to claim 6 is characterized in that: For a single partition in a single update cycle, the detection strategy also provides a temporary storage area for the partition; The capacity of the temporary storage area is proportional to the corresponding partition.
8. The method for real-time updating of data assets under database table changes according to any one of claims 5 to 7, characterized in that: After resetting each partition according to the new usage frequency, the method further includes: The activation status of each partition is monitored at a preset inspection cycle, and the inactivated partitions are named in order.
