CN114253730A - Method, device and equipment for managing database memory and storage medium - Google Patents

Method, device and equipment for managing database memory and storage medium Download PDF

Info

Publication number
CN114253730A
CN114253730A CN202111593090.6A CN202111593090A CN114253730A CN 114253730 A CN114253730 A CN 114253730A CN 202111593090 A CN202111593090 A CN 202111593090A CN 114253730 A CN114253730 A CN 114253730A
Authority
CN
China
Prior art keywords
capacity
allocated
memory
allocable
connection number
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111593090.6A
Other languages
Chinese (zh)
Inventor
尹强
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Kingbase Information Technologies Co Ltd
Original Assignee
Beijing Kingbase Information Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Kingbase Information Technologies Co Ltd filed Critical Beijing Kingbase Information Technologies Co Ltd
Priority to CN202111593090.6A priority Critical patent/CN114253730A/en
Publication of CN114253730A publication Critical patent/CN114253730A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/242Query formulation
    • G06F16/2433Query languages
    • G06F16/2443Stored procedures

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Mathematical Physics (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The present disclosure relates to a method, an apparatus, a device and a storage medium for managing a database memory, wherein the method comprises: acquiring a memory allocation request, wherein the request comprises information of capacity to be allocated; based on the pre-configured connection number, the total capacity of the database memory and the allocated capacity, adjusting the allocable capacity; and if the capacity to be allocated is less than or equal to the allocable capacity, responding to the memory allocation request to allocate the capacity to be allocated from the database memory. The method adjusts the allocable capacity according to the pre-configured connection number, the total capacity of the database memory and the allocated capacity, and determines the size of the allocable capacity; and if the capacity to be allocated is less than or equal to the allocable capacity, responding to the memory allocation request to allocate the capacity to be allocated from the database memory, so that the memory requirement is correspondingly met, the memory is optimized, and the performance is improved.

Description

Method, device and equipment for managing database memory and storage medium
Technical Field
The present disclosure relates to the field of database technologies, and in particular, to a method, an apparatus, a device, and a storage medium for managing a database memory.
Background
All the operations of Structured Query Language (SQL) statements in a database need to occupy a memory to process input data, and if the memory is insufficient, an external memory is needed to assist the operations, so that the performance is reduced.
In general, the database can treat the memory requirements of each SQL statement operation equally, so that the SQL statement operation with large memory requirements cannot obtain the required memory due to the equally distributed algorithm, and the SQL statement operation with small memory requirements wastes the corresponding memory.
Therefore, how to reasonably meet the memory requirements of different SQL statement operations becomes an urgent problem to be solved.
Disclosure of Invention
In order to solve the above technical problems, the present disclosure provides a method, an apparatus, a device, and a storage medium for managing a database memory, so as to meet memory requirements, optimize the memory, and improve performance.
In a first aspect, an embodiment of the present disclosure provides a method for managing a database memory, including:
acquiring a memory allocation request, wherein the request comprises information of capacity to be allocated;
based on the pre-configured connection number, the total capacity of the database memory and the allocated capacity, adjusting the allocable capacity;
and if the capacity to be allocated is less than or equal to the allocable capacity, responding to the memory allocation request to allocate the capacity to be allocated from the database memory.
In some embodiments, said adjusting the allocable capacity based on the preconfigured number of connections, the total capacity of the database memory, and the allocated capacity comprises:
determining a first connection number and a second connection number based on the preconfigured connection number; wherein the first connection number is greater than the second connection number, and the first connection number is less than the preconfigured connection number;
determining a first capacity and a second capacity based on the total capacity; wherein the first capacity is less than the second capacity, and the second capacity is less than the total capacity;
determining a capacity threshold based on the total capacity;
adjusting an allocable capacity based on the capacity threshold, the allocated capacity, the first number of connections, the second number of connections, the first capacity, and the second capacity.
In some embodiments, said adjusting allocable capacity based on said capacity threshold, said allocated capacity, said first number of connections, said second number of connections, said first capacity, and said second capacity comprises:
determining whether the allocated capacity is greater than the capacity threshold;
if the allocated capacity is larger than the capacity threshold, determining allocable capacity based on the first capacity and the first connection number; or the like, or, alternatively,
and if the allocated capacity is smaller than or equal to the capacity threshold, determining the allocable capacity based on the second capacity and the second connection number.
In some embodiments, if said allocated capacity is greater than said capacity threshold, the allocable capacity is said first capacity ÷ said first number of connections;
if the allocated capacity is less than or equal to the capacity threshold, the allocated capacity is the second capacity ÷ the second number of connections.
In some embodiments, said determining a first number of connections and a second number of connections based on said preconfigured number of connections comprises:
distributing the pre-configured connection number according to a first preset proportion to obtain a first connection number and a second connection number;
the determining the first capacity and the second capacity based on the total capacity comprises:
distributing the total capacity according to a second preset proportion to obtain a first capacity and a second capacity;
wherein the sum of the first preset proportion and the second preset proportion is 1.
In some embodiments, after the allocating the capacity to be allocated from the database memory in response to the memory allocation request, the method further includes:
updating the allocated capacity based on the capacity to be allocated.
In some embodiments, the method further comprises:
and if the capacity to be allocated is larger than the allocable capacity, responding to the memory allocation request to allocate the allocable capacity and the external memory capacity from the database memory.
In a second aspect, an embodiment of the present disclosure provides an apparatus for managing a database memory, including:
the device comprises an acquisition module, a storage allocation module and a processing module, wherein the acquisition module is used for acquiring a memory allocation request which comprises information of capacity to be allocated;
the adjusting module is used for adjusting the allocable capacity based on the preconfigured connection number, the total capacity of the database memory and the allocated capacity;
a response module, configured to respond to the memory allocation request to allocate the capacity to be allocated from the database memory if the capacity to be allocated is less than or equal to the allocable capacity.
In a third aspect, an embodiment of the present disclosure provides an electronic device, including:
a memory;
a processor; and
a computer program;
wherein the computer program is stored in the memory and configured to be executed by the processor to implement the method of the first aspect.
In a fourth aspect, the present disclosure provides a computer-readable storage medium, on which a computer program is stored, the computer program being executed by a processor to implement the method of the first aspect.
According to the method, the device, the equipment and the storage medium for managing the database memory, the distributable capacity is adjusted according to the preset connection number, the total capacity and the distributed capacity of the database memory, and the size of the distributable capacity is determined; if the capacity to be allocated is less than or equal to the allocable capacity, the capacity to be allocated is allocated from the database memory in response to the memory allocation request, so that the kernel can meet the memory requirements of different SQL statement operations, namely, the SQL statement operation with a small memory requirement obtains the memory with the capacity to be allocated, the SQL statement operation with a large memory requirement obtains the memory with the allocable capacity, the memory is optimized, the speed is increased, and the performance is improved.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and together with the description, serve to explain the principles of the disclosure.
In order to more clearly illustrate the embodiments or technical solutions in the prior art of the present disclosure, the drawings used in the description of the embodiments or prior art will be briefly described below, and it is obvious for those skilled in the art that other drawings can be obtained according to the drawings without inventive exercise.
FIG. 1 is a flow chart of a method for managing database memory provided by an embodiment of the present disclosure;
fig. 2 is a schematic diagram of an application scenario provided by the embodiment of the present disclosure;
FIG. 3 is a flow chart for adjusting allocable capacity provided by an embodiment of the present disclosure;
fig. 4 is a flowchart for determining allocable capacity according to an embodiment of the present disclosure;
FIG. 5 is a schematic diagram comparing a prior art and another embodiment of the present disclosure;
FIG. 6 is a flowchart of a method for managing database memory according to another embodiment of the present disclosure;
fig. 7 is a schematic structural diagram of an apparatus for managing database memory according to an embodiment of the present disclosure;
fig. 8 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure.
Detailed Description
In order that the above objects, features and advantages of the present disclosure may be more clearly understood, aspects of the present disclosure will be further described below. It should be noted that the embodiments and features of the embodiments of the present disclosure may be combined with each other without conflict.
In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present disclosure, but the present disclosure may be practiced in other ways than those described herein; it is to be understood that the embodiments disclosed in the specification are only a few embodiments of the present disclosure, and not all embodiments.
For a database, operations such as sorting and hashing need to occupy a memory to process input data. The occupied memory is generally called local memory in the database, and if the local memory is not enough, the occupied memory needs to occupy external memory to assist in processing data, which results in performance degradation. Therefore, the proper allocation of local memory directly affects the performance of Structured Query Language (SQL) statements.
In general, the database treats the local memory occupation requirement of each SQL statement equally, and the equal allocation algorithm makes the SQL statement with a large memory occupation requirement unable to obtain the required memory occupation, and the SQL statement with a small memory occupation requirement wastes the corresponding memory occupation.
To address this problem, embodiments of the present disclosure provide a method for managing a database memory, and the method is described below with reference to specific embodiments.
Fig. 1 is a flowchart of a method for managing a database memory according to an embodiment of the disclosure. The method can be applied to the application scenario shown in fig. 2, where the application scenario includes a server 21 and a terminal 22, and the terminal 22 may specifically be a smart phone, a palm computer, a tablet computer, a wearable device with a display screen, a desktop computer, a notebook computer, an all-in-one machine, an intelligent home device, and the like. It can be understood that the method for managing the database memory provided by the embodiment of the present disclosure may also be applied in other scenarios.
The following describes, with reference to the application scenario shown in fig. 2, a method for managing a database memory shown in fig. 1, where the method includes the following specific steps:
s101, obtaining a memory allocation request, wherein the request comprises information of capacity to be allocated.
The storage devices are classified into a main storage device and a secondary storage device according to their purposes, the main storage device is also called an internal storage device (abbreviated as "internal storage"), and the secondary storage device is also called an external storage device (abbreviated as "external storage"). The memory is characterized by high access speed and small capacity; the external memory is characterized by large capacity and slow access speed. The memory is used for storing programs and data to be used immediately; the external memory is used for storing programs and data which are not used for the moment. Information is often frequently exchanged between memory and external memory. The memory is a storage space which can be directly addressed by the CPU and is made of a semiconductor device; the external memory is typically a magnetic medium or an optical disk, such as a hard disk, floppy disk, magnetic tape, CD, etc., which can hold information for a long period of time and does not rely on electricity to hold the information.
The server 21 obtains a memory allocation request required for processing data by an operation, where the operation may be a sorting operation, a hash operation, and the like, and the sorting operation will be described later by taking the sorting as an example; the sequencing request comprises information of the capacity to be allocated, and after the operation request is determined, the information of the capacity to be allocated is fixed, namely a fixed value.
Sorting is an operation that is often performed in computers, the purpose of which is to adjust a set of "unordered" sequences of records to an "ordered" sequence of records. The sorting is divided into internal sorting and external sorting, and if the whole sorting process can be completed without accessing an external memory, the sorting is internal sorting; if the number of records participating in sorting is large, the sorting process of the whole sequence can be completed only by accessing an external memory, and the sorting is external sorting. Common sorting algorithms are insert sorting, merge sorting, select sorting, swap sorting, merge sorting, radix sorting, etc.
Hash, which is a translation of a Hash, or transliteration into a Hash, is the transformation of an input of arbitrary length (also called a pre-mapped pre-image) into a fixed-length output by a hashing algorithm, where the fixed-length output is a Hash value. This conversion is a compression mapping, i.e. the space of hash values is usually much smaller than the space of inputs, different inputs may hash to the same output, so it is not possible to determine a unique input value from a hash value. The hash algorithm can be divided into two categories, namely ordinary hash and encrypted hash.
Optionally, the memory may be a local memory.
And S102, adjusting the allocable capacity based on the preset connection number, the total capacity of the database memory and the allocated capacity.
The number of connections is the number of connections that a visitor takes when accessing a web site, and sometimes a visitor may take multiple connections depending on the program. If the number of connections made by the web site exceeds the limits of the web site, an indication of excessive connections is displayed.
The server 21 adjusts the allocable capacity according to the preconfigured number of connections, the total capacity of the database memory and the allocated capacity.
And S103, if the capacity to be allocated is less than or equal to the allocable capacity, responding to the memory allocation request and allocating the capacity to be allocated from the database memory.
If the capacity to be allocated is less than or equal to the allocable capacity, responding to the memory allocation request, and allocating the capacity to be allocated from the database memory;
and if the capacity to be allocated is larger than the allocable capacity, allocating the allocable capacity and the external memory capacity from the database memory in response to the memory allocation request.
The method comprises the steps that the allocable capacity is adjusted according to the preset connection number, the total capacity and the allocated capacity of the database memory, and the size of the allocable capacity of the memory is determined; if the capacity to be allocated is less than or equal to the allocable capacity, the capacity to be allocated is allocated from the database memory in response to the memory allocation request, so that the kernel can meet the memory requirements of different SQL statement operations, namely, the SQL statement operation with a small memory requirement obtains the memory with the capacity to be allocated, the SQL statement operation with a large memory requirement obtains the memory with the allocable capacity, the memory is optimized, the speed is increased, and the performance is improved.
In some embodiments, the step S102 of adjusting the allocable capacity based on the preconfigured number of connections, the total capacity of the database memory, and the allocated capacity may include the following steps S301 to S303, as shown in fig. 3:
s301, distributing the preset connection number according to a first preset proportion to obtain a first connection number and a second connection number; the first connection number is greater than the second connection number, and the first connection number is less than the pre-configured connection number.
For example, if the number of connections configured in advance is 1000, and the first preset ratio is 80%, the user configures 1000 connections in advance, and the assignment is performed according to the first preset ratio of 80%, where the first connection number is the number of connections configured in advance × the first preset ratio, the second connection number is the number of connections configured in advance — the first connection number, and the first connection number is 800, the second connection number is 200, the first connection number 800 is greater than the second connection number 200, and the first connection number 800 is less than the connection number 1000 configured in advance.
S302, distributing the total capacity according to a second preset proportion to obtain a first capacity and a second capacity; wherein the first capacity is less than the second capacity, and the second capacity is less than the total capacity; the sum of the first preset proportion and the second preset proportion is 1.
For example, when the total capacity size is 10GB 10240MB, and the first preset ratio is 80%, the sum of the first preset ratio and the second preset ratio is 1, and the second preset ratio is 1 — the first preset ratio, that is, the second preset ratio is 20%, the total capacity size is configured to be 10GB, and the allocation is performed according to the second preset ratio of 20%, then the first capacity is the total capacity × the second preset ratio, and the second capacity is the total capacity — the first capacity, and the first capacity is 20GB, the second capacity is 80GB, the first capacity 20GB is smaller than the second capacity 80GB, and the second capacity 80GB is smaller than the total capacity 100 GB.
S303, determining a capacity threshold according to the total capacity; the allocable capacity is adjusted based on the capacity threshold, the allocated capacity, the first number of connections, the second number of connections, the first capacity and the second capacity.
Optionally, the number of connections and the total capacity configured in advance may also be divided into three or more, which is not limited in this embodiment.
According to the embodiment of the disclosure, the method for managing the memory of the database is more comprehensive and specific by determining the first connection number, the second connection number, the first capacity and the second capacity.
In some embodiments, adjusting the allocable capacity according to the capacity threshold, the allocated capacity, the first connection number, the second connection number, the first capacity and the second capacity in step S303, as shown in fig. 4, may include the following steps S401 to S403:
s401, judging whether the allocated capacity is larger than a capacity threshold value, if not, executing a step S402; if yes, go to step S403.
Judging whether the allocated capacity is larger than a capacity threshold value; for example, the capacity threshold is 80GB, if the allocated capacity is 80GB, that is, the allocated capacity is 80GB and is equal to the capacity threshold 80GB, step S402 is executed; if the allocated capacity is 70GB, that is, the allocated capacity is 70GB is less than the capacity threshold 80GB, execute step S402; if the allocated capacity is 90GB, i.e. the allocated capacity 90GB is greater than the capacity threshold 80GB, step S403 is executed.
And S402, determining the allocable capacity according to the second capacity and the second connection number, wherein the allocable capacity is the second capacity/the second connection number.
When the allocated capacity is 80GB, determining the allocable capacity according to the second capacity 80GB and the second connection number 200, where the allocable capacity is 80GB ÷ 81920MB, 81920MB ÷ 200 ═ 409.6MB, and thus the allocable capacity is 409.6 MB; when the allocated capacity is 70GB, the allocable capacity is determined based on the second capacity 80GB and the second connection number 200, and the allocable capacity is 80 GB/81920 MB, 81920 MB/200 409.6MB, and thus the allocable capacity is 409.6 MB.
And S403, determining the allocable capacity according to the first capacity and the first connection number, wherein the allocable capacity is the first capacity/the first connection number.
The allocable capacity is determined based on the first capacity 20GB and the first connection number 800, and is determined to be the first capacity ÷ first connection number, i.e., 20GB 20480MB and 20480MB ÷ 800 ÷ 25.6MB, and thus is 25.6 MB.
The method and the device for managing the database memory improve the accuracy of the method for managing the database memory by determining the allocable capacity.
In some embodiments, after allocating the capacity to be allocated from the database memory in response to the memory allocation request, the method further comprises: and updating the allocated capacity according to the capacity to be allocated, wherein the updated allocated capacity is equal to the original allocated capacity plus the capacity to be allocated.
The embodiment of the disclosure improves the flexibility of the method for managing the memory of the database by updating the allocated capacity.
In some embodiments, after the memory operation is finished, the memory is recycled; that is, the allocated capacity is updated again, and the updated allocated capacity is the updated allocated capacity-to-be-allocated capacity.
The embodiment of the disclosure further improves the flexibility of the method for managing the memory of the database through memory recovery.
Fig. 5 is a schematic diagram comparing a prior art and another embodiment of the present disclosure, as shown in fig. 5, in the prior art, a user configures 1000 connections, the total memory capacity is 100GB, and when the allocable memory capacity is 100GB, the average allocated memory calculation method is 100 GB-102400 MB, 102400MB ÷ 1000 ÷ 102.4MB, and 1024MB is configured as the memory occupied by each operation. If the SQL statement requires 200MB of memory for sorting, the external memory will be used due to insufficient memory, resulting in poor performance. A flowchart of a method for managing a database memory according to another embodiment of the present disclosure is shown in fig. 6, where the method includes the following specific steps:
s601, pre-configuring the number of connections, the total capacity and the allocated capacity of the database memory.
The number of connections is 1000, the total capacity of the database memory is 100CB, and the allocated memory is the memory occupied by the ongoing operation.
S602, determining a first connection number and a second connection number according to a preset connection number, and determining a first capacity, a second capacity and a capacity threshold according to the total capacity of a database memory.
The preconfigured connection number is 1000, when the first preset proportion is 80%, the user preconfigured 1000 connection numbers, and allocates them according to the first preset proportion of 80%, the first connection number is the preconfigured connection number × the first preset proportion, the second connection number is the preconfigured connection number — the first connection number, and the first connection number is 800, the second connection number is 200, the first connection number 800 is greater than the second connection number 200, and the first connection number 800 is less than the preconfigured connection number 1000. When the total capacity size is 10GB 10240MB, since the sum of the first preset proportion and the second preset proportion is 1, the second preset proportion is 1 — the first preset proportion, that is, the second preset proportion is 20%, the total capacity size is configured to be 10GB, and the allocation is performed according to the second preset proportion of 20%, then the first capacity is the total capacity × the second preset proportion, the second capacity is the total capacity — the first capacity, the first capacity is obtained to be 20GB, the second capacity is 80GB, the first capacity 20GB is smaller than the second capacity 80GB, and the second capacity 80GB is smaller than the total capacity 100 GB. The capacity threshold is a value set according to the total capacity of the database memory, and is a fixed value. For example, the capacity threshold may be 80 GB.
S603, judging whether the allocated capacity is larger than a capacity threshold value, if not, executing a step S604; if yes, go to step S605.
Judging whether the allocated capacity is greater than a capacity threshold value of 80GB, if the allocated capacity is 80GB, namely the allocated capacity is 80GB and is equal to the capacity threshold value of 80GB, executing a step S604; if the allocated capacity is 70GB, that is, the allocated capacity is 70GB is less than the capacity threshold 80GB, go to step S604; if the allocated capacity is 90GB, i.e. the allocated capacity 90GB is greater than the capacity threshold 80GB, step S605 is executed.
S604, determining the allocable capacity as second capacity ÷ second connection number.
When the allocated capacity is 80GB, determining the allocable capacity according to the second capacity 80GB and the second connection number 200, where the allocable capacity is 80GB ÷ 81920MB, 81920MB ÷ 200 ═ 409.6MB, and thus the allocable capacity is 409.6 MB; when the allocated capacity is 70GB, the allocable capacity is determined based on the second capacity 80GB and the second connection number 200, and the allocable capacity is 80 GB/81920 MB, 81920 MB/200 409.6MB, and thus the allocable capacity is 409.6 MB.
S605 determines that the allocable capacity is the first capacity ÷ the first connection number.
The allocable capacity is determined based on the first capacity 20GB and the first connection number 800, and is determined to be the first capacity ÷ first connection number, i.e., 20GB 20480MB and 20480MB ÷ 800 ÷ 25.6MB, and thus is 25.6 MB.
S606, judging whether the capacity of the memory allocation request is larger than the allocable capacity, if not, executing a step S607; if yes, go to step S608.
Judging whether the current operation memory allocation request capacity is larger than the allocable capacity or not; for example, when the allocated capacity is 90GB and greater than the capacity threshold 80GB, the currently allocable capacity is 25.6MB, if the memory allocation request capacity of the sorting operation is 20MB, that is, the memory allocation request capacity is smaller than the allocable capacity, step S607 is executed; if the hash operation memory allocation request size is 30MB, step S608 is executed.
Optionally, when the allocable capacity is less than or equal to the capacity threshold, the same principle is also applied, and details are not described here.
S607, the capacity to be allocated is the capacity of the memory allocation request.
The memory capacity to be allocated for the sorting operation is the capacity of the memory allocation request, i.e. 20 MB.
And S608, the capacity to be allocated is the allocable capacity, and the capacity of the operation allocation request is the allocable capacity + the external memory.
The capacity to be allocated in the hash operation memory is 25.6MB of allocable capacity, and the capacity of the hash operation allocation request is 30MB, namely the allocable capacity is 25.6MB + external memory.
And S609, updating the allocated capacity.
And the updated allocated capacity is equal to the original allocated capacity plus the capacity to be allocated. For example: the sequencing operation updates the allocated capacity to 90GB +20 MB; the hash operation updates the allocated capacity to 90GB +25.6 MB.
And S610, ending the operation.
S611, recycling the memory.
After the operation is finished, the size of the allocated memory is updated again, and the updated allocated capacity is the updated allocated capacity-to-be-allocated capacity.
Fig. 7 is a schematic structural diagram of an apparatus for managing a database memory according to an embodiment of the present disclosure. The means for managing the database memory may be the electronic device as described in the above embodiments, or the means for managing the database memory may be a component or an assembly in the electronic device. As shown in fig. 7, the apparatus for managing a database memory 70 provided in the embodiment of the present disclosure may execute the processing procedure provided in the embodiment of the method for managing a database memory, and includes: an acquisition module 71, an adjustment module 72, and a response module 73; the acquiring module 71 is configured to acquire a memory allocation request, where the request includes information of a capacity to be allocated; an adjusting module 72, configured to adjust the allocable capacity based on the preconfigured number of connections, the total capacity of the database memory, and the allocated capacity; a response module 73, configured to, if the capacity to be allocated is less than or equal to the allocable capacity, allocate the capacity to be allocated from the database memory in response to the memory allocation request.
Optionally, the adjusting module 72 includes a determining unit 721 and a judging unit 722, where the determining unit 721 is configured to determine the first connection number and the second connection number based on the preconfigured connection number; the first connection number is greater than the second connection number and is less than the preset connection number; determining a first capacity and a second capacity based on the total capacity; wherein the first capacity is less than the second capacity, and the second capacity is less than the total capacity; determining a capacity threshold based on the total capacity; an adjusting module 72 for adjusting the allocable capacity based on the capacity threshold, the allocated capacity, the first number of connections, the second number of connections, the first capacity and the second capacity.
Optionally, the adjusting module 72 includes a determining unit 721 and a judging unit 722, wherein the judging unit 722 is configured to judge whether the allocated capacity is larger than the capacity threshold; a determining unit 721 configured to determine an allocatable capacity based on the first capacity and the first connection number if the allocated capacity is larger than the capacity threshold; or, if the allocated capacity is less than or equal to the capacity threshold, determining the allocable capacity based on the second capacity and the second connection number.
Optionally, the determining unit 721 is further configured to allocate the capacity as the first capacity ÷ the first number of connections if the allocated capacity is greater than the capacity threshold; if the allocated capacity is less than or equal to the capacity threshold, the capacity may be allocated a second capacity ÷ second number of connections.
Optionally, the determining unit 721 is further configured to determine, based on the preconfigured number of connections, that the first number of connections and the second number of connections include: distributing the pre-configured connection number according to a first preset proportion to obtain a first connection number and a second connection number; determining the first capacity and the second capacity based on the total capacity includes: distributing the total capacity according to a second preset proportion to obtain a first capacity and a second capacity; wherein the sum of the first preset proportion and the second preset proportion is 1.
Optionally, the response module 73 further includes an update module 731, where after the update module 731 is configured to allocate the capacity to be allocated from the database memory in response to the memory allocation request, the method further includes: the allocated capacity is updated based on the capacity to be allocated.
Optionally, the response module 73 is further configured to, if the capacity to be allocated is greater than the allocable capacity, allocate the allocable capacity and the external memory capacity from the database memory in response to the memory allocation request.
The apparatus for managing a database memory according to the embodiment shown in fig. 7 can be used to implement the technical solution of the above method embodiment, and the implementation principle and the technical effect are similar, which are not described herein again.
Fig. 8 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure. As shown in fig. 8, the electronic device 80 may execute the processing procedure provided in the method for managing a database memory according to the embodiment of the present disclosure, and includes: memory 81, processor 82, computer programs and communication interface 83; wherein the computer program is stored in the memory 81 and is configured to be executed by the processor 82 for the method of managing database memory as described above.
In addition, the embodiment of the present disclosure also provides a computer-readable storage medium, on which a computer program is stored, where the computer program is executed by a processor to implement the method for managing a database memory according to the foregoing embodiment.
It should be noted that the computer readable medium in the present disclosure can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In contrast, in the present disclosure, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
In some embodiments, the clients, servers may communicate using any currently known or future developed network Protocol, such as HTTP (HyperText Transfer Protocol), and may interconnect with any form or medium of digital data communication (e.g., a communications network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), the Internet (e.g., the Internet), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future developed network.
The computer readable medium may be embodied in the electronic device; or may exist separately without being assembled into the electronic device.
The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to:
acquiring a memory allocation request, wherein the request comprises information of capacity to be allocated;
based on the pre-configured connection number, the total capacity of the database memory and the allocated capacity, adjusting the allocable capacity;
and if the capacity to be allocated is less than or equal to the allocable capacity, responding to the memory allocation request to allocate the capacity to be allocated from the database memory.
In addition, the electronic device may also perform other steps in the method for managing the database memory as described above.
Computer program code for carrying out operations for the present disclosure may be written in any combination of one or more programming languages, including but not limited to an object oriented programming language such as Java, Smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present disclosure may be implemented by software or hardware. Where the name of an element does not in some cases constitute a limitation on the element itself.
The functions described herein above may be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field Programmable Gate Arrays (FPGAs), Application Specific Integrated Circuits (ASICs), Application Specific Standard Products (ASSPs), systems on a chip (SOCs), Complex Programmable Logic Devices (CPLDs), and the like.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
It is noted that, in this document, relational terms such as "first" and "second," and the like, may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The foregoing are merely exemplary embodiments of the present disclosure, which enable those skilled in the art to understand or practice the present disclosure. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the disclosure. Thus, the present disclosure is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (10)

1. A method of managing database memory, the method comprising:
acquiring a memory allocation request, wherein the request comprises information of capacity to be allocated;
based on the pre-configured connection number, the total capacity of the database memory and the allocated capacity, adjusting the allocable capacity;
and if the capacity to be allocated is less than or equal to the allocable capacity, responding to the memory allocation request to allocate the capacity to be allocated from the database memory.
2. The method of claim 1, wherein adjusting the allocable capacity based on the preconfigured number of connections, the total capacity of the database memory, and the allocated capacity comprises:
determining a first connection number and a second connection number based on the preconfigured connection number; wherein the first connection number is greater than the second connection number, and the first connection number is less than the preconfigured connection number;
determining a first capacity and a second capacity based on the total capacity; wherein the first capacity is less than the second capacity, and the second capacity is less than the total capacity;
determining a capacity threshold based on the total capacity;
adjusting an allocable capacity based on the capacity threshold, the allocated capacity, the first number of connections, the second number of connections, the first capacity, and the second capacity.
3. The method of claim 2, wherein the adjusting allocable capacity based on the capacity threshold, the allocated capacity, the first number of connections, the second number of connections, the first capacity, and the second capacity comprises:
determining whether the allocated capacity is greater than the capacity threshold;
if the allocated capacity is larger than the capacity threshold, determining allocable capacity based on the first capacity and the first connection number; or the like, or, alternatively,
and if the allocated capacity is smaller than or equal to the capacity threshold, determining the allocable capacity based on the second capacity and the second connection number.
4. The method of claim 3, wherein if said allocated capacity is greater than said capacity threshold, the allocable capacity is said first capacity ÷ said first number of connections;
if the allocated capacity is less than or equal to the capacity threshold, the allocated capacity is the second capacity ÷ the second number of connections.
5. The method of claim 2, wherein determining the first number of connections and the second number of connections based on the preconfigured number of connections comprises:
distributing the pre-configured connection number according to a first preset proportion to obtain a first connection number and a second connection number;
the determining the first capacity and the second capacity based on the total capacity comprises:
distributing the total capacity according to a second preset proportion to obtain a first capacity and a second capacity;
wherein the sum of the first preset proportion and the second preset proportion is 1.
6. The method of claim 1, wherein after allocating the capacity to be allocated from the database memory in response to the memory allocation request, the method further comprises:
updating the allocated capacity based on the capacity to be allocated.
7. The method of claim 1, further comprising:
and if the capacity to be allocated is larger than the allocable capacity, responding to the memory allocation request to allocate the allocable capacity and the external memory capacity from the database memory.
8. An apparatus for managing database memory, comprising:
the device comprises an acquisition module, a storage allocation module and a processing module, wherein the acquisition module is used for acquiring a memory allocation request which comprises information of capacity to be allocated;
the adjusting module is used for adjusting the allocable capacity based on the preconfigured connection number, the total capacity of the database memory and the allocated capacity;
a response module, configured to respond to the memory allocation request to allocate the capacity to be allocated from the database memory if the capacity to be allocated is less than or equal to the allocable capacity.
9. An electronic device, comprising:
a memory;
a processor; and
a computer program;
wherein the computer program is stored in the memory and configured to be executed by the processor to implement the method of any one of claims 1-7.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1-7.
CN202111593090.6A 2021-12-23 2021-12-23 Method, device and equipment for managing database memory and storage medium Pending CN114253730A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111593090.6A CN114253730A (en) 2021-12-23 2021-12-23 Method, device and equipment for managing database memory and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111593090.6A CN114253730A (en) 2021-12-23 2021-12-23 Method, device and equipment for managing database memory and storage medium

Publications (1)

Publication Number Publication Date
CN114253730A true CN114253730A (en) 2022-03-29

Family

ID=80794683

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111593090.6A Pending CN114253730A (en) 2021-12-23 2021-12-23 Method, device and equipment for managing database memory and storage medium

Country Status (1)

Country Link
CN (1) CN114253730A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117349028A (en) * 2023-12-01 2024-01-05 苏州元脑智能科技有限公司 Memory capacity adjustment method and device, electronic equipment and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117349028A (en) * 2023-12-01 2024-01-05 苏州元脑智能科技有限公司 Memory capacity adjustment method and device, electronic equipment and storage medium
CN117349028B (en) * 2023-12-01 2024-02-27 苏州元脑智能科技有限公司 Memory capacity adjustment method and device, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
US11146502B2 (en) Method and apparatus for allocating resource
CN113495921B (en) Routing method and device for database cluster
US10235047B2 (en) Memory management method, apparatus, and system
CN112035529A (en) Caching method and device, electronic equipment and computer readable storage medium
CN109428926B (en) Method and device for scheduling task nodes
US20220229701A1 (en) Dynamic allocation of computing resources
CN114253730A (en) Method, device and equipment for managing database memory and storage medium
CN111241137A (en) Data processing method and device, electronic equipment and storage medium
CN112860421B (en) Method, apparatus and computer program product for job processing
CN109614089B (en) Automatic generation method, device, equipment and storage medium of data access code
CN113779412B (en) Message touch method, node and system based on blockchain network
US9860313B2 (en) Maintaining state synchronization of an application between computing devices as well as maintaining state synchronization of common information between different applications without requiring perioidic synchronization
CN115794396A (en) Resource allocation method, system and electronic equipment
CN115203210A (en) Hash table processing method, device and equipment and computer readable storage medium
CN115442129A (en) Method, device and system for managing cluster access authority
CN111756833B (en) Node processing method, node processing device, electronic equipment and computer readable medium
CN111090520B (en) User allocation method and device for exclusive resources, electronic equipment and storage medium
CN108683608B (en) Method and device for distributing flow
CN111581930A (en) Online form data processing method and device, electronic equipment and readable medium
CN112507676A (en) Energy report generation method and device, electronic equipment and computer readable medium
CN111694670A (en) Resource allocation method, device, equipment and computer readable medium
CN113127430A (en) Mirror image information processing method and device, computer readable medium and electronic equipment
CN114328558B (en) List updating method, apparatus, device and storage medium
CN112148448B (en) Resource allocation method, apparatus, device and computer readable medium
CN110022348B (en) System and method for dynamic backup sessions

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination