CN117742951A - Method, device, equipment and medium for managing memory of database system - Google Patents

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

Info

Publication number
CN117742951A
CN117742951A CN202311745493.7A CN202311745493A CN117742951A CN 117742951 A CN117742951 A CN 117742951A CN 202311745493 A CN202311745493 A CN 202311745493A CN 117742951 A CN117742951 A CN 117742951A
Authority
CN
China
Prior art keywords
memory
quota
memory quota
query
query operator
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.)
Granted
Application number
CN202311745493.7A
Other languages
Chinese (zh)
Other versions
CN117742951B (en
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.)
Shenzhen Institute of Computing Sciences
Original Assignee
Shenzhen Institute of Computing Sciences
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 Shenzhen Institute of Computing Sciences filed Critical Shenzhen Institute of Computing Sciences
Priority to CN202311745493.7A priority Critical patent/CN117742951B/en
Publication of CN117742951A publication Critical patent/CN117742951A/en
Application granted granted Critical
Publication of CN117742951B publication Critical patent/CN117742951B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application is applicable to the field of database management, and particularly relates to a method, a device, equipment and a medium for managing a memory of a database system. The method comprises the steps of distributing a first memory quota to query sentences, distributing a second memory quota to each execution stage in the first memory quota, distributing a third memory quota to each query operator in the second memory quota, and if the execution memory of the query operator is larger than the third memory quota in the execution process of the query operator, searching the remaining memory quota from the second memory quota, the first memory quota or all memory quotas of the database system in the execution stage to which the query operator belongs to expand the third memory quota of the query operator to obtain the expanded memory quota, and distributing the memory of the corresponding quota to execute the query operator. According to the method, dynamic expansion and release of memory quota are fully utilized according to real-time execution conditions of query operators, and the utilization rate of the memory is improved.

Description

Method, device, equipment and medium for managing memory of database system
Technical Field
The application is applicable to the field of database management, and particularly relates to a method, a device, equipment and a medium for managing a memory of a database system.
Background
In the process of executing database query sentences, the traditional database system mainly adopts a method of pre-allocating fixed memory to manage the memory, namely, before the database query sentences are executed, one fixed memory is pre-allocated for the database query sentences, in the process of executing the database query sentences, the database query sentences can only use the pre-allocated fixed memory and cannot exceed the pre-allocated fixed memory, and in the process of executing the query sentences, the pre-allocated fixed memory is fixed, if the pre-allocated fixed memory is too large enough to meet the requirement of executing the memory, the waste of memory resources is caused, and if the pre-allocated fixed memory is too small to meet the requirement of executing the memory, the overflow of the memory occurs in the process of executing the database query sentences, so that the performance problem is caused. Therefore, how to manage the database memory and improve the utilization rate of the memory is a urgent problem to be solved.
Disclosure of Invention
In view of this, the embodiments of the present application provide a method, an apparatus, a device, and a medium for managing a memory of a database system, so as to solve the problem of how to manage the memory of the database and improve the utilization rate of the memory.
In a first aspect, an embodiment of the present application provides a method for managing a database memory, where the method for managing a database system memory includes:
determining each execution stage in the query statement and a query operator belonging to any execution stage according to the acquired query statement;
allocating a first memory quota to the query statement, allocating a second memory quota to each execution stage in the first memory quota, and allocating a third memory quota to each query operator in the second memory quota;
if the required memory for executing any query operator is greater than the third memory quota allocated by the query operator, calling the remaining memory quota, expanding the third memory quota allocated by the query operator to obtain an expanded memory quota, wherein the expanded memory quota is used for supporting the execution of the query operator;
the residual memory quota is obtained by searching a second memory quota distributed in an execution stage to which the query operator belongs, the first memory quota or all memory quotas of the database system.
In a second aspect, an embodiment of the present application provides a database system memory management device, where the database system memory management device includes:
The first determining module is used for determining each execution stage in the query statement and query operators belonging to any execution stage according to the acquired query statement;
the first allocation module is used for allocating a first memory quota to the query statement, allocating a second memory quota to each execution stage in the first memory quota, and allocating a third memory quota to each query operator in the second memory quota;
the first expansion module is configured to, if a required memory for executing any query operator is greater than a third memory quota allocated by the query operator, invoke a remaining memory quota, expand the third memory quota allocated by the query operator to obtain an expanded memory quota, where the expanded memory quota is used to support execution of the query operator, and the remaining memory quota is obtained by searching from a second memory quota allocated by an execution stage to which the query operator belongs, the first memory quota, or all memory quotas of the database system.
In a third aspect, embodiments of the present application provide a computer device, where the computer device includes a processor, a memory, and a computer program stored in the memory and executable on the processor, where the processor implements the method for managing memory of a database system according to the first aspect when the computer program is executed.
In a fourth aspect, embodiments of the present application provide a computer readable storage medium storing a computer program, which when executed by a processor implements the method for managing memory of a database system according to the first aspect.
Compared with the prior art, the embodiment of the application has the beneficial effects that: according to the method and the device, the query statement is obtained, the first memory quota is allocated to the query statement, the second memory quota is allocated to each query stage in the first memory quota, the third memory quota is allocated to each query operator in the second memory quota, if the memory required by execution of any query operator is larger than the third memory quota, the second memory quota of the execution stage to which the query operator belongs, the first memory quota or the rest memory quota in all memory quotas of the database system are called to expand the third memory quota of the query operator, and the query operator is executed by using the expanded memory quota. In the execution process of the query operator, if the first memory quota of the query operator is insufficient to meet the requirement of executing the memory, searching the remaining memory quota from the second memory quota, the first memory quota or all memory quotas of the database system in the execution stage to which the query operator belongs to expand the third memory quota of the query operator, so that the dynamic expansion of the pre-allocated memory quota is realized according to the real-time execution condition of the query operator, the pre-allocated memory quotas are fully utilized, and the utilization rate of the memory is improved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are required for the embodiments or the description of the prior art will be briefly described below, it being obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a schematic view of an application environment of a method for managing memory in a database system according to an embodiment of the present application;
fig. 2 is a flow chart of a method for managing memory in a database system according to a second embodiment of the present application;
fig. 3 is a schematic diagram of an allocation structure of a first memory quota, a second memory quota, and a third memory quota provided in the second embodiment of the present application;
fig. 4 is a flow chart of a method for managing memory in a database system according to a third embodiment of the present application;
fig. 5 is a flowchart of a method for managing memory in a database system according to a fourth embodiment of the present application;
fig. 6 is a flowchart of a method for managing memory in a database system according to a fifth embodiment of the present application;
fig. 7 is a flowchart of a method for managing memory in a database system according to a sixth embodiment of the present application;
Fig. 8 is a flowchart of a method for managing memory in a database system according to a seventh embodiment of the present application;
fig. 9 is a flowchart of a method for managing memory in a database system according to an eighth embodiment of the present application;
fig. 10 is a schematic structural diagram of a memory management device of a database system according to a ninth embodiment of the present application;
fig. 11 is a schematic structural diagram of a computer device according to a tenth embodiment of the present application.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth, such as particular system configurations, techniques, etc. in order to provide a thorough understanding of the embodiments of the present application. It will be apparent, however, to one skilled in the art that the present application may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.
It should be understood that the terms "comprises" and/or "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
It should also be understood that the term "and/or" as used in this specification and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes such combinations.
As used in this specification and the appended claims, the term "if" may be interpreted as "when..once" or "in response to a determination" or "in response to detection" depending on the context. Similarly, the phrase "if a determination" or "if a [ described condition or event ] is detected" may be interpreted in the context of meaning "upon determination" or "in response to determination" or "upon detection of a [ described condition or event ]" or "in response to detection of a [ described condition or event ]".
In addition, in the description of the present application and the appended claims, the terms "first," "second," "third," and the like are used merely to distinguish between descriptions and are not to be construed as indicating or implying relative importance.
Reference in the specification to "one embodiment" or "some embodiments" or the like means that a particular feature, structure, or characteristic described in connection with the embodiment is included in one or more embodiments of the application. Thus, appearances of the phrases "in one embodiment," "in some embodiments," "in other embodiments," and the like in the specification are not necessarily all referring to the same embodiment, but mean "one or more but not all embodiments" unless expressly specified otherwise. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless expressly specified otherwise.
The embodiment of the application can acquire and process the related data based on the artificial intelligence technology. Wherein artificial intelligence is the intelligence of simulating, extending and expanding a person using a digital computer or a machine controlled by a digital computer, sensing the environment, obtaining knowledge, and using knowledge to obtain optimal results.
Artificial intelligence infrastructure technologies generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technologies, operation/interaction systems, mechatronics, and the like. The artificial intelligence software technology mainly comprises a computer vision technology, a robot technology, a biological recognition technology, a voice processing technology, a natural language processing technology, machine learning/deep learning and other directions.
It should be understood that the sequence numbers of the steps in the following embodiments do not mean the order of execution, and the execution order of the processes should be determined by the functions and the internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
In order to illustrate the technical solution of the present application, the following description is made by specific examples.
The first embodiment of the present application provides a method for managing memory of a database system, which can be applied in an application environment as shown in fig. 1, wherein a server communicates with a client, the server provides a memory management service of the database system, and the client sends a memory management task of the database system to the server. The clients include, but are not limited to, palm top computers, desktop computers, notebook computers, ultra-mobile personal computer (UMPC), netbooks, cloud computing devices, personal digital assistants (personal digital assistant, PDA), and the like. The computer device corresponding to the server may be implemented by an independent server or a server cluster formed by a plurality of servers.
Referring to fig. 2, a flow chart of a method for managing a memory of a database system according to a second embodiment of the present application is provided, where the method for managing a memory of a database system is applied to a server in fig. 1, specifically, a database system of a server, so as to manage a memory corresponding to the database system, and the server may obtain a corresponding query statement from a client, and perform management operations such as calling and allocating the memory in a process of executing the query statement. As shown in fig. 2, the method for managing the memory of the database system may include the following steps:
step S201, according to the acquired query statement, determining each execution stage in the query statement and query operators belonging to any execution stage.
In this embodiment of the present application, a query statement may refer to a statement used for database query, where a query language corresponding to the query statement needs to be a query language that can be processed by a server, and the query statement may be sent by a client or provided by other users. For example, structured query language (Structured Query Language, SQL) based query statements: "SELECT FROM a, B, C WHERE a.1=b.2and b.1=c.1; ".
The execution stage may refer to a plan segment in an execution plan corresponding to the query statement, where the execution plan may refer to an execution path of the query statement in the database, where the execution path includes a sub-path that can be executed in parallel, a sub-path that can be executed in a distributed manner, and the like, where the sub-paths that can be separately executed and individually correspond to the plan segment, and the above process may be obtained by analyzing the query statement.
For example, if there is a table 1, the table 1 contains employee information including employee ID, name, wage, etc., and the query statement is to query the table 1 for all employee information with wage higher than 5000, and to output the employee information in order according to employee ID. The database query statement may be: "SELECT employee ID, name, payroll table 1WHERE payroll >5000ORDER BY employee ID; an execution plan generated by analyzing the query statement may be: the method comprises the following steps of executing step 1, scanning the table 1, obtaining records of all staff, filtering the obtained staff records, and only keeping records of staff with wages higher than 5000; an execution stage 2, wherein the results of the execution stage 1 are ordered according to the ascending order of employee IDs; and 3, returning a final query result. According to the above example, it may be known that the execution plan of the query statement includes 3 execution phases, and the query purpose of the query statement may be completed by executing the 3 execution phases in sequence, where the execution phases in different execution plans and the execution sequence of each execution phase may be different.
The query operators may refer to basic operations in query processing, which can complete specific computing functions, where all query operators are included in the execution plan, and at least one query operator may be included in a plan segment, where, of course, at least two query operators with the same function may be included in one execution plan, and in the execution process, query operators with the same function are not combined into one operator, and each operator is independently operated.
For example, the query operator may be a scanning operator, a filtering operator, a linking operator, a grouping operator, a sorting operator, and the like, and each type of query operator is used for completing a specific basic operation, where the scanning operator may be used for scanning all data in a table and performing preliminary processing on the data according to requirements; the filtering operator can be used for filtering data in the table according to a certain condition in the query statement; the join operator may be used to merge the data in two or more tables according to specified join conditions; the grouping operator can be used for grouping the data according to the grouping conditions of the execution and performing an aggregation operation on each group; the sort operator may be used to sort the data according to specified sort conditions. It should be noted that specific query operators and operations may vary according to the database system, and the query operators and operations to be used may be determined according to actual situations.
In the process of determining each execution stage in a query sentence and query operators belonging to any execution stage, firstly, carrying out grammar analysis on the obtained query sentence to generate a plurality of original execution plans, evaluating each original execution plan, selecting an optimal plan as a target query plan, then, determining all query operators and the execution sequence corresponding to each query operator according to the target query plan, finally, determining the query operators with the dependency relationship before and after execution according to the type of each query operator and the execution sequence of each query operator, and grouping the query operators with the dependency relationship before and after execution into the same execution stage, thereby obtaining all query operators in each execution stage, wherein in each execution stage, the execution of all query operators has a sequential order, no execution sequence front and back relationship exists between the query operators in any two execution stages, and the execution stages are independent and can be simultaneously executed in a multiprocessor or a distributed database system.
Step S202, a first memory quota is allocated to the query statement, a second memory quota is allocated to each execution stage in the first memory quota, and a third memory quota is allocated to each query operator in the second memory quota.
In this embodiment of the present application, the first memory quota may be a memory resource allocated in advance for executing the query statement when executing the query statement, so as to prepare for execution and use of the query statement; the second memory quota may be memory resources allocated in advance for executing each execution stage when executing each execution stage in the query statement, so as to be used by executing each execution stage; the third memory quota may be memory resources pre-allocated for each query operator in executing each query operator in each execution phase for use in preparing for execution by the query operator.
The memory quota may be a memory resource with a certain size that is preconfigured according to the requirement, or may be obtained by evaluating and calculating a memory required by execution of a corresponding task. For example, the memory quota is preconfigured according to the requirement, and the memory quota may be preconfigured through a preset mapping table, where the preset mapping table may include a correspondence between types of query operators such as a sorting operator, a connection operator, an aggregation operator, and an index operator in a query statement and an amount of memory occupied by executing the corresponding types of query operators, and content of the preset mapping table may be preconfigured according to the specific requirement. In the process of obtaining the memory quota based on the preset mapping table, the preset mapping table can be queried according to the types and the numbers of all query operators in the query statement to obtain a first memory quota allocated to the query statement, the preset mapping table is queried according to the types and the numbers of all query operators in each execution stage of the query statement to obtain a second memory quota allocated to each execution stage in the first memory quota, the preset mapping table is queried according to the types of the query operators to obtain a third memory quota allocated to each query operator in the second memory quota of the execution stage to which the query operator belongs.
Referring to fig. 3, two query sentences, namely a query sentence 1 and a query sentence 2, are being executed in the database system, where the first memory quota 1 is a memory resource pre-allocated in the database system memory for executing the query sentence 1, and the first memory quota 2 is a memory resource pre-allocated in the database system memory for executing the query sentence 2; the query statement 1 comprises an execution stage 1 and an execution stage 2, wherein the second memory quota 1 is memory resources which are allocated in advance for executing the execution stage 1 in the first memory quota 1, and the second memory quota 2 is memory resources which are allocated in advance for executing the execution stage 2 in the first memory quota 1; the execution stage 1 comprises a query operator 1 and a query operator 2, wherein a third memory quota 1 is memory resources which are allocated in advance for the execution of the query operator 1 in a second memory quota 1, and a third memory quota 2 is memory resources which are allocated in advance for the execution of the query operator 2 in the second memory quota 1; the execution stage 2 comprises a query operator 3 and a query operator 4, wherein the third memory quota 3 is memory resources which are allocated in advance for executing the query operator 3 in the second memory quota 2, and the third memory quota 4 is memory resources which are allocated in advance for executing the query operator 4 in the second memory quota 2; the allocation structure for the first memory quota, the second memory quota, and the third memory quota for query statement 2 may refer to the allocation structure in query statement 1.
Step S203, if the required memory for executing any query operator is greater than the third memory quota allocated by the query operator, the remaining memory quota is called, and the third memory quota allocated by the query operator is expanded, so as to obtain an expanded memory quota.
The extended memory quota is used for supporting execution of the query operator, that is, after the extended memory quota is obtained, the query operator can allocate the memory of the corresponding quota to execute the query operator, and the remaining memory quota is obtained by searching from the second memory quota allocated in the execution stage to which the query operator belongs, the first memory quota or all memory quotas of the database system.
In this embodiment of the present application, the remaining memory quota may refer to an unused memory amount or an unused memory amount of the total memory occupied by the database system, or the remaining memory quota may be an unused memory amount of a first memory quota allocated in the database system, or an unused memory amount of a second memory quota allocated in the first memory quota. The query of the remaining memory quota can be checked and monitored through a management interface, for example, the use condition of the memory of the database system can be queried through a database management interface, and the use condition of the memory of other systems outside the database system can be checked through a command line tool or a task manager.
In the process of calling the residual memory quota to expand the third memory quota of the query operator, firstly, calculating the memory quota which needs to be increased of the query operator according to the memory which is needed by the execution of the query operator and the pre-allocated third memory quota, then, inquiring whether the second memory quota, the first memory quota and the residual memory quota in the database system memory of the execution stage which the query operator belongs to are larger than or equal to the memory quota which needs to be increased of the query operator or not through a database management interface, and finally, if the residual memory quota is larger than or equal to the memory quota which needs to be increased of the query operator, reading the memory quota which is the same as the memory quota which needs to be increased of the query operator from the residual memory quota through a specific function or instruction, and expanding the read memory resources to the third memory quota which is allocated to the query operator to obtain the expanded memory quota.
The extended memory quota may refer to a memory quota obtained by calling the remaining memory quota to be extended on the basis of a third memory quota corresponding to the query operator. The expansion of the third memory quota allocated to the query operator can be performed by calling any one of the second memory quota allocated to the execution stage to which the query operator belongs, the first memory quota and all memory quotas of the database system to expand the third memory quota, or can be performed by selecting a specific memory quota from the second memory quota, the first memory quota and all memory quotas of the database system corresponding to the query operator according to the actual execution situation.
According to the method and the device, the query statement is obtained, the first memory quota is allocated to the query statement, the second memory quota is allocated to each query stage in the first memory quota, the third memory quota is allocated to each query operator in the second memory quota, if the memory required by execution of any query operator is larger than the third memory quota, the second memory quota of the execution stage to which the query operator belongs, the first memory quota or the rest memory quota in all memory quotas of the database system are called to expand the third memory quota of the query operator, and the query operator is executed by using the expanded memory quota. In the execution process of the query operator, if the first memory quota of the query operator is insufficient to meet the requirement of executing the memory, searching the remaining memory quota from the second memory quota, the first memory quota or all memory quotas of the database system in the execution stage to which the query operator belongs to expand the third memory quota of the query operator, so that the dynamic expansion of the pre-allocated memory quota is realized according to the real-time execution condition of the query operator, the pre-allocated memory quotas are fully utilized, and the utilization rate of the memory is improved.
Referring to fig. 4, a flowchart of a method for managing a memory of a database system according to a third embodiment of the present application is provided. As shown in fig. 4, allocating a first memory quota to the query statement in step S201, allocating a second memory quota to each execution stage in the first memory quota, and allocating a third memory quota to each query operator in the second memory quota may include the following steps:
step S301, the memory required by each query operator is evaluated, and a first evaluation result is obtained.
In the embodiment of the present application, the first evaluation result is an evaluation of a memory required for executing each query operator, where the evaluation is obtained by respectively evaluating each query operator, and the evaluation process is an execution process of simulating the corresponding query operator, so as to calculate a memory of storage data required to be occupied in the simulated execution process.
And evaluating the memory required by the execution of each query operator, wherein the evaluation can be performed according to the algorithm of each query operator, the record number required to be processed by the query operator, the record number after the duplication removal of certain fields, the table metadata information, concurrent operation and other aspects. For example, if the memory evaluation is performed according to the algorithm of the query operator, if the query operator is a materialized operator, the materialized operator converts the data into a binary format, and stores the converted data in the memory, the evaluation of the materialized operator is mainly to evaluate the number of records multiplied by the memory size occupied by each record, for example, if there are N records in table C, and the size of each record is M bytes, then the memory evaluation of the materialized operator is n×m bytes.
Step S302, according to the first evaluation result, determining a first memory quantity of each query operator.
In this embodiment of the present application, the first memory amount may refer to memory resources allocated in advance for executing each query operator. The determining of the first memory amount may be obtained by calculating according to a preset memory allocation ratio, or the first evaluation result may be directly used as the first memory amount. For example, if the first memory amount is calculated according to a preset memory allocation ratio, the preset memory allocation ratio may be calculated according to the type and cost of the query operator, or may be obtained according to an empirical value of historical statistics, and the preset memory allocation ratios corresponding to different types of query operators may be the same or different. For example, a materialized operator generally requires a large amount of memory in the execution process, a higher memory allocation ratio may be set for the type of query operator, and a connection operator requires less memory in the execution process, a lower memory allocation ratio may be set for the type of query operator. Multiplying the first evaluation result of each query operator by a preset memory allocation ratio to obtain a first memory quantity of each query operator, for example, if the preset memory allocation ratio is 1:2, the first memory amount is 6 bytes, and the first memory amount calculated according to the preset memory allocation proportion is 12 bytes.
Step S303, determining the second memory quantity of each execution stage according to the first memory quantity of all the query operators in each execution stage.
In this embodiment of the present application, the second memory amount may refer to memory resources allocated in advance for execution of each execution stage. The determination of the second memory amount of each execution stage may be obtained according to a maximum value and a minimum value of the first memory amounts of all the query operators in each execution stage, or according to a preset memory allocation ratio of the first memory amounts of all the query operators in each execution stage. For example, the second memory amount of each execution stage is obtained according to the maximum value of the first memory amount and the minimum value of the first memory amount of all the query operators in each execution stage, the maximum total memory amount when the memory amount of all the query operators is the maximum value of the first memory amount is calculated, the minimum total memory amount when the memory amount of all the query operators is the minimum value of the first memory amount is calculated, and the average processing is performed on the calculated maximum total memory amount and the minimum total memory amount to obtain the second memory amount of each execution stage.
Step S304, determining the third memory quantity of the query statement according to the second memory quantity of all the execution stages in the query statement.
In this embodiment of the present application, the third memory amount may refer to memory resources allocated in advance for execution of the query statement. The determination of the third memory level of the query term based on the second memory levels of all the execution phases in the query term may refer to the details of step S302 and step S303, which are not described in detail herein.
Step S305, based on the third memory amount, allocates a first memory quota to the query statement from the memory quotas of the database system, allocates a second memory quota to each execution stage in the first memory quota based on the second memory amount, and allocates a third memory quota to each query operator in the second memory quota based on the first memory amount.
In the embodiment of the present application, according to the third memory quantity of the query statement, a first memory quota is allocated to the query statement in the memory quota of the database system, in the range of the first memory quota, according to the second memory quantity of each execution stage, a second memory quota is allocated to each execution stage, in the range of the second memory quota, according to the first memory quantity of each query operator, a third memory quota is allocated to each query operator.
According to the method and the device, the first memory quantity of each query operator is obtained according to the first evaluation result, the second memory quantity of each execution stage is determined according to the first memory quantity of all query operators in each execution stage, the third memory quantity of the query statement is determined according to the second memory quantity of all execution stages in the query statement, the first memory quota is obtained by distributing the query statement from the memory quota of the database system based on the third memory quantity, the second memory quota is obtained by distributing the first memory quota to each execution stage, the third memory quota is obtained by distributing the second memory quota to each query operator in the second memory quota based on the first memory quantity, the memory quota is reasonably distributed for each layer of the query statement according to the specific condition of the query statement by the steps, the memory resources are fully utilized, and the memory utilization rate of the memory quota distribution is improved.
Referring to fig. 5, a flowchart of a method for managing a memory of a database system according to a fourth embodiment of the present application is provided. As shown in fig. 5, the step S203 of calling the remaining memory and expanding the third memory quota allocated by the query operator to obtain an expanded memory quota may include the following steps:
Step S401, obtaining the memory quota increased by the query operator according to the required memory for executing the query operator and the third memory quota allocated by the query operator.
In this embodiment of the present application, the memory quota may refer to an amount of memory that needs to be increased for execution of the query operator based on the third memory quota of the query operator, and in the process of executing the query operator, if it is monitored that the third memory quota of the query operator has been used up, the memory resource that is still needed by the query operator is evaluated, so as to obtain an amount of memory that is needed for evaluation, where a specific evaluation manner may refer to the specific content of step S301 in the third embodiment. Of course, in the process of executing the query operator, the usage condition of the third memory quota of the query operator is monitored, the memory quantity which needs to be occupied by the query operator is dynamically predicted according to the real-time memory usage condition, and the memory quota which needs to be increased by the query operator is calculated according to the predicted occupied memory quantity and the usage condition of the third memory quota.
Step S402, detecting whether the remaining memory quota in the second memory quota allocated in the execution stage to which the query operator belongs is greater than or equal to the memory quota to be increased.
Step S403, if it is detected that the remaining memory quota in the second memory quota allocated in the execution stage to which the query operator belongs is greater than or equal to the memory quota to be increased, expanding the third memory quota allocated by the query operator according to the remaining memory quota in the second memory quota allocated in the execution stage to which the query operator belongs, to obtain an expanded memory quota.
In the embodiment of the present application, in the process of detecting whether the remaining memory quota in the second memory quota allocated in the execution stage of the query operator is greater than or equal to the memory quota to be increased, the use condition of the second memory quota in the execution stage of the query operator may be detected through a database management interface or a command line tool, etc., to obtain the use condition of the corresponding second memory quota, so as to obtain the remaining memory quota in the second memory quota, and comparing the calculated remaining memory quota with the value of the memory quota to be increased, to detect whether the remaining memory quota can meet the requirement of the memory quota to be increased.
After detecting that the remaining memory quota in the second memory quota can meet the requirement of the memory quota to be increased, expanding the third memory quota of the query operator, and calling all the remaining memory quota in the second memory quota to expand the third memory quota to obtain an expanded memory quota, or calling the remaining memory quota with the same memory quantity as the memory quota to be increased in the second memory quota to expand the third memory quota to obtain an expanded memory quota.
In the embodiment of the present application, according to a required memory for executing a query operator and a third memory quota allocated by the query operator, a memory quota required to be added by the query operator is obtained, and if it is detected that a remaining memory quota in a second memory quota allocated by an execution stage to which the query operator belongs is greater than or equal to the memory quota, the third memory quota allocated by the query operator is expanded according to the remaining memory quota in the second memory quota allocated by the execution stage to which the query operator belongs, so as to obtain an expanded memory quota. Through the steps, the rest memory quota in the second memory quota of the execution stage to which the query operator belongs is called to expand the third memory quota, the expanded memory quota is obtained, and when the normal execution of the query operator can be ensured, the unused memory part in the second memory quota of the execution stage of the query operator is reasonably utilized, the dynamic expansion of the third memory quota is realized, and the utilization rate of the preassigned second memory quota is improved.
Referring to fig. 6, a flowchart of a method for managing memory in a database system according to a fifth embodiment of the present application is shown in fig. 6, and after detecting in the above step S402 whether the remaining memory quota in the second memory quota allocated in the execution stage to which the query operator belongs is greater than or equal to the memory quota to be added, the method may further include the following steps:
step S501, if it is detected that the remaining memory quota in the second memory quota allocated in the execution stage to which the query operator belongs is smaller than the memory quota to be increased, the difference between the remaining memory quota in the second memory quota allocated in the execution stage to which the query operator belongs and the memory quota to be increased is calculated as the first memory difference.
In this embodiment of the present application, the first memory difference may refer to an amount of memory that needs to be increased to meet a requirement of a memory quota that needs to be increased on the basis of a remaining memory quota in the second memory quota in an execution stage to which the query operator belongs. And after the residual memory quota in the second memory quota of the execution stage to which the query operator belongs is insufficient to meet the requirement of the memory quota to be increased, subtracting the residual memory quota in the second memory quota from the memory quota to be increased to obtain a first memory difference which is required to meet the memory quota to be increased on the basis of the residual memory quota in the second memory quota.
Step S502 detects whether the remaining memory quota in the first memory quota allocated by the query statement is greater than or equal to the first memory difference.
Step S503, if it is detected that the remaining memory quota in the first memory quota allocated by the query statement is greater than or equal to the first memory difference, calling the memory quota of the first memory difference from the remaining memory quota in the first memory quota allocated by the query statement, expanding the second memory quota allocated by the execution stage to which the query operator belongs, and returning to execute the execution to detect whether the remaining memory quota in the second memory quota allocated by the execution stage to which the query operator belongs is greater than or equal to the memory quota to be added.
In this embodiment, specific detection may refer to specific contents in step S402 and step S403 in the fourth embodiment, where the remaining memory quota in the first memory quota allocated by the query statement is greater than or equal to the first memory difference.
After detecting that the remaining memory quota in the first memory quota can meet the requirement of the first memory difference, in an embodiment, all the remaining memory quota in the first memory quota may be called to expand the second memory quota.
In this embodiment of the present application, if it is detected that the remaining memory quota in the second memory quota allocated in the execution stage to which the query operator belongs is smaller than the memory quota to be increased, a difference between the remaining memory quota in the second memory quota allocated in the execution stage to which the query operator belongs and the memory quota to be increased is calculated to be the first memory difference, if it is detected that the remaining memory quota in the first memory quota allocated in the query statement is greater than or equal to the first memory difference, the remaining memory quota in the first memory quota allocated in the query statement is called from the remaining memory quota in the first memory quota allocated in the query statement, the second memory quota allocated in the execution stage to which the query operator belongs is extended, and whether the remaining memory quota in the second memory quota allocated in the execution stage to which the query operator belongs is greater than or equal to the memory quota to be increased is returned to be executed. Through the steps, while the normal execution of the query operator is ensured, the unused memory quota part in the first memory quota of the query statement and the second memory quota of the execution stage of the query operator is reasonably utilized, the dynamic expansion of the second memory quota and the third memory quota is realized, and the utilization rate of the preassigned first memory quota and the second memory quota is improved.
Referring to fig. 7, a flowchart of a method for managing memory in a database system according to a sixth embodiment of the present application is provided. As shown in fig. 7, after detecting whether the remaining memory quota in the first memory quota allocated by the query statement is greater than or equal to the first memory difference in the step S502, the method may further include the following steps:
step S601, if it is detected that the remaining memory quota in the first memory quota allocated by the query statement is smaller than the first memory difference, calculating a difference between the remaining memory quota and the first memory difference in the first memory quota allocated by the query statement as a second memory difference.
In this embodiment of the present application, the second memory difference may be a memory quota that needs to be increased and meets a requirement of the memory quota that needs to be increased on the basis of a remaining memory quota in the second memory quota in the execution stage to which the query operator belongs and a remaining memory quota in the first memory quota of the query statement. And when the residual memory quota in the second memory quota in the execution stage of the query operator and the residual memory quota in the first memory quota of the query statement are insufficient to meet the requirement of the memory quota to be increased, subtracting the residual memory quota in the first memory quota from the first memory quota to obtain a second memory difference which is required to meet the requirement of the memory quota to be increased on the basis of the residual memory quota in the second memory quota and the residual memory quota in the first memory quota.
Step S602, detecting whether the remaining memory quota in the database system is greater than or equal to the second memory allowance.
Step S603, if it is detected that the remaining memory quota in the database system is greater than or equal to the second memory difference, calling the memory quota of the second memory difference from the remaining memory quota in the database system, expanding the first memory quota allocated by the query statement, and returning to execute the detection of whether the remaining memory quota in the first memory quota allocated by the query statement is greater than or equal to the first memory difference.
In this embodiment, specific detection whether the remaining memory quota in the database system is greater than or equal to the first memory quota may refer to specific contents in step S402 and step S403 in the fourth embodiment.
In the embodiment of the application, if the residual memory quota in the first memory quota allocated by the query statement is detected to be smaller than the first memory difference, the difference between the residual memory in the first memory quota allocated by the query statement and the first memory difference is calculated to be the second memory difference, if the residual memory quota in the database system is detected to be greater than or equal to the second memory difference, the residual memory quota in the database system is called, the residual memory quota in the second memory difference is expanded, and the first memory quota allocated by the query statement is returned to execute the detection to determine whether the residual memory quota in the first memory quota allocated by the query statement is greater than or equal to the first memory difference. Through the steps, while the normal execution of the query operator is ensured, the first memory quota of the query statement, the second memory quota of the execution stage of the query operator and the unused memory quota in the database system memory are reasonably utilized, the dynamic expansion of the first memory quota, the second memory quota and the third memory quota is realized, and the utilization rate of the database system memory, the pre-allocated first memory quota and the second memory quota is improved.
Referring to fig. 8, a flowchart of a method for managing memory in a database system according to a seventh embodiment of the present application is provided. As shown in fig. 8, after detecting whether the remaining memory quota in the database system is greater than or equal to the second memory allowance in the step S602, the method may further include the following steps:
step S701, if it is detected that the remaining memory quota in the database system is smaller than the second memory allowance, evaluating the execution state of the query operator to obtain a second evaluation result.
In this embodiment of the present application, the second evaluation result may be an evaluation of an execution state corresponding to the query operator when the remaining memory quota cannot meet the requirement for executing the query operator. The evaluation of the execution state of the query operator may be a single evaluation or a joint evaluation of the data volume and the computation complexity required to be processed by the query operator, the memory size required in the execution process of the query operator, the number of input/output operations required by the query operator, the requirements and the contending conditions of the query operator for other system resources, the execution time required by the query operator, and the like, so as to obtain a second evaluation result.
In step S702, if the second evaluation result is immediate execution, part of the intermediate results in the execution process of the query operator is sent to the external storage.
In this embodiment of the present application, the intermediate results may be partial results calculated during the execution of the query operator, where these results may be used as input for a subsequent operation or used to generate a final query result, and the external storage may be a disk, a usb disk, or the like. In the process of sending part of intermediate results in the execution process of the query operator to the external storage, the intermediate results generated in the execution process of the query operator can be evaluated according to the aspects of data access frequency, data size, data update frequency, data relevance and the like, and according to the evaluation results, the part of intermediate results of the corresponding query operator are sent to the external storage, so that the execution memory of the query operator does not exceed the third memory quota of the query operator, and the execution memory is provided for normal execution of the query operator.
In an embodiment, if the second evaluation result is waiting, the query operator waits according to the second evaluation result, monitors the change amounts of the second memory quota, the first memory quota and the remaining memory quota in the memory quota of the database system in the execution stage to which the query operator belongs in real time, and after the second memory quota, the first memory quota and the remaining memory quota in the memory quota of the database system in the execution stage to which the query operator belongs can meet the memory quota required to be increased by the query operator, expands the third memory quota of the query operator according to the remaining memory quota to obtain an expanded memory quota, and allocates the corresponding memory of the expanded memory quota to execute the query operator.
In this embodiment of the present application, if it is detected that the remaining memory quota in the database system is smaller than the second memory allowance, the execution state of the query operator is evaluated to obtain a second evaluation result, if the second evaluation result is immediate execution, a part of intermediate results in the execution process of the query operator are sent to an external storage, so that the execution memory of the query operator does not exceed the third memory quota of the query operator, and the execution memory is provided for normal execution of the query operator. Through the steps, according to the specific execution condition of the query operator, the normal execution efficiency of the query operator is ensured while the memory resource is reasonably utilized.
Referring to fig. 9, a flowchart of a method for managing memory in a database system according to an eighth embodiment of the present application is provided. As shown in fig. 9, the method for managing the memory of the database system may further include the following steps:
step S801, if execution of any query operator is ended, releasing the memory quota used when the query operator is executed to the memory quota of the execution stage to which the query operator belongs, releasing a portion of the memory quota of the hollow memory quota in the memory quota of the execution stage to the memory quota of the query statement, and releasing a portion of the memory quota of the hollow memory quota in the memory quota of the query statement to the memory quota of the database system.
In the process of releasing the memory quota used when the query operator is executed, if the query operator does not expand the memory quota in the execution process, releasing the third memory quota of the query operator to the memory quota of the execution stage to which the query operator belongs through a specific function or instruction, and if the query operator expands the memory quota in the execution process, releasing the memory quota expanded by the query operator, wherein the releasing of the expanded memory quota can include: 1) Releasing the memory quota added by the query operator in the execution process to the memory quota which belongs to the pre-allocated memory quota, wherein the memory quota which belongs to the pre-allocated memory quota can be a first memory quota, a second memory quota, a third memory quota or a memory quota of a database system; 2) Releasing the third memory quota of the query operator to the memory quota of the execution stage to which the query operator belongs.
In the process of releasing the part of the memory quota of the idle memory quota in the execution stage into the memory quota of the query statement, the minimum idle memory quota required by the execution stage can be reserved, the idle memory quota except for the minimum idle memory quota can be released into the memory quota of the query statement, the part of the memory quota which needs to be released in the idle memory quota can be calculated according to the preset proportion, and the part of the memory quota is released into the memory quota of the query statement according to the calculation result. Releasing the part of the memory quota of the hollow memory quota in the memory quota of the query statement to the memory quota of the database system, wherein the specific content of the part of the memory quota of the hollow memory quota in the execution stage can be referred to.
Step S802, if all query operators in any execution stage are executed, releasing the remaining memory quota in the execution stage into the memory quota of the query statement, and releasing part of the memory quota of the hollow memory quota in the memory quota of the query statement into the memory quota of the database system.
Step 803, if all execution phases in the query statement are executed, releasing the remaining memory quota in the query statement to the memory quota of the database system.
In the process of releasing the residual memory quota in the execution stage, the residual memory quota in the execution stage can be released to the memory quota of the query statement through a specific function or instruction, wherein the residual memory quota can be the memory quota which is not used by the execution of the execution stage, the execution of all the execution stages in the query statement is finished, and the residual memory quota in the query statement is released to the memory quota of the database system, and the residual memory quota can be the memory quota which is not used by the execution of the query statement. Releasing part of the memory quota of the hollow memory quota in the memory quota of the query statement to the memory quota of the database system, which can refer to the content in step S801.
In the embodiment of the present application, if execution of the query operator is ended, the memory quota used in the execution of the query operator is released to the memory quota of the execution stage to which the query operator belongs, a part of the memory quota of the hollow memory quota in the memory quota of the execution stage is released to the memory quota of the query statement, a part of the memory quota of the hollow memory quota in the memory quota of the query statement is released to the memory quota of the database system, if execution of all the query operators in the execution stage is ended, the remaining memory quota in the execution stage is released to the memory quota of the query statement, a part of the memory quota of the hollow memory quota in the memory quota of the query statement is released to the memory quota of the database system, and if execution of all the execution stages in the query statement is ended, the remaining memory quota in the query statement is released to the memory quota of the database system. Through the steps, the dynamic release of the memory quota is realized according to the real-time execution condition of the query operator, each memory quota is fully utilized, and the utilization rate of the memory is improved.
Fig. 10 shows a block diagram of a database system memory management device according to a ninth embodiment of the present application, which is applied to a server in fig. 1, where the server is connected to a client to obtain a query statement sent by the client. For convenience of explanation, only portions relevant to the embodiments of the present application are shown.
Referring to fig. 10, the database system memory management apparatus includes:
a first determining module 1001, configured to determine, according to an obtained query statement, each execution stage in the query statement, and a query operator belonging to any execution stage;
a first allocation module 1002, configured to allocate a first memory quota to the query statement, allocate a second memory quota to each execution stage in the first memory quota, and allocate a third memory quota to each query operator in the second memory quota;
a first expansion module 1003, configured to, if a required memory for executing any query operator is greater than a third memory quota allocated by the query operator, invoke a remaining memory quota, expand the third memory quota allocated by the query operator to obtain an expanded memory quota, where the expanded memory quota is used to support execution of the query operator, and the remaining memory quota is obtained by searching from a second memory quota allocated by an execution stage to which the query operator belongs, the first memory quota, or all memory quotas of the database system
Optionally, the allocation module 1002 includes:
The first evaluation sub-module is used for evaluating the memory required by each query operator to obtain a first evaluation result;
a second determining submodule, configured to determine a first memory quantity of each query operator according to the first evaluation result;
a third determining submodule, configured to determine a second memory quantity of each execution stage according to the first memory quantities of all query operators in each execution stage;
a fourth determining submodule, configured to determine a third memory quantity of the query statement according to the second memory quantities of all execution phases in the query statement;
the second allocation submodule is used for allocating the first memory quota to the query statement from the memory quota of the database system based on the third memory quantity, allocating the second memory quota to each execution stage in the first memory quota based on the second memory quantity, and allocating the third memory quota to each query operator in the second memory quota based on the first memory quantity.
Optionally, the first expansion module 1003 includes:
the first computing sub-module is used for obtaining the memory quota which is required to be increased by the query operator according to the memory required to execute the query operator and the third memory quota distributed by the query operator;
The first detection submodule is used for detecting whether the residual memory quota in the second memory quota distributed in the execution stage to which the query operator belongs is greater than or equal to the memory quota which needs to be increased;
and the second expansion submodule is used for expanding the third memory quota allocated by the query operator according to the remaining memory quota in the second memory quota allocated by the execution stage of the query operator if the remaining memory quota in the second memory quota allocated by the execution stage of the query operator is detected to be greater than or equal to the memory quota required to be increased, so as to obtain the expanded memory quota.
Optionally, the first detection sub-module further includes:
the second calculating unit is configured to calculate, if it is detected that the remaining memory quota in the second memory quota allocated in the execution stage to which the query operator belongs is smaller than the memory quota to be increased, a difference between the remaining memory quota in the second memory quota allocated in the execution stage to which the query operator belongs and the memory quota to be increased as a first memory difference;
the second detection unit is used for detecting whether the residual memory quota in the first memory quota distributed by the query statement is greater than or equal to the first memory difference;
And the third expansion unit is used for calling the memory quota of the first memory difference from the memory quota remained in the first memory quota allocated by the query statement if the memory quota remained in the first memory quota allocated by the query statement is detected to be greater than or equal to the first memory difference, expanding the second memory quota allocated in the execution stage to which the query operator belongs, and returning to execute the step of detecting whether the memory quota remained in the second memory quota allocated in the execution stage to which the query operator belongs is greater than or equal to the memory quota required to be increased.
Optionally, the second detection unit further includes:
a third calculation subunit, configured to calculate, if it is detected that a remaining memory quota in the first memory quota allocated by the query statement is smaller than the first memory difference, a difference between the remaining memory quota in the first memory quota allocated by the query statement and the first memory difference to be a second memory difference;
a third detecting subunit, configured to detect whether a remaining memory quota in the database system is greater than or equal to the second memory allowance;
and the fourth expansion subunit is used for calling the memory quota of the second memory difference from the memory quota remained in the database system if the memory quota remained in the database system is detected to be greater than or equal to the second memory difference, expanding the first memory quota allocated by the query statement, and returning to execute the detection of whether the memory quota remained in the first memory quota allocated by the query statement is greater than or equal to the first memory difference.
Optionally, the third detection subunit further comprises:
if the residual memory quota in the database system is detected to be smaller than the second memory allowance, evaluating the execution state of the query operator to obtain a second evaluation result;
and if the second evaluation result is immediately executed, sending part of intermediate results in the execution process of the query operator to an external storage so that the execution memory of the query operator does not exceed the third memory quota of the query operator.
Optionally, the method for managing the memory of the database system further comprises the following steps:
the first release module is used for releasing the memory quota used when any query operator is executed to the memory quota of the execution stage to which the query operator belongs, releasing part of the memory quota of the hollow memory quota in the memory quota of the execution stage to the memory quota of the query statement, and releasing part of the memory quota of the hollow memory quota in the memory quota of the query statement to the memory quota of the database system if the execution of any query operator is finished;
the second release module is used for releasing the rest memory quota in the execution stage to the memory quota of the query statement and releasing part of the memory quota of the hollow memory quota in the memory quota of the query statement to the memory quota of the database system if all query operators in any execution stage are executed;
And the third releasing module is used for releasing the residual memory quota in the query statement to the memory quota of the database system if all the execution stages in the query statement are executed.
It should be noted that, because the content of information interaction and execution process between the modules is based on the same concept as the method embodiment of the present application, specific functions and technical effects thereof may be referred to in the method embodiment section, and details are not repeated herein.
Fig. 11 is a schematic structural diagram of a computer device according to a tenth embodiment of the present application. As shown in fig. 11, the computer device of this embodiment includes: at least one processor (only one shown in fig. 11), a memory, and a computer program stored in the memory and executable on the at least one processor, the processor executing the computer program to perform the steps of any of the various database system memory management method embodiments described above.
The computer device may include, but is not limited to, a processor, a memory. It will be appreciated by those skilled in the art that fig. 11 is merely an example of a computer device and is not intended to be limiting, and that a computer device may include more or fewer components than shown, or may combine certain components, or different components, such as may also include a network interface, a display screen, an input device, and the like.
The processor may be a CPU, but may also be other general purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), off-the-shelf programmable gate arrays (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory includes a readable storage medium, an internal memory, etc., where the internal memory may be the memory of the computer device, the internal memory providing an environment for the execution of an operating system and computer-readable instructions in the readable storage medium. The readable storage medium may be a hard disk of a computer device, and in other embodiments may be an external storage device of the computer device, for example, a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), etc. that are provided on the computer device. Further, the memory may also include both internal storage units and external storage devices of the computer device. The memory is used to store an operating system, application programs, boot loader (BootLoader), data, and other programs such as program codes of computer programs, and the like. The memory may also be used to temporarily store data that has been output or is to be output.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-described division of the functional units and modules is illustrated, and in practical application, the above-described functional distribution may be performed by different functional units and modules according to needs, i.e. the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-described functions. The functional units and modules in the embodiment may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit, where the integrated units may be implemented in a form of hardware or a form of a software functional unit. In addition, specific names of the functional units and modules are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working process of the units and modules in the above device may refer to the corresponding process in the foregoing method embodiment, which is not described herein again. The integrated units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer readable storage medium. Based on such understanding, the present application implements all or part of the flow of the method of the above-described embodiments, and may be implemented by a computer program to instruct related hardware, where the computer program may be stored in a computer readable storage medium, where the computer program, when executed by a processor, may implement the steps of the method embodiments described above. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, executable files or in some intermediate form, etc. The computer readable medium may include at least: any entity or device capable of carrying computer program code, a recording medium, a computer Memory, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), an electrical carrier signal, a telecommunications signal, and a software distribution medium. Such as a U-disk, removable hard disk, magnetic or optical disk, etc. In some jurisdictions, computer readable media may not be electrical carrier signals and telecommunications signals in accordance with legislation and patent practice.
The present application implementing all or part of the flow of the method of the above embodiment may also be implemented by a computer program product, which when run on a computer device causes the computer device to execute the steps of the method embodiment described above.
In the foregoing embodiments, the descriptions of the embodiments are emphasized, and in part, not described or illustrated in any particular embodiment, reference is made to the related descriptions of other embodiments.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the embodiments provided in this application, it should be understood that the disclosed apparatus/computer device and method may be implemented in other ways. For example, the apparatus/computer device embodiments described above are merely illustrative, e.g., the division of modules or units is merely a logical functional division, and there may be additional divisions when actually implemented, e.g., multiple units or components may be combined or integrated into another system, or some features may be omitted or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection via interfaces, devices or units, which may be in electrical, mechanical or other forms.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed over a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
The above embodiments are only for illustrating the technical solution of the present application, and are not limiting thereof; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present application, and are intended to be included in the scope of the present application.

Claims (10)

1. The method for managing the memory of the database system is characterized by comprising the following steps of:
determining each execution stage in the query statement and a query operator belonging to any execution stage according to the acquired query statement;
Allocating a first memory quota to the query statement, allocating a second memory quota to each execution stage in the first memory quota, and allocating a third memory quota to each query operator in the second memory quota;
if the required memory for executing any query operator is greater than the third memory quota allocated by the query operator, calling the remaining memory quota, expanding the third memory quota allocated by the query operator to obtain an expanded memory quota, wherein the expanded memory quota is used for supporting the execution of the query operator;
the residual memory quota is obtained by searching a second memory quota distributed in an execution stage to which the query operator belongs, the first memory quota or all memory quotas of the database system.
2. The method of claim 1, wherein allocating a first memory quota to the query statement, allocating a second memory quota to each execution stage in the first memory quota, and allocating a third memory quota to each query operator in the second memory quota, comprises:
Evaluating the memory required by each query operator to obtain a first evaluation result;
determining a first memory quantity of each query operator according to the first evaluation result;
determining a second memory quantity of each execution stage according to the first memory quantity of all query operators in each execution stage;
determining a third memory quantity of the query statement according to the second memory quantities of all execution stages in the query statement;
and based on the third memory quantity, allocating a first memory quota to the query statement from the memory quota of the database system, based on the second memory quantity, allocating a second memory quota to each execution stage in the first memory quota, and based on the first memory quantity, allocating a third memory quota to each query operator in the second memory quota.
3. The method for managing the memory of the database system according to claim 1, wherein the calling the remaining memory quota, expanding the third memory quota allocated by the query operator, to obtain an expanded memory quota, includes:
obtaining the memory quota which is required to be increased by the query operator according to the required memory for executing the query operator and the third memory quota distributed by the query operator;
Detecting whether the remaining memory quota in the second memory quota allocated in the execution stage to which the query operator belongs is greater than or equal to the memory quota to be increased;
if the residual memory quota in the second memory quota allocated in the execution stage to which the query operator belongs is detected to be greater than or equal to the memory quota to be increased, expanding the third memory quota allocated by the query operator according to the residual memory quota in the second memory quota allocated in the execution stage to which the query operator belongs, so as to obtain an expanded memory quota.
4. The method for managing memory in a database system according to claim 3, further comprising, after said detecting whether remaining memory quota in the second memory quota allocated in the execution stage to which the query operator belongs is greater than or equal to the memory quota to be increased, the steps of:
if the residual memory quota in the second memory quota allocated in the execution stage of the query operator is detected to be smaller than the memory quota required to be increased, calculating the difference between the residual memory quota in the second memory quota allocated in the execution stage of the query operator and the memory quota required to be increased as a first memory difference;
Detecting whether the residual memory quota in the first memory quota distributed by the query statement is greater than or equal to the first memory difference;
if the residual memory quota in the first memory quota allocated by the query statement is detected to be greater than or equal to the first memory difference, calling the memory quota of the first memory difference from the residual memory quota in the first memory quota allocated by the query statement, expanding the second memory quota allocated by the execution stage to which the query operator belongs, and returning to execute the execution to detect whether the residual memory quota in the second memory quota allocated by the execution stage to which the query operator belongs is greater than or equal to the memory quota required to be increased.
5. The method of claim 4, further comprising, after said detecting whether a remaining memory quota in the first memory quota allocated by the query statement is greater than or equal to the first memory difference:
if the residual memory quota in the first memory quota allocated by the query statement is detected to be smaller than the first memory difference, calculating the difference between the residual memory quota in the first memory quota allocated by the query statement and the first memory difference to be a second memory difference;
Detecting whether the residual memory quota in the database system is greater than or equal to the second memory allowance;
if the residual memory quota in the database system is detected to be greater than or equal to the second memory difference, calling the memory quota of the second memory difference from the residual memory quota in the database system, expanding the first memory quota allocated by the query statement, and returning to execute the detection of whether the residual memory quota in the first memory quota allocated by the query statement is greater than or equal to the first memory difference.
6. The method of claim 5, further comprising, after said detecting whether a remaining memory quota in said database system is greater than or equal to said second memory margin:
if the residual memory quota in the database system is detected to be smaller than the second memory allowance, evaluating the execution state of the query operator to obtain a second evaluation result;
and if the second evaluation result is immediately executed, sending part of intermediate results in the execution process of the query operator to an external storage so that the execution memory of the query operator does not exceed the third memory quota of the query operator.
7. The method for memory management of a database system according to claim 1, further comprising:
if any query operator is executed, releasing the memory quota used by the query operator to the memory quota of the execution stage to which the query operator belongs, releasing part of the memory quota of the hollow memory quota in the memory quota of the execution stage to the memory quota of the query statement, and releasing part of the memory quota of the hollow memory quota in the memory quota of the query statement to the memory quota of the database system;
if all query operators in any execution stage are executed, releasing the rest memory quota in the execution stage into the memory quota of the query statement, and releasing part of the memory quota of the empty memory quota in the memory quota of the query statement into the memory quota of the database system;
and if all the execution stages in the query statement are executed, releasing the residual memory quota in the query statement to the memory quota of the database system.
8. A database system memory management device, the database system memory management device comprising:
The first determining module is used for determining each execution stage in the query statement and query operators belonging to any execution stage according to the acquired query statement;
the first allocation module is used for allocating a first memory quota to the query statement, allocating a second memory quota to each execution stage in the first memory quota, and allocating a third memory quota to each query operator in the second memory quota;
the first expansion module is configured to, if a required memory for executing any query operator is greater than a third memory quota allocated by the query operator, invoke a remaining memory quota, expand the third memory quota allocated by the query operator to obtain an expanded memory quota, where the expanded memory quota is used to support execution of the query operator, and the remaining memory quota is obtained by searching from a second memory quota allocated by an execution stage to which the query operator belongs, the first memory quota, or all memory quotas of the database system.
9. A computer device comprising a processor, a memory and a computer program stored in the memory and executable on the processor, the processor implementing the database system memory management method of any of claims 1 to 7 when the computer program is executed by the processor.
10. A computer readable storage medium storing a computer program, wherein the computer program when executed by a processor implements the method of database system memory management according to any one of claims 1 to 7.
CN202311745493.7A 2023-12-15 2023-12-15 Method, device, equipment and medium for managing memory of database system Active CN117742951B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311745493.7A CN117742951B (en) 2023-12-15 2023-12-15 Method, device, equipment and medium for managing memory of database system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311745493.7A CN117742951B (en) 2023-12-15 2023-12-15 Method, device, equipment and medium for managing memory of database system

Publications (2)

Publication Number Publication Date
CN117742951A true CN117742951A (en) 2024-03-22
CN117742951B CN117742951B (en) 2024-07-02

Family

ID=90257219

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311745493.7A Active CN117742951B (en) 2023-12-15 2023-12-15 Method, device, equipment and medium for managing memory of database system

Country Status (1)

Country Link
CN (1) CN117742951B (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108196970A (en) * 2017-12-29 2018-06-22 东软集团股份有限公司 The dynamic memory management method and device of Spark platforms
CN113032156A (en) * 2021-05-25 2021-06-25 北京金山云网络技术有限公司 Memory allocation method and device, electronic equipment and storage medium
US20210406311A1 (en) * 2020-06-30 2021-12-30 Snowflake Inc. Accessing files in a database stage using a user defined function

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108196970A (en) * 2017-12-29 2018-06-22 东软集团股份有限公司 The dynamic memory management method and device of Spark platforms
US20210406311A1 (en) * 2020-06-30 2021-12-30 Snowflake Inc. Accessing files in a database stage using a user defined function
CN113032156A (en) * 2021-05-25 2021-06-25 北京金山云网络技术有限公司 Memory allocation method and device, electronic equipment and storage medium

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
"The ModelSEED Biochemistry Database for the integration of metabolic annotations and the reconstruction, comparison and analysis of metabolic models for plants, fungi and microbes", NUCLEIC ACIDS RESEARCH, vol. 49, no. 1, 31 December 2021 (2021-12-31) *
魏星: "分布式架构下数据库查询的并行处理与优化", CNKI博士学位论文全文库, 15 May 2022 (2022-05-15) *

Also Published As

Publication number Publication date
CN117742951B (en) 2024-07-02

Similar Documents

Publication Publication Date Title
CN110633296A (en) Data query method, device, medium and electronic equipment
JP5730386B2 (en) Computer system and parallel distributed processing method
CN110134738B (en) Distributed storage system resource estimation method and device
CN111563014A (en) Interface service performance test method, device, equipment and storage medium
CN110990396B (en) Data storage method, device and storage medium
CN111400288A (en) Data quality inspection method and system
CN110975293A (en) Method, device, server and medium for establishing resource reference relation table
CN108038215A (en) Data processing method and system
CN112948330A (en) Data merging method, device, electronic equipment, storage medium and program product
CN113987086A (en) Data processing method, data processing device, electronic device, and storage medium
CN113268500A (en) Service processing method and device and electronic equipment
CN113642301A (en) Report generation method, device and system
CN117742951B (en) Method, device, equipment and medium for managing memory of database system
CN116303820A (en) Label generation method, label generation device, computer equipment and medium
CN113641628B (en) Data quality detection method, device, equipment and storage medium
CN115857918A (en) Data processing method and device, electronic equipment and storage medium
CN115147183A (en) Chip resource management method, device, equipment and storage medium based on cloud platform
CN115016890A (en) Virtual machine resource allocation method and device, electronic equipment and storage medium
CN112181825A (en) Test case library construction method and device, electronic equipment and medium
CN113127327A (en) Test method and device for performance test
CN117591293B (en) Memory management method, memory management device, computer equipment and computer readable storage medium
CN111782482B (en) Interface pressure testing method and related equipment
CN112669025B (en) Data resource supply charging method, device, medium and terminal equipment
CN114969261B (en) Data query method and device based on artificial intelligence, electronic equipment and medium
CN117032560A (en) Dynamic compression storage and quantile data analysis method, device, equipment and medium

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
GR01 Patent grant