Method for adjusting second-level cache, database system, device, medium and product

By monitoring the size changes of valid data pages in the secondary cache and automatically adjusting the memory capacity of the secondary cache, the problem of temporary tables stored on slow storage devices affecting database performance is solved, and efficient access and resource optimization of the database system are achieved.

CN120653672APending Publication Date: 2025-09-16ALIBABA CLOUD COMPUTING CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410260742.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-03-06
Publication Date
2025-09-16

AI Technical Summary

Technical Problem

In the prior art, temporary tables are stored on slower storage devices, which affects database system performance. The prior art fails to effectively utilize the secondary cache to cache temporary tables and automatically adjust memory capacity.

Method used

By monitoring the size changes of valid data pages in the secondary cache, the memory capacity of the secondary cache is automatically expanded or reduced to adapt to the changes in the demand for temporary table space, thereby improving the access speed and resource utilization of the database system.

Benefits of technology

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

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120653672A_ABST
    Figure CN120653672A_ABST
Patent Text Reader

Abstract

The invention provides a method for adjusting a second-level cache, a database system, equipment, a medium and a product, and the method for adjusting the second-level cache comprises the following steps: determining the size change of an effective data page stored in the second-level cache in response to the change of the storage state of a temporary table in the database system by the second-level cache; wherein the storage state comprises a state that the temporary table is written into the second-level cache or a state that the second-level cache releases the temporary table; and adjusting the memory capacity of the second-level cache based on the change of the storage state and the size change of the effective data page. According to the embodiment of the invention, automatic capacity expansion or automatic capacity shrinkage of the second-level cache can be realized, so that the sudden increase requirement of a temporary table space in a relational database system is met, and the waste of memory resources can be avoided, so that the performance of the database system is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of database technology, and in particular to a method for adjusting a secondary cache, a database system, an electronic device, a storage medium, and a program product. Background Art

[0002] A relational database system provides data storage, query, and modification capabilities, where data is logically organized in tables. In a relational database system, temporary tables are used to store temporary data generated during query processing, such as data generated by the database manager or by users during a session. When temporary tables are stored on slower storage devices, such as disks, they can affect database system performance. Summary of the Invention

[0003] Embodiments of the present application provide a method for adjusting a secondary cache, a database system, an electronic device, a storage medium, and a program product to solve or alleviate technical problems existing in the prior art.

[0004] In a first aspect, an embodiment of the present application provides a method for adjusting the secondary cache, including: the method for adjusting the secondary cache includes: determining the size change of the valid data page stored in the secondary cache in response to a change in the storage status of a temporary table in a database system by the secondary cache; wherein the storage status includes the state of the temporary table being written to the secondary cache or the state of the secondary cache releasing the temporary table; based on the change in the storage status and the change in the size of the valid data page, adjusting the memory capacity of the secondary cache.

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

[0006] In a third aspect, an embodiment of the present application 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 application is implemented.

[0007] In a fourth aspect, an embodiment of the present application provides a computer program product, including a computer program, which implements any method of the embodiments of the present application when executed by a processor.

[0008] Compared with the prior art, the technical solution of the embodiment of the present application has the following advantages:

[0009] Based on the method for adjusting the secondary cache provided in an embodiment of the present application, a secondary cache having an access speed faster than that of 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 the valid data page on the secondary cache is monitored, and the memory capacity of the secondary cache is adjusted according to the size change of the valid data page, thereby realizing automatic expansion (increasing memory capacity) or automatic reduction (reducing memory capacity) of the secondary cache, thereby adapting to the sudden increase in temporary table space demand in the relational database system and avoiding waste of memory resources, thereby improving resource utilization and performance of the database system.

[0010] The above description is only an overview of the technical solution of this application. In order to more clearly understand the technical means of this application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of this application more obvious and easy to understand, the specific implementation methods of this application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0012] Figure 1 This is an exemplary architecture diagram of a database system for implementing the method of the embodiment of the present application;

[0013] Figure 2 A flowchart of a method for adjusting the secondary cache according to an embodiment of the present application;

[0014] Figure 3 A block diagram of an electronic device used to implement an embodiment of the present application. DETAILED DESCRIPTION

[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 application. Therefore, the drawings and description are to be regarded as illustrative in nature and not restrictive.

[0016] To facilitate understanding of the technical solutions of the embodiments of the present application, the following describes the related technologies of the embodiments of the present application. The following related technologies can be combined with the technical solutions of the embodiments of the present application as optional solutions, and all of them fall within the scope of protection of the embodiments of the present application.

[0017] A relational database system (RDS) uses a relational model to organize data. It stores data in rows and columns for easy 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 a relational database, 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. The use of temporary tables can reduce recalculation, improve query performance, and provide better readability and maintainability in complex queries or stored procedures.

[0019] Data Page: In a relational database system, a data page is a physical unit of storage on a storage device that organizes and stores database data. A data page is typically a fixed-size block of memory, typically 4KB, 8KB, or other sizes. A data page is the fundamental 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 accesses to the storage device.

[0020] Buffer Pool (BP): A memory structure within a database system that caches data pages read from storage devices. The primary purpose of the buffer pool is to reduce direct disk accesses, thereby improving the performance of database operations. 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 is also responsible for writing modified data pages (dirty pages) back to the storage device to maintain data persistence.

[0021] Level-2 Cache (L2C): Another layer of cache located between the buffer pool (BP) and the storage device. L2C is usually hosted on local persistent memory, local SSD, or remote memory, and can store more data pages. Since the capacity of L2C is usually larger than the buffer pool, it can cache more data, but the access speed may be slower than the buffer pool. In L2C, data pages may exist in compressed form, which can save storage space and improve cache efficiency. When the required data page is not found in the buffer pool, the database system will try to obtain the data page from L2C. If it is not available in L2C, it will finally read it from the storage device.

[0022] Valid Data: Valid data pages. At the cache level, valid data pages are those cached data pages that still reflect the actual data status 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 will not be immediately cleared.

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

[0024] like Figure 1 As shown, users can send data access requests to the database server based on the database client, such as data query requests or data modification requests. The database server receives and responds to the database client's data access requests. To improve access efficiency, the database system maintains a buffer pool (BP) in memory. When data needs to be queried or modified, the database system first checks whether the required page is already 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 set 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 for the data 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).

[0025] In the embodiments of the present application, when responding to a data access request from a database server, the database server generates a temporary table, and the secondary cache is used to store or release the temporary table. In other words, the embodiments of the present application can utilize the secondary cache, which has a faster access speed than the storage device, to cache temporary tables in the database system, thereby improving the access speed of the database system.

[0026] Furthermore, when a temporary table generated by the database system is written into the secondary cache, the database server monitors the increase in the size of the valid data pages stored on the secondary cache. If the increase in the size of the valid data pages is greater than a preset first threshold and the free memory of the secondary cache is less than the memory threshold, an expansion strategy is executed on the secondary cache, i.e., the memory capacity of the secondary cache is increased. When the secondary cache releases a temporary table, the database server monitors the decrease in the size of the valid data pages stored on the secondary cache. If the decrease in the size of the valid data pages is greater than a preset second threshold, a decision needs to be made as to whether to execute a reduction strategy on the secondary cache, i.e., reduce the memory capacity of the secondary cache. For example: monitor the size changes of the valid data pages of the secondary 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 executed on the secondary cache.

[0027] That is to say, based on the method for adjusting the secondary cache provided in the embodiment of the present application, when a temporary table is written to the secondary cache or the secondary cache releases a temporary table, the size changes of the valid data pages on the secondary cache are monitored, and then the memory capacity of the secondary cache is adjusted according to the size changes of the valid data pages to achieve automatic expansion or automatic reduction of the secondary cache. This automatic expansion and reduction mechanism can adapt to the sudden increase in temporary table space demand in the relational database system, and can avoid waste of memory resources and manual intervention, thereby achieving flexible configuration and adjustment of memory resources and performance optimization of the database system.

[0028] Figure 2 Flowchart showing a method for adjusting the secondary cache according to an embodiment of the present application. Exemplarily, the method for adjusting the secondary cache can be applied to the above-mentioned database system, for example, executed by a database server. Figure 2 As shown, the method for adjusting the secondary cache may include:

[0029] Step S201: In response to a change in the storage state of a temporary table in a database system by the secondary cache, determining a change in the size of a valid data page stored in 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;

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

[0031] Temporary tables can be generated by a database system. For example, in a relational database system, temporary tables can be used to store temporary results generated by users and sessions. When temporary tables are stored on a storage device (such as a disk), the performance of the database system may be affected due to the slow access speed to the storage device. In the embodiments of the present application, using a secondary cache with a faster access speed to store temporary tables can increase the access speed of the database system and thereby improve the performance of the database system.

[0032] For example, the secondary 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 secondary 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.

[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, it may be necessary to automatically expand the L2 cache to accommodate sudden increases in temporary tablespace in the relational database system. When a temporary table is released, it may be necessary to automatically shrink the cache to reduce its memory capacity to avoid wasting memory resources.

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

[0035] The size of a valid data page refers to the sum of the sizes of all valid data pages in the L2 cache. For example, the size change of newly added valid data pages can be monitored by updating valid data page statistics based on a management mechanism within the L2 cache. For example, the valid data page statistics can be determined based on a counter or a data structure to determine how many valid data pages are currently stored in the L2 cache.

[0036] Furthermore, the memory capacity of the secondary cache is adaptively adjusted based on the size changes and storage status of valid data pages. For example, when a temporary table is written to the secondary 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 secondary cache. Alternatively, when a temporary table is released from the secondary 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 secondary cache.

[0037] Based on this, the embodiment of the present application can determine whether the secondary cache needs to be expanded or reduced based on the size change of the valid data page on the secondary cache to ensure the efficiency and responsiveness of the cache, thereby realizing flexible configuration and adjustment of memory resources.

[0038] 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 the valid data page may include: in response to the storage status changing to a state in which a temporary table is written to the secondary cache, determining the increased size of the valid data page compared to before the storage status change; and increasing the memory capacity of the secondary cache according to the increased size of the valid data page.

[0039] That is, when temporary tables are written to the L2 cache, the database system monitors the increase in the size of valid data pages stored in the L2 cache and, based on the increase in the size of the valid data pages, increases the memory capacity of the L2 cache to accommodate the sudden increase in temporary tablespace in the relational database system through automatic expansion. For example, the L2 cache stores data in segments, and increasing the memory capacity of the L2 cache can be achieved by allocating more segments to the L2 cache.

[0040] In one embodiment, increasing the memory capacity of the secondary cache based on the increased size of the valid data page may include: 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 the memory threshold.

[0041] For example, the memory capacity required to be occupied by the valid data pages can be calculated based on the total amount of the valid data pages; then, the memory capacity of the free memory can be determined based on the memory capacity required to be occupied and the total memory capacity of the secondary cache, and the free memory can be guaranteed to account for at least a certain percentage of the total memory capacity (for example, 90%), and then a first threshold value can be pre-set. Furthermore, a memory threshold can be pre-set. If the free memory of the secondary cache is less than the memory threshold, and the increase in the size of the valid data pages is greater than the first threshold, the increase in the memory capacity of the secondary cache is determined, and the secondary cache is expanded according to the increase, that is, the memory capacity of the secondary cache is increased by the increase. Based on this, the automatic expansion of the secondary cache can be controlled within a reasonable range.

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

[0043] The first scaling factor can be set according to actual needs. For example, if it is set to 2, the increase in the memory capacity of the secondary cache can be calculated by multiplying the current occupied memory by the first scaling factor. For example, the secondary cache stores data by segment, and the increase is the number of segments that need to be allocated. The number of segments that need to be increased can be calculated based on the number of currently occupied segments multiplied by the first scaling factor.

[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 the size of the valid data page may include: releasing the state of the temporary table for the secondary cache in response to the change in storage status, determining the reduced size of the valid data page; and reducing the memory capacity of the secondary cache based on the reduced size of the valid data page compared to before the storage status change.

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

[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 enters 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 according to the amount of reduction in 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.

[0047] For example, the second threshold can be pre-set 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 beyond the second threshold, a stabilization period is 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, i.e., the memory capacity of the L2 cache is reduced by the amount of reduction.

[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 unchanged 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 caused by frequent shrinkage 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.

[0050] The second scaling factor can be set based on actual needs, such as 1 / 3. This means that 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 that need to be reclaimed. The number of segments that need to be reclaimed can be calculated based on the number of currently free segments multiplied by the second scaling factor.

[0051] Based on the method for adjusting the secondary cache provided in an embodiment of the present application, the access speed of the database system is improved by utilizing the secondary cache having an access speed faster than that of the storage device to cache temporary tables in the database system. When the temporary table is written to the secondary cache or the secondary cache releases the temporary table, the size change of the valid data page on the secondary cache is monitored. Then, according to the size change of the valid data page, the memory capacity of the secondary cache is adjusted to realize automatic expansion or reduction of the secondary cache, thereby adapting to the sudden increase in the demand for temporary table space in the relational database system and avoiding waste of memory resources, thereby improving the performance of the database system.

[0052] Corresponding to the method provided in the embodiment of the present application, the embodiment of the present application also provides an apparatus for adjusting the secondary cache. The apparatus for adjusting the secondary cache may include: a size change determination module for determining 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 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 secondary cache releases the temporary table; and a memory capacity adjustment module for adjusting the memory capacity of the secondary cache based on the change in the storage state and the size change of the valid data page.

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

[0054] In one embodiment, the memory capacity adjustment module is specifically used 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.

[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.

[0057] In one embodiment, the memory capacity adjustment module is specifically used to: determine that the secondary cache enters a stable period in response to the reduced 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 the size of the valid data page decreasing or remaining unchanged during the stable period.

[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.

[0059] The functions of each module in each device in the embodiment of the present application can be referred to the corresponding description in the above method, and have corresponding beneficial effects, which will not be repeated here.

[0060] Figure 3 FIG. 1 is a block diagram of an electronic device for implementing an embodiment of the present application. Figure 3 As shown, the electronic device includes: a memory 031 and a processor 032. The memory 031 stores a computer program that can be run on the processor 032. When the processor 032 executes the computer program, the method in the above embodiment is implemented. The number of the memory 031 and the processor 032 can be one or more.

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

[0062] If the memory 031, the processor 032, and the communication interface 303 are implemented independently, the memory 031, the processor 032, and the communication interface 303 can be connected to each other via a bus and communicate with each other. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 3 Only one thick line is used in the diagram, but this does not mean that there is only one bus or one type of bus.

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

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

[0065] An embodiment of the present application also provides a chip, which includes a processor for calling and executing instructions stored in the memory from the memory, so that a communication device equipped with the chip executes the method provided in the embodiment of the present application.

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

[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, etc. It is worth noting that the processor may be a processor that supports the Advanced RISC Machines (ARM) architecture.

[0068] Furthermore, optionally, the above-mentioned memory may include a read-only memory and a random access memory. The memory may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories. Among them, the non-volatile memory may include a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may include a 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 (SRAM), 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 DRAM (SLDRAM) and direct memory bus random access memory (DR RAM).

[0069] In the above embodiments, all or part of the embodiments may be implemented using software, hardware, firmware, or any combination thereof. When implemented using software, all or part of the embodiments may be implemented 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 application are generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transferred from one computer-readable storage medium to another.

[0070] In the description of this specification, the reference terms "one embodiment," "some embodiments," "example," "specific example," or "some examples" mean that the specific features, structures, materials, or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. Moreover, the specific features, structures, materials, or characteristics described may be combined in any appropriate manner in any one or more embodiments or examples. In addition, those skilled in the art may combine and combine different embodiments or examples described in this specification, as well as features of different embodiments or examples, unless they are mutually inconsistent.

[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 technical features being referred to. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one such feature. Throughout the description of this application, "plurality" means two or more, unless otherwise specifically defined.

[0072] Any process or method described in the flowchart or otherwise described 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. The scope of the preferred embodiments of the present application includes other implementations in which the functions may be performed in a different order than shown or discussed, including performing the functions substantially simultaneously or in reverse order depending on the functions involved.

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

[0074] It should be understood that various parts of the present application can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can 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 embodiment method can be completed by instructing the relevant hardware through a program, which can be stored in a computer-readable storage medium. When the program is executed, it includes one or a combination of the steps of the method embodiment.

[0075] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing module, or each unit may exist physically separately, or two or more units may be integrated into a single module. The aforementioned integrated modules may be implemented in the form of hardware or in the form of software functional modules. If the aforementioned integrated modules are implemented in the form of 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, or an optical disk, etc.

[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 application 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 provide corresponding operation entrances for users to choose or edit authorization or rejection.

[0077] The above is merely an exemplary embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any person skilled in the art can easily conceive of various modifications or substitutions within the technical scope described in this application, and such modifications or substitutions should be included in the scope of protection of the present application. Therefore, the scope of protection of the present application should be based on the scope of protection of the claims.

Claims

1. A method for adjusting a secondary cache, comprising: In response to a change in a storage state of a temporary table in a database system by a secondary cache, determining a change in the size of a valid data page stored in 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; 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 into the secondary cache, determining an increase in size of the valid data page compared to before the storage state change; The memory capacity of the secondary cache is increased according to the increased 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: In response to the increase in size of the valid data page being greater than a preset first threshold, determining a current free memory of the secondary cache; When the current free memory of the secondary cache is less than the memory threshold, the memory capacity of the secondary cache is increased according to the increase amount of the memory capacity of the secondary cache.

4. The method according to claim 3, wherein: Determining an increase in the memory capacity of the secondary cache includes: Determine the current occupied memory of the secondary cache; An increase in the memory capacity of the secondary cache is calculated based on the currently 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: In response to the storage state change, releasing the state of the temporary table for the secondary cache, determining a reduction in size of the valid data page compared to before the storage state change; The memory capacity of the secondary cache is reduced according to the reduced 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: In response to the reduction size of the valid data page being greater than a preset second threshold, determining that the secondary cache enters a stable period; In response to the size of the valid data page decreasing or remaining unchanged during the stable period, the memory capacity of the secondary cache is reduced according to the amount of reduction in the memory capacity of the secondary cache.

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

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, wherein a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.

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