A method for quickly generating the name of the primary key cascade relationship in a relational memory database

By using a two-level caching mechanism in a relational memory database to pre-generate and cache the primary key cascaded relationship names, the problems of repeated calculations and resource waste in traditional methods are solved, and fast response and efficient reference display are achieved.

CN115827695BActive Publication Date: 2025-07-18NARI TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211554783.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Priority Date
2022-11-17
Filing Date
2022-12-06
Publication Date
2025-07-18
Estimated Expiration
2042-12-06

AI Technical Summary

Technical Problem

The traditional real-time library primary key cascade relationship name generation method has repeated calculations and waste of resources during high-frequency access, resulting in the inability to respond to client calls quickly.

Method used

The two-level caching mechanism is adopted to pre-generate and cache the primary key cascaded relationship name of the relational memory database. It is read directly from the cache when the client accesses. The updated references are performed in the secondary cache to ensure the transparency and rapid response of client access.

Benefits of technology

It realizes the client's quick acquisition of primary key cascade relationship names, reduces the time of real-time calculation, and reduces the generation time from 120 seconds to 12 seconds, ensuring that the cache reconstruction time after online modification is less than 5 minutes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115827695B_ABST
    Figure CN115827695B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for quickly generating the primary key cascade relationship name of a relational in-memory database, which supports constructing a cache table for displaying primary key cascade references, configuring the relational in-memory database tables and fields that need to be cascaded and referenced, and establishing a cache for hot data as needed. According to the cascade reference table and domain structure provided by the configuration information, a table is created through an initialization program, and the data required for generating the reference display is downloaded from a commercial library. At the same time, the generated primary key cascade reference display is written into the cache; this method adopts a mechanism of two-level cache application. The first-level cache application provides access for clients, and data updates are only targeted at the second-level cache application, and it can ensure the data synchronization from the second-level cache application to the first-level cache application; two reference display cache update mechanisms, namely, real-time receiving of model modification messages and periodic refreshing, are provided, which support online modification of the number of cache tables and domains, and are transparent to client access during the cache update and table structure modification processes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the application of real-time database technology, and particularly to a method for quickly generating the primary key cascade relationship name of a relational in-memory database. Background Art

[0002] With the advancement of the pilot work of the new generation of power grid dispatching control system, the real-time operation data of the power grid is gradually officially connected, and various QT graphical interfaces, web pages, sampling query tools, and real-time database interface tools are gradually deployed and launched. The access to the primary key cascade relationship name of the real-time database is becoming increasingly frequent, and higher requirements are put forward for the generation efficiency of the real-time database reference display.

[0003] The traditional reference display is to extract online based on the configuration information of the real-time database table, perform multi-table queries according to the foreign key of the cascade relationship, and gradually obtain the reference display content for splicing to form a complete cascade relationship name. This method needs to be generated in real time each time it is called, and there are repeated calculations and resource waste during high-frequency access, resulting in the inability to quickly respond to client calls. Summary of the Invention

[0004] Object of the Invention: The object of the present invention is to provide a method for quickly generating the primary key cascade relationship name of a relational in-memory database, so as to pre-generate and cache the reference display content of the device table primary key and each reference display domain name of the device table, and extract it based on the cached method when the client accesses, replacing the method of real-time calculation generation.

[0005] Technical Solution: The method for quickly generating the primary key cascade relationship name of a relational in-memory database described in the present invention includes the following steps:

[0006] (1) Read the configuration information from the table information table and domain information table in the real-time database to determine the table structure of the reference display cache table.

[0007] (2) According to the table and domain structures provided by the configuration information, create a cascade reference cache table through the initialization program and download the data required for generating the reference display from the commercial database, and at the same time write the generated primary key cascade reference display name into the domain "ref_name" of the cascade reference cache table for caching;

[0008] (3) Create two-level reference display cache applications, and create cache tables for quickly generating reference displays in both the first-level cache application and the second-level cache application; when the client accesses the reference display, only request the data in the first-level cache application, and update the reference display cache on the second-level cache application, so as to avoid client access failure during the process of updating the reference display cache cycle;

[0009] (4) Provide two reference display cache update mechanisms: real-time update and periodic update. The real-time update is provided by the reference display modification service through real-time reception of model modification messages, and the periodic update is provided by the reference display access service. Both cache modification methods only update the reference display cache table in the secondary cache application, and at the same time, the "ref_name" reference display cache domain in the secondary cache application is periodically synchronized to the primary cache application, and the synchronization period is configurable;

[0010] (5) Sense whether the number of cache tables or domains has changed, and thus regenerate the reference display cache table in the secondary cache application for the new table structure, and the entire process is transparent to client access.

[0011] The configuration information described in step (1) is the table structure information of the reference display cache table.

[0012] A computer storage medium, on which a computer program is stored. When the computer program is executed by a processor, it implements the above-mentioned method for quickly generating the primary key cascade relationship name of a relational in-memory database.

[0013] A computer device, including a storage, a processor, and a computer program stored on the storage and executable on the processor. When the processor executes the computer program, it implements the above-mentioned method for quickly generating the primary key cascade relationship name of a relational in-memory database.

[0014] Beneficial effects: Compared with the prior art, the present invention has the following advantages: The method of the present invention creates two-level reference cache applications to cache the reference display of the primary key cascade relationship name of a relational in-memory database. The client no longer needs to calculate and generate the reference display in real time, and can directly read it from the cache according to the primary key; when the reference display is modified, the longest time period for the client to obtain the latest reference display from the primary cache application is less than 30 seconds; after online modification of the reference display cache configuration, the reconstruction time period of the reference display cache in the secondary cache is less than 5 minutes; through on-site test verification of the generation time of the primary key cascade relationship reference display of 500,000 telemetry messages, the traditional real-time calculation method takes 120 seconds, and the cache-based method takes 12 seconds. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] Figure 1 is the architecture design diagram for quickly generating the primary key cascade relationship name;

[0016] Figure 2 is the table structure diagram of the reference display cache table; wherein, Figure 2 (a) is the traditional data table structure, Figure 2 (b) is the reference display cache table structure;

[0017] Figure 3It is a flowchart for triggering and updating the reference display by receiving model modification messages;

[0018] Figure 4 It is a flowchart for periodically updating the reference display. Specific implementation manner

[0019] The technical solution of the present invention will be further described below in conjunction with the accompanying drawings.

[0020] As Figure 1 shown, a method for quickly generating the primary key cascade relationship name of a relational memory database according to the present invention includes the following steps:

[0021] (1) Read the configuration information from the table information table and domain information table in the real-time library to determine the table structure of the reference display cache table;

[0022] Read the configuration information of "is_ref_cache" in the real-time database table information table to determine the table that needs to be cached for reference display, and read the configuration information of "reference_flag" in the table that needs to be cached for reference display in the real-time library domain information table to determine the domain that needs to be cached.

[0023] As Figure 2 shown, for the table with reference display cache enabled, a "ref_name" field needs to be extended to store the calculated reference display name corresponding to the primary key. This field is only downloaded in the first-level cache application and second-level cache application of the reference display cache.

[0024] (2) Initialization of the reference display cache;

[0025] According to the table and domain structures provided in step (1), execute the initialization program rtdb_init_ref to create a cache table for quickly generating reference displays in the first-level cache application and second-level cache application of the PUBLIC_REF sub-scenario in the real-time library. At the same time, write the reference display of the primary key into the "ref_name" field in the traditional online generation method of reference display.

[0026] The initialization program rtdb_init_ref supports generating reference display caches by obtaining data from different data sources through parameters. The parameter "-db" is used to obtain data from the commercial library to generate reference display data, and the parameter "-rtdb" is used to obtain data from the second-level cache application of the PUBLIC_REF sub-scenario on the SCADA sub-scenario host to generate reference displays. This function can be used not only as a data initialization tool for reference display caches but also as a full recovery tool when data quality problems occur. When repairing, the data source can also be selected from the commercial library or the SCADA host for recovery.

[0027] (3) Update of the reference display cache data;

[0028] Reference display refresh includes two types: periodic update and trigger update, which are managed by the rtdb_modify_ref service.

[0029] (3.1) Trigger update

[0030] When the content of the reference domain changes, it needs to be synchronously updated by receiving the model modification message. The process of trigger maintenance for reference display is as follows Figure 3 shown below:

[0031] After receiving the model modification message, the reference display update service has three processing methods according to the message type:

[0032] ① Insert

[0033] a. Determine whether the table to be inserted is a reference display cache;

[0034] b. If not, return;

[0035] c. Determine whether the table has a reference display domain;

[0036] d. If not, return;

[0037] e. Parse the message, calculate the primary key and the domain value of the reference display domain according to the offset based on the structure of the reference display cache table, and write the newly added record into the corresponding table under the PUBLIC_REF sub-scenario secondary cache application;

[0038] f. Recursively generate the reference display content of the corresponding record according to the primary key cascade management, and update it to the corresponding cache table under the PUBLIC_REF sub-scenario secondary cache application.

[0039] ② Modify

[0040] a. Determine whether the table to be inserted is a reference display cache;

[0041] b. If not, return;

[0042] c. Determine whether the domain to be modified has a reference display set;

[0043] d. If not, return;

[0044] e. Parse the message, call the modification interface to write the modified domain value into the record of the corresponding table under the PUBLIC_REF sub-scenario secondary cache application, regenerate the primary key cascade relationship reference display of this record, and update the generated result to the ref_name domain;

[0045] f. Query all the table numbers and domain numbers in the domain information table that reference this table;

[0046] In the PUBLIC_REF sub-scenario secondary cache application, for each cache table, use the primary key of the modified record as the foreign key to filter out the corresponding records;

[0047] g. Regenerate the primary key cascade relationship reference display for these records and update it to the ref_name field of the cache table.

[0048] ③ Delete

[0049] a. Determine whether the table to be deleted references the display cache;

[0050] b. If not, return;

[0051] c. Parse the message to obtain the primary key of the device table to be deleted, and delete the records in the corresponding cache table under the PUBLIC_REF sub-scenario secondary cache application;

[0052] d. Since the devices are deleted from bottom to top, downward recursive update of the reference display cache is not considered here.

[0053] (3.2) Periodic update

[0054] Considering abnormal situations such as data request changes or message loss during the process of triggering updates to the reference display cache, a periodic update mechanism is added to provide backup for abnormal situations during the trigger update process. By creating a background thread in the reference display access service rtdb_server_ref and periodically calling the rtdb_init_ref program, the "ref_name" field of each table under the PUBLIC_REF sub-scenario secondary cache application is updated periodically. The update period can be configured and specified through input parameters, as follows Figure 4 shown.

[0055] The SCADA host synchronizes from the commercial library and executes "rtdb_init_ref - db"; other application servers synchronize the reference display cache table from the SCADA host and execute "rtdb_init_ref - rtdb". Through the mechanism that the host is consistent with the relational database and the standby is consistent with the host, the consistency and integrity of the reference display names under the public_ref sub-scenario secondary cache application on each application server are ensured.

[0056] (4) Update of ref_name under the first-level cache;

[0057] The cache modification service rtdb_modify_ref only updates the reference display cache table in the secondary cache. The reference display name field "ref_name" in the primary cache application is synchronized from the secondary cache application. By creating a background thread in rtdb_modify_ref, "rtdb_init_ref-sync" is executed every 30 seconds to synchronize the "ref_name" reference display cache field in the secondary cache to the primary cache.

[0058] (5) Modify the reference display cache configuration online;

[0059] During system operation, it is sometimes necessary to modify the number of reference display tables or fields. rtdb_server_ref will verify whether the configuration of the reference display cache has been modified when updating the secondary cache application in each cycle, so as to sense the change and regenerate the reference display cache table in the secondary cache application for the new table structure.

Claims

1. A method for quickly generating the name of the primary key cascade relationship in a relational memory database, characterized in that, It includes the following steps: (1) Read the configuration information from the table information table and domain information table in the real-time library, and determine the table structure of the cascading reference display cache table; (2) According to the table and domain structures provided by the configuration information, create a cascading reference cache table through the initialization program and download the data required for generating the reference display from the commercial library. At the same time, write the generated primary key cascading reference display name into the domain "ref_name" of the cascading reference cache table for caching; (3) Create a two-level reference display cache application, and create a cache table for quickly generating reference displays in both the first-level cache application and the second-level cache application; when the client accesses the reference display, it only requests the data in the first-level cache application, and the update of the reference display cache is performed on the second-level cache application, thus avoiding client access failures during the process of periodic update of the reference display cache; (4) Provide two reference display cache update mechanisms: real-time update and periodic update. The real-time update is provided by the reference display modification service through real-time reception of model modification messages, and the periodic update is provided by the reference display access service. Both cache modification methods only update the reference display cache table in the second-level cache application, and at the same time, periodically synchronize the "ref_name" reference display cache domain in the second-level cache application to the first-level cache application, and the synchronization period can be configured; (5) Sense whether the number of cache tables or domains has changed, and thus regenerate the reference display cache table in the second-level cache application for the new table structure, and the entire process is transparent to client access.

2. The fast generation method for the primary key cascade relationship name of a relational memory database according to claim 1, characterized in that, The configuration information described in step (1) is the table structure information of the cascading reference display cache table.

3. A computer storage medium, having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements a method for quickly generating the primary key cascading relationship name of a relational in-memory database as described in any one of claims 1-2.

4. A computer device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements a method for quickly generating the primary key cascading relationship name of a relational in-memory database as described in any one of claims 1-2.

Citation Information

Patent Citations

  • WFS service-oriented space query result cache method

    CN107622115A

  • Data query method and device

    CN109684358A