Level-2 cache adjustment

WO2025186661A8PCT designated stage Publication Date: 2025-10-02CLOUD INTELLIGENCE ASSETS HOLDING (SINGAPORE) PTE LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
PCT/IB2025/052043
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2024-03-06
Filing Date
2025-02-26
Publication Date
2025-10-02

AI Technical Summary

Technical Problem

In relational database systems, temporary tables stored on slower storage devices affect performance. Existing technologies make it difficult to effectively utilize faster secondary caches to cache temporary tables and adapt to sudden increases in temporary table space.

Method used

By monitoring the size changes of valid data pages on the secondary cache, the secondary cache can be automatically expanded or reduced, and the secondary cache with faster access speed can be used to cache temporary tables to adapt to the sudden increase in temporary table space in the database system.

Benefits of technology

It improves the access speed of the database system, avoids the waste of memory resources, and improves the resource utilization and performance of the database system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure IB2025052043_02102025_PF_FP_ABST
    Figure IB2025052043_02102025_PF_FP_ABST
Patent Text Reader

Abstract

The present disclosure provides a method for adjusting a level-2 cache, a database system, a device, a medium and a product. The method for adjusting the level-2 cache comprises: in response to the change of the storage state of a temporary table in a database system by a level-2 cache, determining the size change of a valid data page stored by the level-2 cache, wherein the storage state comprises a state in which the temporary table is written into the level-2 cache or a state in which the level-2 cache releases the temporary table; and on the basis of the change of the storage state and the size change of the valid data page, adjusting the memory capacity of the level-2 cache. The present disclosure can achieve automatic capacity expansion or automatic capacity reduction of the level-2 cache, so as to meet the sudden increase requirement of the space of the temporary table in a relational database system and avoid memory resource waste, thereby improving the performance of the database system.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] Adjust cross-references to L2 cache related applications

[0002]

[0001] This disclosure claims priority to Chinese patent application No. 202410260742.1, filed on March 6, 2024, entitled “Method, database system, device, medium, and product for adjusting secondary cache,” the entire text of which is incorporated herein by reference.

[0003]

[0002] The present disclosure relates to the field of database technology, and more particularly to adjusting the secondary cache.

[0004] A relational database system is a system that provides data storage, query, and modification capabilities, where data is logically organized in a table format. In a relational database system, temporary tables are used to store temporary data generated when processing queries, such as temporary data generated by the database manager or users during a session. When temporary tables are stored on slower storage devices (such as disks), the performance of the database system may be affected.

[0005]

[0004] Embodiments of the present disclosure provide a method for adjusting a secondary cache, a database system, an electronic device, a storage medium, and a program product.

[0006]

[0005] In a first aspect, an embodiment of the present disclosure provides a method for adjusting a secondary cache, comprising: determining a size change of valid data pages stored in the secondary cache in response to a change in a storage state of a temporary table in a database system by the secondary cache; wherein the storage state includes a state in which the temporary table is written to the secondary cache or a state in which the temporary table is released by the secondary cache; and adjusting the memory capacity of the secondary cache based on the change in the storage state and the change in the size of the valid data pages.

[0007]

[0006] In a second aspect, an embodiment of the present disclosure provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory, wherein the processor implements any method of the embodiments of the present disclosure when executing the computer program.

[0008]

[0007] In a third aspect, an embodiment of the present disclosure provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the method of any one of the embodiments of the present disclosure is implemented.

[0009]

[0008] In a fourth aspect, embodiments of the present disclosure provide a computer program product, comprising a computer program, which, when executed by a processor, implements any of the methods of the embodiments of the present disclosure.

[0009] The technical solutions of the embodiments of the present disclosure have the following advantages: Based on the method for adjusting the secondary cache provided by the embodiments of the present disclosure, the secondary cache, which has a faster access speed than a storage device, is used to cache temporary tables in a database system, thereby improving the access speed of the database system. When a temporary table is written to the secondary cache or released by the secondary cache, the size change of valid data pages in the secondary cache is monitored. Based on the size change of the valid data pages, the memory capacity of the secondary cache is adjusted, thereby achieving automatic expansion (increasing memory capacity) or automatic reduction (reducing memory capacity) of the secondary cache. This adapts to sudden increases in the demand for temporary tablespace in a relational database system and avoids waste of memory resources, thereby improving resource utilization and performance of the database system.

[0010]

[0010] The above description is only an overview of the technical solution of the present disclosure. In order to more clearly understand the technical means of the present disclosure, it can be implemented according to the contents of the description. In order to make the above and other purposes, features and advantages of the present disclosure more obvious and easy to understand, the following specific embodiments of the present disclosure are specifically cited.

[0011] In the accompanying drawings, unless otherwise specified, identical reference numerals throughout the various drawings represent identical or similar components or elements. These drawings are not necessarily drawn to scale. It should be understood that these drawings depict only some embodiments of the present disclosure and should not be construed as limiting the scope of the present disclosure.

[0012] FIG1 is an exemplary architecture diagram of a database system for implementing the method according to an embodiment of the present disclosure;

[0013]

[0013] FIG2 is a flow chart of a method for adjusting a secondary cache according to an embodiment of the present disclosure;

[0014]

[0014] FIG3 is a block diagram of an electronic device used to implement an embodiment of the present disclosure.

[0015]

[0015] Hereinafter, only certain exemplary embodiments are briefly described. As will be appreciated by those skilled in the art, the described embodiments may be modified in various ways without departing from the spirit or scope of the present disclosure. Therefore, the drawings and description are to be regarded as illustrative in nature and not restrictive.

[0016]

[0016] To facilitate understanding of the technical solutions of the embodiments of the present disclosure, the related technologies of the embodiments of the present disclosure are described below. The following related technologies can be arbitrarily combined with the technical solutions of the embodiments of the present disclosure as optional solutions, and all of them belong to the protection scope of the embodiments of the present disclosure.

[0017] A relational database system (RDS) is a database system that uses a relational model to organize data. It stores data in rows and columns for easier understanding. These rows and columns are called tables, and a set of tables constitutes a database. Users retrieve data from the database through queries.

[0018] Temporary Table: In relational databases, a temporary table is a temporary data storage structure that exists during a database connection session and disappears when the session ends or is explicitly deleted. Temporary tables are used to temporarily store intermediate results, such as temporary data generated by the database manager or users during a session. Using temporary tables can reduce recalculation, improve query performance, and enhance readability and maintainability in complex queries or stored procedures.

[0018]

[0019] Data Page: In a relational database system, a data page is a physical unit of storage on a storage device, used to organize and store database data. A data page is typically a fixed-size block of memory, typically 4KB, 8KB, or other sizes. A data page is the basic unit of storage management in a database system, containing a certain number of database records or other data structures. Each data page has a unique identifier, typically represented by a page number. The database system uses these identifiers to quickly locate and access data stored in a specific page. In a database system, data in a table is typically stored and organized in pages. When data needs to be read or written, the database system uses the page identifier to locate the page containing the data and reads or writes the entire page to the storage device. This page-based data access method helps improve data read and write efficiency because the database system can pre-read the entire page, reducing the number of storage device accesses.

[0019]

[0020] Buffer Pool (BP): A memory structure within a database system that caches data pages read from storage devices. The buffer pool's primary purpose is to reduce direct disk accesses, thereby improving database performance. When the database needs to read or write data, it first checks whether the required data page is already in the buffer pool. If so, the database can perform the operation directly in memory, avoiding slow disk reads and writes. If not, the database system reads the data page from disk and loads it into the buffer pool. The buffer pool also writes modified data pages (dirty pages) back to the storage device to maintain data persistence.

[0020]

[0021] Level-2 Cache (L2C): This is another layer of cache located between the buffer pool (BP) and the storage device. The L2C is typically hosted in local persistent memory, a local SSD, or remote memory and can store more data pages. Because the L2C typically has a larger capacity than the buffer pool, it can cache more data, but access speeds may be slower. Data pages in the L2C may be stored in a compressed form, saving storage space and improving cache efficiency. If the required data page is not found in the buffer pool, the database system attempts to obtain the data page from the L2C. If the data page is not available in the L2C, it will finally read it from the storage device.

[0021]

[0022] Valid Data: Valid data pages. At the cache level, valid data pages are those that still reflect the actual state of the data on the storage device. Even if some data pages become invalid in the buffer pool (for example, because they have been updated or deleted), they may still reside in the L2C and not be immediately cleared.

[0022]

[0023] Figure 1 is an exemplary architecture diagram of a database system for implementing the methods of the embodiments of the present disclosure. A storage device is hardware used to persist data, that is, to store persistent data. The database system organizes data in logical structures (such as tables and indexes), while the storage device stores this data in physical form (such as files on a disk). For example, the database system of the embodiments of the present disclosure can be a relational database system.

[0023]

[0024] As shown in Figure 1, users, through database clients, can send data access requests to the database server, such as data query requests or data modification requests, to access data on storage devices. The database server receives and responds to these requests. To improve access efficiency, the database system maintains a buffer pool (BP) in memory. When querying or modifying data, the database system first checks whether the required page is in the buffer pool. If so, the data is directly accessed from memory. If not, the page is loaded from the storage device into the buffer pool. A second-level cache (L2C) can be located between the buffer pool and the storage device. The L2C can store more data pages, but access speed is slower than the buffer pool. When querying data, the database system first checks whether the data page is in the buffer pool. If not, it checks the L2C. If not, the database system reads the data page from the storage device and loads it into the buffer pool (possibly also cached in the L2C).

[0024]

[0025] In the embodiments of the present disclosure, when responding to data access requests from a database server, the database server generates temporary tables. The secondary cache is used to store or release temporary tables. Specifically, the embodiments of the present disclosure utilize the secondary cache, which has a faster access speed than a storage device, to cache temporary tables in the database system, thereby improving the access speed of the database system.

[0025]

[0026] Furthermore, when a temporary table generated by the database system is written to the L2 cache, the database server monitors the increase in the size of valid data pages stored in the L2 cache. If the increase in the size of the valid data pages exceeds a preset first threshold and the free memory in the L2 cache is less than a memory threshold, an expansion strategy is implemented for the L2 cache, namely, increasing the L2 cache's memory capacity. When the L2 cache releases a temporary table, the database server monitors the decrease in the size of the valid data pages stored in the L2 cache. If the decrease in the size of the valid data pages exceeds a preset second threshold, a decision is made as to whether to implement a reduction strategy for the L2 cache, namely, reducing the L2 cache's memory capacity. For example, the database server monitors the change in the size of valid data pages in the L2 cache during a stable period. If the size of the valid data pages decreases or remains unchanged during the stable period, a reduction strategy is implemented for the L2 cache.

[0026]

[0027] That is, the method for adjusting the L2 cache provided in the embodiments of the present disclosure monitors changes in the size of valid data pages in the L2 cache when a temporary table is written to the L2 cache or when the L2 cache releases a temporary table. The L2 cache's memory capacity is then adjusted based on the changes in the size of the valid data pages, enabling automatic expansion or contraction of the L2 cache. This automatic expansion and contraction mechanism can adapt to sudden increases in temporary tablespace demand in a relational database system, avoid wasting memory resources and manual intervention, and thus achieve flexible configuration and adjustment of memory resources, optimizing database system performance.

[0028] FIG2 illustrates a flowchart of a method for adjusting the L2 cache according to an embodiment of the present disclosure. Exemplarily, the method for adjusting the L2 cache can be applied to the aforementioned database system, for example, and executed by a database server. As shown in FIG2 , the method for adjusting the L2 cache can include the following steps.

[0027]

[0029] Step S201: In response to a change in the storage state of a temporary table in a database system by the secondary cache, determine a change in the size of a valid data page stored in the secondary cache; wherein the storage state includes a state in which a temporary table is written to the secondary cache or a state in which the secondary cache releases the temporary table.

[0028]

[0030] Step S202: Adjust the memory capacity of the secondary cache based on the change in storage status and the change in size of the valid data page.

[0029]

[0031] Temporary tables can be generated by database systems. For example, in relational database systems, temporary tables can be used to store temporary results generated by users and sessions. When temporary tables are stored on storage devices (such as disks), the slow access speed to the storage devices may affect the performance of the database system. However, in the embodiments of the present disclosure, using a faster-accessing secondary cache to store temporary tables can improve the access speed of the database system and, therefore, enhance the performance of the database system.

[0030]

[0032] For example, the L2 cache can be located in remote memory. Remote memory generally refers to memory resources that are not directly connected to the local computer but are accessed through a network connection. These memory resources may be located on other computers, servers, or specialized memory storage devices on the network. In distributed computing and cloud computing environments, remote memory can be used to share and dynamically manage memory resources across multiple physical locations, improving overall resource utilization. By using the L2 cache in remote memory to store temporary tables, remote memory resources can be used as a caching layer to reduce the burden on local memory and storage devices while improving data access speed.

[0031]

[0033] The L2 cache stores temporary tables in two main states: when a temporary table is written to the L2 cache and when it is released. When a temporary table is written to the L2 cache located in remote memory, an automatic L2 cache expansion strategy may be implemented to increase the L2 cache's memory capacity to accommodate sudden increases in temporary tablespace in the relational database system. When a temporary table is released from the L2 cache, an automatic cache reduction strategy may be implemented to reduce the L2 cache's memory capacity to avoid wasted memory resources.

[0032]

[0034] Considering that even if some data pages are no longer valid in the database system, they may still be considered valid data pages in the L2 cache until the L2 cache clears or replaces these data pages, in the embodiments of the present disclosure, if the storage status of the temporary table in the L2 cache changes, such as when the temporary table is written to the L2 cache or when the L2 cache releases the temporary table, the size change of the valid data pages stored in the L2 cache can be monitored, and the memory capacity of the L2 cache can be adaptively adjusted based on the size change of the valid data pages.

[0035] The valid data page size refers to the total size of all valid data pages in the L2 cache. For example, valid data page statistics can be updated based on a management mechanism within the L2 cache to monitor changes in the size of newly added valid data pages. For example, valid data page statistics can be determined based on a counter or data structure to determine the number of valid data pages currently stored in the L2 cache.

[0033]

[0036] Furthermore, the memory capacity of the L2 cache is adaptively adjusted based on changes in the size of valid data pages and their storage status. For example, when a temporary table is written to the L2 cache, an automatic capacity expansion strategy is implemented based on the increase in the size of the valid data pages to increase the memory capacity of the L2 cache. Alternatively, when a temporary table is released from the L2 cache, an automatic capacity reduction strategy is implemented based on the decrease in the size of the valid data pages to reduce the memory capacity of the L2 cache.

[0034]

[0037] Based on this, the embodiments of the present disclosure can determine whether to expand or shrink the L2 cache based on the size change of valid data pages in the L2 cache, so as to ensure the efficiency and responsiveness of the cache, thereby achieving flexible configuration and adjustment of memory resources.

[0035]

[0038] In one embodiment, in step S202, adjusting the memory capacity of the secondary cache based on the change in the storage state and the change in the size of the valid data page may include: in response to the storage state changing to a state in which the temporary table is written to the secondary cache, determining an increase in the size of the valid data page compared to before the storage state change; and increasing the memory capacity of the secondary cache based on the increase in the size of the valid data page.

[0036]

[0039] Specifically, when temporary tables are written to the L2 cache, the database system monitors the size of valid data pages stored in the L2 cache and, based on this increase, increases the L2 cache's memory capacity. This automatic capacity expansion accommodates sudden increases in temporary tablespace demand within the relational database system. For example, the L2 cache stores data in segments, and increasing the L2 cache's memory capacity can be achieved by allocating more segments to the cache.

[0037]

[0040] In one embodiment, increasing the memory capacity of the L2 cache based on the increased size of valid data pages may include: determining current free memory of the L2 cache in response to the increased size of the valid data pages being greater than a preset first threshold; and increasing the memory capacity of the L2 cache according to the amount of increase in the memory capacity of the L2 cache when the current free memory of the L2 cache is less than the memory threshold.

[0038]

[0041] For example, the memory capacity required by valid data pages can be calculated based on the total number of valid data pages. The free memory capacity can then be determined based on the required memory capacity and the total memory capacity of the L2 cache. The free memory capacity is ensured to account for at least a certain percentage (e.g., 90%) of the total memory capacity, and a first threshold is pre-set. Furthermore, a memory threshold can be pre-set. If the free memory in the L2 cache is less than the memory threshold and the increase in the size of valid data pages is greater than the first threshold, an increase in the L2 cache memory capacity is determined and the L2 cache is expanded by the increase. This means that the automatic expansion of the L2 cache can be controlled within a reasonable range.

[0039]

[0042] In one embodiment, determining the amount of increase in the memory capacity of the secondary cache may include: determining the current occupied memory of the secondary cache; and calculating the amount of increase in the memory capacity of the secondary cache based on the current occupied memory and a preset first expansion factor.

[0040]

[0043] The first expansion factor can be set based on actual needs, such as 2. This means that the increase in the memory capacity of the secondary cache can be calculated by multiplying the currently occupied memory by the first expansion factor. For example, the secondary cache stores data by segment, and the increase is the number of segments to be allocated. The number of segments to be added can be calculated by multiplying the number of currently occupied segments by the first expansion factor.

[0041]

[0044] In one embodiment, in step S202, adjusting the memory capacity of the secondary cache based on the change in storage status and the change in size of valid data pages may include: releasing the state of a temporary table for the secondary cache in response to the change in storage status, determining a reduction in the size of the valid data pages; and reducing the memory capacity of the secondary cache based on the reduction in the size of the valid data pages compared to before the change in storage status.

[0042]

[0045] That is, when the L2 cache releases a temporary table, the database system monitors the decrease in the size of valid data pages stored in the L2 cache and, based on the decrease in the size of the valid data pages, reduces the L2 cache's memory capacity. This automatically reduces the capacity to avoid wasting memory resources. For example, reducing the L2 cache's memory capacity can be achieved by reclaiming L2 cache segments.

[0043]

[0046] In one embodiment, reducing the memory capacity of the secondary cache based on the reduced size of the valid data page may include: determining that the secondary cache has entered a stable period in response to the reduced size of the valid data page being greater than a preset second threshold; and reducing the memory capacity of the secondary cache in response to the size of the valid data page decreasing or remaining unchanged during the stable period according to the amount of reduction in the memory capacity of the secondary cache.

[0044]

[0047] For example, the second threshold can be preset as half the size of the valid data page in the L2 cache before the temporary table is released. Once the size of the valid data page decreases by more than the second threshold, a stabilization period begins to be counted. If the size of the valid data page decreases or remains unchanged during the stabilization period, the amount of reduction in the memory capacity of the L2 cache is determined, and the L2 cache is scaled down by the amount of reduction. That is, the memory capacity of the L2 cache is reduced by the amount of reduction.

[0045]

[0048] In other words, before deciding to shrink the L2 cache, a stabilization period must be maintained. Shrinking the L2 cache is triggered only if the size of valid data pages decreases or remains constant during the stabilization period. For example, the length of the stabilization period may need to be adjusted based on the specific workload and system performance to avoid system performance degradation that may be caused by frequent shrinking operations.

[0049] In one embodiment, determining the amount of reduction in the memory capacity of the secondary cache may include: determining current free memory of the secondary cache; and calculating the amount of reduction in the memory capacity of the secondary cache based on the current free memory and a preset second expansion factor.

[0046]

[0050] The second scaling factor can be set based on actual needs, such as 1 / 3. That is, the reduction in the memory capacity of the secondary cache can be calculated by multiplying the current free memory by the second scaling factor. For example, the secondary cache stores data by segment, and the reduction is the number of segments to be reclaimed. The number of segments to be reclaimed can be calculated by multiplying the number of currently free segments by the second scaling factor.

[0047]

[0051] The method for adjusting the L2 cache provided in the embodiments of the present disclosure improves the access speed of the database system by utilizing the L2 cache, which has a faster access speed than a storage device, to cache temporary tables in the database system. When a temporary table is written to the L2 cache or released from the L2 cache, the method monitors the size changes of valid data pages in the L2 cache. Based on the size changes of the valid data pages, the method adjusts the memory capacity of the L2 cache, thereby automatically expanding or shrinking the L2 cache. This adapts to sudden increases in temporary tablespace demand in the relational database system, avoids wasting memory resources, and improves the performance of the database system.

[0048]

[0052] Corresponding to the method provided in the embodiments of the present disclosure, the embodiments of the present disclosure further provide an apparatus for adjusting a secondary cache. The apparatus for adjusting a secondary cache may include: a size change determination module configured to determine a size change of valid data pages stored in the secondary cache in response to a change in the storage state of a temporary table in a database system in the secondary cache; the storage state includes a state in which the temporary table is written to the secondary cache or a state in which the temporary table is released by the secondary cache; and a memory capacity adjustment module configured to adjust the memory capacity of the secondary cache based on the change in the storage state and the size change of the valid data pages.

[0049]

[0053] In one embodiment, the memory capacity adjustment module is specifically configured to: determine an increase in the size of the valid data page in response to the storage state changing to a state in which the temporary table is written to the secondary cache; and increase the memory capacity of the secondary cache according to the increase in the size of the valid data page compared to before the storage state change.

[0050]

[0054] In one embodiment, the memory capacity adjustment module is specifically configured to: determine the current free memory of the secondary cache in response to the increase in the size of the valid data page being greater than a preset first threshold; and increase the memory capacity of the secondary cache according to the increase in the memory capacity of the secondary cache when the current free memory of the secondary cache is less than the memory threshold.

[0051]

[0055] In one embodiment, the memory capacity adjustment module is specifically configured to: determine the current occupied memory of the secondary cache; and calculate an increase in the memory capacity of the secondary cache based on the current occupied memory and a preset first expansion coefficient.

[0056] In one embodiment, the memory capacity adjustment module is specifically used to: release the state of the temporary table for the secondary cache in response to the storage state change, determine the reduced size of the valid data page compared to before the storage state change; and reduce the memory capacity of the secondary cache according to the reduced size of the valid data page.

[0052]

[0057] In one embodiment, the memory capacity adjustment module is specifically configured to: determine that the secondary cache enters a stable period in response to a decrease in the size of the valid data page being greater than a preset second threshold; and reduce the memory capacity of the secondary cache according to the amount of reduction in the memory capacity of the secondary cache in response to a decrease in the size of the valid data page or a decrease in the size of the valid data page during the stable period.

[0053]

[0058] In one embodiment, the memory capacity adjustment module is specifically configured to: determine the current free memory of the secondary cache; and calculate the reduction amount of the memory capacity of the secondary cache based on the current free memory and a preset second expansion coefficient.

[0054]

[0059] The functions of the modules in the devices of the embodiments of the present disclosure can be found in the corresponding descriptions of the above methods, and have corresponding beneficial effects, which will not be described in detail here.

[0055]

[0060] Figure 3 is a block diagram of an electronic device used to implement embodiments of the present disclosure. As shown in Figure 3 , the electronic device includes a memory 301 and a processor 302. Memory 301 stores a computer program executable on processor 302. Processor 302 executes the computer program to implement the methods described in the above embodiments. There may be one or more memory 301 and processor 302.

[0056]

[0061] The electronic device also includes a communication interface 303 for communicating with external devices and performing data exchange transmission.

[0057]

[0062] If the memory 301, processor 302, and communication interface 303 are implemented independently, the memory 301, processor 302, and communication interface 303 may be connected to each other via a bus and communicate with each other. This bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus. This bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, FIG3 shows only one thick line, but this does not mean that there is only one bus or only one type of bus.

[0058]

[0063] Optionally, in a specific implementation, if the memory 301, the processor 302, and the communication interface 303 are integrated on a chip, the memory 301, the processor 302, and the communication interface 303 may communicate with each other through an internal interface.

[0059]

[0064] An embodiment of the present disclosure provides a computer-readable storage medium storing a computer program, which implements the method provided in the embodiment of the present disclosure when the program is executed by a processor.

[0060]

[0065] An embodiment of the present disclosure further provides a chip, which includes a processor configured to call and execute instructions stored in a memory, so that a communication device equipped with the chip executes the method provided in the embodiment of the present disclosure.

[0061]

[0066] An embodiment of the present disclosure further provides a chip, comprising: an input interface, an output interface, a processor, and a memory. The input interface, the output interface, the processor, and the memory are connected via an internal connection path. The processor is configured to execute code in the memory. When the code is executed, the processor is configured to execute the method provided in the embodiment of the application.

[0062]

[0067] It should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor. It is worth noting that the processor may be a processor that supports the Advanced RISC Machines (ARM) architecture.

[0063]

[0068] Furthermore, optionally, the above-mentioned memory may include read-only memory and random access memory. The memory may be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. Among them, the non-volatile memory may include read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory may include random access memory (RAM), which is used as an external cache. By way of example but not limitation, many forms of RAM are available. For example, static random access memory

[0064] (Static RAM, SRAM), Dynamic Random Access Memory (Dynamic Random Access Memory, DRAM), Synchronous Dynamic Random Access Memory (SDRAM), Double Data Rate Synchronous Dynamic Random Access Memory (DDR SDRAM), Enhanced Synchronous Dynamic Random Access Memory (ESDRAM), Synchronous Link Dynamic Random Access Memory (SLDRAM) and Direct Rambus RAM (DR RAM).

[0065]

[0069] The above embodiments can be implemented in whole or in part using software, hardware, firmware, or any combination thereof. When implemented using software, they can be implemented in whole or in part in the form of a computer program product. A computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions according to the present disclosure are fully or partially generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transferred from one computer-readable storage medium to another.

[0066]

[0070] Throughout this specification, references to terms such as "one embodiment," "some embodiments," "examples," "specific examples," or "some examples" indicate that the specific features, structures, materials, or characteristics described in connection with that embodiment or example are included in at least one embodiment or example of the present disclosure. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Furthermore, those skilled in the art may combine and integrate different embodiments or examples, and features of different embodiments or examples, described in this specification, unless otherwise inconsistent.

[0067]

[0071] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of the technical features indicated. Therefore, features defined as "first" or "second" may explicitly or implicitly include at least one such feature. In the description of this disclosure, "plurality" means two or more, unless otherwise specifically defined.

[0068]

[0072] Any process or method described in a flowchart or otherwise herein can be understood to represent a module, segment, or portion of code comprising one or more executable instructions for implementing the steps of a specific logical function or process. Furthermore, the scope of the preferred embodiments of the present disclosure includes alternative implementations in which functions may be performed out of the order shown or discussed, including performing functions substantially simultaneously or in reverse order depending on the functions involved.

[0069]

[0073] The logic and / or steps described in the flowcharts or otherwise described herein may be considered, for example, a sequenced list of executable instructions for implementing the logical functions, and may be embodied in any computer-readable medium for use by an instruction execution system, apparatus, or device (e.g., a computer-based system, a system including a processor, or other system that can fetch and execute instructions from an instruction execution system, apparatus, or device), or used in conjunction with such instruction execution systems, apparatuses, or devices.

[0070]

[0074] It should be understood that various aspects of the present disclosure may be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods may be implemented using software or firmware stored in a memory and executed by a suitable instruction execution system. All or part of the steps of the above-described method embodiments may be performed by a program instructing the relevant hardware. The program may be stored in a computer-readable storage medium. When executed, the program includes one or a combination of the steps of the method embodiments.

[0071]

[0075] Furthermore, the functional units in the various embodiments of the present disclosure may be integrated into a single processing module, each unit may exist physically separately, or two or more units may be integrated into a single module. The integrated modules may be implemented in the form of hardware or software functional modules. If the integrated modules are implemented as software functional modules and sold or used as independent products, they may also be stored in a computer-readable storage medium. The storage medium may be a read-only memory, a magnetic disk, an optical disk, or the like.

[0072]

[0076] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this disclosure are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and corresponding operation portals are provided for users to select or edit authorization or rejection.

[0073]

[0077] The above are merely exemplary embodiments of the present disclosure, but the scope of protection of the present disclosure is not limited thereto. Any person skilled in the art can readily conceive of various modifications or substitutions within the technical scope of the present disclosure, and such modifications or substitutions are intended to fall within the scope of protection of the present disclosure. Therefore, the scope of protection of the present disclosure shall be subject to the scope of protection of the claims.

Claims

Claims 1. A method for adjusting a secondary cache, comprising: In response to a change in the storage state of a temporary table in a database system by a secondary cache, a change in the size of a valid data page stored in the secondary cache is determined; wherein the storage state includes a state in which the temporary table is written to the secondary cache or a state in which the secondary cache releases the temporary table; and based on the change in the storage state and the change in the size of the valid data page, the memory capacity of the secondary cache is adjusted.

2. The method according to claim 1, wherein: Adjusting the memory capacity of the secondary cache based on the change in the storage state and the change in the size of the valid data page includes: in response to the storage state changing to a state in which the temporary table is written to the secondary cache, determining an increase in the size of the valid data page compared to before the storage state changed; and increasing the memory capacity of the secondary cache according to the increase in the size of the valid data page.

3. The method according to claim 2, wherein: Increasing the memory capacity of the secondary cache according to the increased size of the valid data page includes: determining the current free memory of the secondary cache in response to the increased size of the valid data page being greater than a preset first threshold; and increasing the memory capacity of the secondary cache according to the amount of increase in the memory capacity of the secondary cache when the current free memory of the secondary cache is less than a memory threshold.

4. The method according to claim 3, wherein: Determining an increase in the memory capacity of the secondary cache includes: determining a current occupied memory of the secondary cache; and calculating an increase in the memory capacity of the secondary cache based on the current occupied memory and a preset first expansion factor.

5. The method according to claim 1, wherein: Adjusting the memory capacity of the secondary cache based on the change in the storage state and the change in the size of the valid data page includes: releasing the state of the temporary table for the secondary cache in response to the change in the storage state, and determining a reduction in the size of the valid data page compared to before the storage state changed; and reducing the memory capacity of the secondary cache according to the reduction in the size of the valid data page.

6. The method according to claim 5, wherein: Reducing the memory capacity of the secondary cache according to the reduced size of the valid data page includes: determining that the secondary cache enters a stable state in response to the reduced size of the valid data page being greater than a preset second threshold; periodically; in response to the size of the valid data page decreasing or remaining unchanged during the stable period, reducing the memory capacity of the secondary cache according to the amount of reduction in the memory capacity of the secondary cache.

7. The method according to claim 6, wherein: Determining the amount of reduction in the memory capacity of the secondary cache includes: determining current free memory of the secondary cache; and calculating the amount of reduction in the memory capacity of the secondary cache based on the current free memory and a preset second expansion factor.

8. A database system comprising: Storage devices, used to store persistent data; Second-level cache, used to store or release temporary tables; A database client, configured to send a data access request to the storage device; A database server is configured to receive the data access request, generate the temporary table, and execute the method according to any one of claims 1 to 7 to adjust the memory capacity of the secondary cache.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory, wherein the processor implements the method according to any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium having a computer program stored therein, wherein the computer program, when executed by a processor, implements the method according to any one of claims 1 to 7.

11. A computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements the method according to any one of claims 1 to 7.