Optimized scheduling method for data pages and related products
By detecting low load status in the database, predicting the usage probability of future data pages and transferring them into memory in advance, the problem of high database page missing rate and limitations of page scheduling algorithm is solved, and the working efficiency and resource utilization of the database are improved.
Patent Information
- Application Number
- CN202410823037.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-24
- Publication Date
- 2024-10-01
AI Technical Summary
The high page missing rate in the database increases the database transaction time and reduces work efficiency. Moreover, the existing page scheduling algorithm has limitations and cannot effectively predict the usage probability of future data pages.
By detecting whether the database is in a low load state, obtain the usage records of data pages in historical time periods, divide the periods, calculate the usage probability, use the time series-based prediction model and the naive Bayes algorithm to predict the usage probability of future data pages, and Transfer high-probability data pages into memory before the future time period.
Reduce the page missing rate of the database, improve the work efficiency and resource utilization of the database, reduce the limitations of the existing page scheduling algorithm, and improve the throughput of the database service.
Smart Images

Figure CN118733141A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to database technology, and in particular to a data page optimization scheduling method and related products. Background Art
[0002] The page fault rate of a database refers to the ratio of the number of failures in accessing a data page to the total number of data page accesses, where the main reason for the failure in accessing a data page is the database page fault.
[0003] A database page fault means that the data page that the CPU (Central Processing Unit) needs to access is not in the database memory. After a database page fault occurs, the missing data page needs to be transferred to the database memory. If the database memory is full, the data page needs to be replaced with the data page that already exists in the memory. Therefore, after a database page fault occurs, the time it takes for the database to process transactions will increase, reducing the database's work efficiency. Summary of the invention
[0004] The present invention provides a data page optimization scheduling method and related products, one purpose of which is to reduce the page fault rate of a database to improve the working efficiency of the database.
[0005] A further object of the present invention is to improve the rationality of the use of database resources.
[0006] Another further object of the present invention is to reduce the limitations of existing page scheduling algorithms.
[0007] In particular, the present invention provides a method for optimizing scheduling of data pages, comprising:
[0008] Check whether the database is in a low load state;
[0009] If yes, then obtain the usage records of each data page in multiple historical time periods;
[0010] Using a preset time period division strategy to divide each of the historical time periods into a plurality of historical sub-time periods;
[0011] Calculating the usage probability of each of the data pages in each of the historical sub-time periods according to each of the usage records;
[0012] Using a usage probability prediction model based on time series, according to the usage probability of each data page in each historical sub-time period, predicting the usage probability of each data page in at least one future time period;
[0013] Acquire pre-used data pages for each of the future time periods, wherein the pre-used data pages are a first set number of data pages sorted from largest to smallest in terms of usage probability within the corresponding future time period;
[0014] Before each of the future time periods, the corresponding pre-used data pages are loaded into the memory.
[0015] Furthermore, the step of calculating the usage probability of each of the data pages in each of the historical sub-time periods according to each of the usage records includes:
[0016] Calculate the proportion of the duration of each of the historical sub-time periods in the corresponding historical time period;
[0017] Calculating, according to each of the usage records, a total usage frequency of each of the data pages in each of the set sub-time periods, and a sub-frequency of usage of each of the data pages in each of the historical sub-time periods;
[0018] The Naive Bayes algorithm is adopted to calculate the usage probability of each of the data pages in each of the historical sub-time periods according to the total usage frequencies, the proportions and the sub-frequency of usage.
[0019] Furthermore, before the step of dividing each of the historical time periods into a plurality of historical sub-time periods by using a preset time period division strategy, the method further includes:
[0020] Acquiring operation status information of the database, and determining whether it is necessary to update the usage probability prediction model according to the operation status information;
[0021] If so, a training data set is obtained, and the usage probability prediction model is trained using the training data set to update the usage probability prediction model.
[0022] Furthermore, the step of obtaining a training data set includes:
[0023] Obtaining usage records of each of the data pages within a set training cycle;
[0024] The preset time period division strategy is adopted to divide the set training cycle into a plurality of training sub-time periods, and based on the usage records of each data page in the set training cycle, the usage probability of each data page in each training sub-time period is calculated;
[0025] Acquire prediction data for each of the training sub-time periods, and construct the training data set according to each of the prediction data and the probability of use of each of the data pages in each of the training sub-time periods;
[0026] The prediction data is data used to predict the usage probability of each of the data pages in the corresponding training sub-time period.
[0027] Furthermore, before the step of dividing the set training cycle into a plurality of training sub-time periods by using the preset time period division strategy, the method further includes:
[0028] Dividing the set training cycle into a plurality of preset sub-time periods of equal duration;
[0029] According to the usage record of each data page in the set training cycle, the number of data pages accessed in each preset sub-time period is obtained;
[0030] The access volume threshold is obtained according to the maximum number of data pages accessed in each of the preset sub-time periods, and the preset time period division strategy is updated according to the access volume threshold so that the number of data pages accessed in each of the training sub-time periods is greater than or equal to the access volume threshold.
[0031] Furthermore, the step of determining whether the usage probability prediction model needs to be updated according to the operating status information includes:
[0032] According to the running status information, obtaining the interval between the current time and the time when the usage probability prediction model was last updated;
[0033] Determine whether the interval duration is greater than a set duration threshold;
[0034] If so, it is determined that the usage probability prediction model needs to be updated.
[0035] Furthermore, the step of detecting whether the database is in a low-load state includes:
[0036] The throughput of the database service is obtained, and whether the database is in the low-load state is determined according to the throughput.
[0037] Furthermore, before the step of detecting whether the database is in a low-load state, the method further includes:
[0038] Detecting whether the database has started an optimized scheduling strategy for data pages;
[0039] If yes, the step of obtaining the throughput of the database service is performed.
[0040] In a second aspect, the present invention further provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the steps of the data page optimization scheduling method described in any one of the above items are implemented.
[0041] In a third aspect, the present invention further provides a computer program product, including a computer program, which, when executed by a processor, implements the steps of any of the above methods for optimizing scheduling of data pages.
[0042] The data page optimization scheduling method of the present invention can first obtain the pre-used data pages of each future time period, and then respectively store the corresponding pre-used data pages into the memory before each future time period. Therefore, in the process of processing transactions in each future time period, the number of page faults can be reduced, that is, the page fault rate of the database is reduced, thereby reducing the processing time of each transaction by the database and improving the throughput of the database service. And in the technical solution of the present invention, the pre-used data pages of each future time period are obtained when the database is in a low-load state, thereby improving the utilization rate of the CPU of the database and achieving the purpose of rationally utilizing the database resources. Therefore, the technical solution of the present invention can not only improve the resource utilization rate of the database, but also improve the working efficiency of the database.
[0043] Furthermore, the data page optimization scheduling method of the present invention also uses a naive Bayes algorithm to calculate the usage probability of each data page in each historical sub-time period, thereby also reducing the limitations of the existing page scheduling algorithm.
[0044] Based on the following detailed description of specific embodiments of the present invention in conjunction with the accompanying drawings, those skilled in the art will become more aware of the above and other objects, advantages and features of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Hereinafter, some specific embodiments of the present invention will be described in detail in an exemplary and non-limiting manner with reference to the accompanying drawings. The same reference numerals in the accompanying drawings indicate the same or similar components or parts. It should be understood by those skilled in the art that these drawings are not necessarily drawn to scale. In the accompanying drawings:
[0046] Figure 1 is a schematic flow chart of a method for optimizing scheduling of data pages according to an embodiment of the present invention;
[0047] Figure 2 is a schematic flow chart of calculating the usage probability of each data page in each historical sub-time period according to an embodiment of the present invention;
[0048] Figure 3 is a schematic flow chart of determining whether to update the usage probability prediction model according to an embodiment of the present invention;
[0049] Figure 4 is a schematic flow chart of a method for obtaining a training data set according to an embodiment of the present invention;
[0050] Figure 5is a schematic flow chart of a method for obtaining a preset time period division strategy according to an embodiment of the present invention;
[0051] Figure 6 is a schematic flow chart of a method for obtaining a preset time period division strategy according to an embodiment of the present invention;
[0052] Figure 7 is a schematic flow chart of a method for optimizing scheduling of data pages according to another embodiment of the present invention;
[0053] Figure 8 is a schematic diagram of a computer program product according to an embodiment of the present invention;
[0054] Fig. 9 is a schematic diagram of a computer-readable storage medium according to an embodiment of the present invention. DETAILED DESCRIPTION
[0055] Refer to the following Figures 1 to 9 To describe the optimization scheduling method and related products of the data page of the embodiment of the present invention. In the description of this embodiment, it should be understood that the terms "first" and "second" are used for descriptive purposes only, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features, that is, include one or more of the features. In the description of the present invention, the meaning of "multiple" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined. When a feature "includes or contains" one or some of the features it covers, unless otherwise specifically described, this indicates that other features are not excluded and may further include other features.
[0056] See also Figure 1 , Figure 1 What is shown is a schematic flow chart of a data page optimization scheduling method in one embodiment of the present invention. The optimization scheduling method first predicts the use probability of each data page in a future time period, and then before the future time period, a set number of data pages with the highest predicted use probability in the future time period are loaded into the memory for use in the future time period, thereby reducing the probability of page faults in the future time period. Figure 1 The process shown is a detailed introduction to the optimized electric method of this embodiment.
[0057] like Figure 1 As shown, the data page optimization scheduling method of this embodiment may generally include:
[0058] Step S102: Detect whether the database is in a low load state;
[0059] If yes, execute step S104;
[0060] Step S104: Obtain usage records of each data page in multiple historical time periods.
[0061] Step S106: using a preset time period division strategy to divide each historical time period into a plurality of historical sub-time periods;
[0062] Step S108: Calculating the usage probability of each data page in each historical sub-time period according to the usage record of each data page in each historical time period;
[0063] Step S110: using a usage probability prediction model based on time series to predict the usage probability of each data page in at least one future time period according to the usage probability of each data page in each historical sub-time period;
[0064] Step S112: obtaining pre-used data pages for each future time period, the pre-used data pages being a pre-set number of data pages sorted from largest to smallest in terms of usage probability in the corresponding future time period;
[0065] Step S114: before each future time period, the corresponding pre-used data page is loaded into the memory.
[0066] In the above step S102, whether the database is in a low-load state can be determined by detecting the business volume of the database service.
[0067] In the above step S104, the usage record of each data page in each historical time period includes a unique identification code of the data page used in each time period and a timestamp of the use of each data page.
[0068] In the above step S106, after each historical time period is divided into multiple historical sub-time periods using a preset time period division strategy, the number of historical sub-time periods in each historical time period is the same, the duration of each historical sub-time period in the same historical time period can be the same or different, and the duration of the historical sub-time periods corresponding to the time periods in the historical time period is the same.
[0069] In this embodiment, the length of the historical time period may be one day, that is, 24 hours, so as to predict the usage probability of each data page in multiple future time periods within the next day.
[0070] In the above step S108, based on the usage records of each data page in each historical time period, the timestamp of the use of each data page in each historical time period can be obtained, and the historical sub-time period in which the usage time of each data page is located can be obtained based on the timestamp. Then, based on the number of data pages accessed in each historical sub-time period and the unique identifier code, the data pages used in each historical sub-time period can be obtained. In this embodiment, the usage probability of each data page in each historical sub-time period can be calculated based on the data pages used in each historical time period and the data pages used in each historical sub-time period.
[0071] In the above step S110, it is assumed that the usage records of each data page in N historical time periods are obtained, and each historical time period is divided into M historical sub-time periods. Assume that the usage probability of the i-th data page in the m-th historical sub-time period of the n-th historical time period is P n,m,i , we can get the time series of the probability of using the i-th data page in the m-th historical sub-time period of each historical time period as follows:
[0072] {P 1,m,i , P 2,m,i , ..., P N,m,i}
[0073] Substituting the above time series into the usage probability prediction model based on time series, the usage probability of the i-th data page in the m-th future time period can be predicted as P′ m,i By analogy, the probability of using each data page in each future time period can be predicted.
[0074] In this embodiment, the usage probability prediction model based on time series can be a moving average model or a neural network model. If the usage probability prediction model based on time series is a moving average model, then:
[0075]
[0076] If the usage probability prediction model based on time series is a neural network model, the neural network model can be trained using a training data set so that the usage probability prediction model can predict the usage probability P′ of the i-th data page in the m-th future time period based on the time series of the usage probability of the i-th data page in the m-th future time period. m,i .
[0077] In the above step S112, taking one of the future time periods as an example, the data pages are first sorted in descending order according to the probability of use in the future time period, and then the first set number of data pages in the sort are used as the pre-used data pages for the future time period, thereby using a set number of data pages with a higher probability of use in the future time period as the pre-used data pages for the future time period.
[0078] After obtaining the pre-used data page for each future time period, the pre-used data page for each future time period is stored in a disk.
[0079] In the above step S114, the corresponding pre-used data page can be read from the disk and loaded into the memory before each future time period, so that the database can call it in the process of processing transactions. For example, before the mth future time period, the pre-used data page of the mth future time period can be read from the disk and loaded into the memory, so that the pre-used data page can be called in the mth future time period.
[0080] Through the technical solution of this embodiment, the pre-used data pages of each future time period can be obtained first, and then the corresponding pre-used data pages can be loaded into the memory before each future time period. Therefore, in the process of processing transactions in each future time period, the number of page faults can be reduced, that is, the page fault rate of the database can be reduced, thereby reducing the processing time of each transaction by the database and improving the throughput of the database service. And in the technical solution of this embodiment, the pre-used data pages of each future time period are obtained when the database is in a low-load state, thereby improving the utilization rate of the CPU of the database and achieving the purpose of rationally utilizing the database resources. Therefore, the technical solution of this embodiment can not only improve the resource utilization rate of the database, but also improve the working efficiency of the database.
[0081] In some embodiments of the present invention, the method for calculating the usage probability of each data page in each historical sub-time period according to the usage record of each data page in each historical time period in the above step S108 is as follows: Figure 2 As shown, the following steps are included:
[0082] Step S202: Calculate the proportion of the duration of each historical sub-time period in the corresponding historical time period;
[0083] Step S204: Calculate the total usage frequency of each data page in each historical time period and the sub-frequency of each data page in each historical sub-time period according to the usage records of each data page in each historical time period;
[0084] Step S206: Using the Naive Bayes algorithm, the probability of use of each data page in each historical sub-time period is calculated according to the proportion of the duration of each historical sub-time period in the corresponding historical time period, the total frequency of use of each data page in each historical time period, and the sub-frequency of use of each data page in each historical sub-time period.
[0085] In the above step S202, each historical sub-time period is regarded as an event, and the proportion of the duration of each historical sub-time period in the corresponding historical time period can be regarded as the probability of each historical sub-time period occurring in the corresponding historical time period. Assume that the duration of each historical time period is L, and the duration of the mth historical sub-time period in each historical time period is L m , then the proportion of the length of the mth historical sub-time period in the corresponding historical time period can be calculated as P″ m for:
[0086]
[0087] In the above step S204, it is assumed that the total number of data pages accessed in the nth historical time period is H n , the number of visits to the i-th data page is C ni , then the total usage frequency F of the i-th data page in the n-th historical time period ni for:
[0088]
[0089] The number of data pages accessed in the mth historical sub-time period in the nth historical time period is H′ nm , the number of visits to the i-th data page is C′ nmi , then the usage sub-frequency F′ of the i-th data page in the m-th historical sub-time period in the n-th historical time period is nmi for:
[0090]
[0091] In the above step S206, the naive Bayes algorithm is used to calculate the usage probability P of the i-th data page in the m-th historical sub-time period within the n-th historical time period. n,m,i for:
[0092]
[0093] Among them, P′ n,m,i is the probability of using the i-th data page in the m-th historical sub-period when the i-th data page is used in the n-th historical period.
[0094]
[0095] By analogy, the usage probability of each data page in each historical sub-time period in each historical time period can be calculated.
[0096] In the technical solution of this embodiment, the naive Bayes algorithm is used to calculate the usage probability of each data page in each historical sub-time period, which can solve the problem that the existing prediction method cannot predict multiple results in a future time period, thereby reducing the limitations of the existing page scheduling algorithm.
[0097] In some embodiments of the present invention, when it is determined in step S102 that the database is in a low load state, Figure 3 As shown, before obtaining the usage records of each data page in multiple historical time periods in the above step S104, it also includes:
[0098] Step S103: obtaining the operation status information of the database, and judging whether it is necessary to update the time series-based usage probability prediction model according to the operation status information;
[0099] If necessary, execute step S114;
[0100] Step S114: Acquire a training data set, and use the training data set to retrain the time series-based usage probability prediction model to update the time series-based usage probability prediction model, and then execute step S104.
[0101] Through the technical solution of this embodiment, the usage probability prediction model based on time series can be updated according to the operating status information of the database, thereby ensuring that the usage probability prediction model based on time series is adapted to the operating status of the database and improving the accuracy of the usage probability prediction of each data page in each future time period.
[0102] In some embodiments of the present invention, the method for obtaining the training data set in step S114 is as follows: Figure 4 As shown, the following steps are included:
[0103] Step S212: obtaining usage records of each data page within a set training cycle;
[0104] Step S214: using a preset time period division strategy to divide the set training cycle into a plurality of training sub-time periods;
[0105] Step S216: Calculate the usage probability of each data page in each training sub-time period according to the usage record of each data page in the set training cycle;
[0106] Step S218: Obtain prediction data for each training sub-time period, and construct a training data set based on the prediction data and the usage probability of each data page in each training sub-time period.
[0107] In the above step S212, the length of the training cycle is set to be the same as the length of each historical time period. The set training cycle can be a specified period of time before the current moment. The usage records of each data page within the set training cycle obtained include the timestamp and unique identification code of the data page used.
[0108] In the above step S214, the method of dividing the set training cycle is the same as the method of dividing each historical time period in the above embodiment.
[0109] In the above step S216, a naive Bayes algorithm may be used to calculate the usage probability of each data page in each training sub-time period, and the calculation method is the same as the method for calculating the usage probability of each data page in each historical sub-time period in the above embodiment.
[0110] In the above step S218, the prediction data of each training sub-time period refers to data of the usage rate of each data page in each training sub-time period predicted by using the usage probability prediction model based on time series.
[0111] In this embodiment, the usage records of each data page in multiple set time periods before the set training cycle can be obtained, and then each set time period can be divided into multiple set sub-time periods using a preset time period division strategy; finally, the naive Bayes algorithm is used to calculate the usage probability of each data page in each historical sub-time period based on the usage records of each data page in each set sub-time period, so as to obtain the prediction data for each training sub-time period in the set training cycle.
[0112] Through the technical solution of this embodiment, the time series-based usage probability prediction model can be updated according to the usage records of each data page within the set training cycle, thereby ensuring the reliability of the usage probability prediction model, and then improving the accuracy of the usage probability prediction of each data page in each future time period, thereby improving the performance of the database.
[0113] In some embodiments of the present invention, before the training cycle is divided into a plurality of historical sub-time periods using the preset time period division strategy in the above step S214, a step of obtaining the preset time period division strategy is also included, wherein the method for obtaining the preset time period division strategy is as follows: Figure 5 As shown, the following steps are included:
[0114] Step S222: Divide the set training cycle into a plurality of preset sub-time periods of equal duration;
[0115] Step S224: obtaining the number of data pages used in each preset sub-time period according to the usage record of each data page in the set training cycle;
[0116] Step S226: obtaining an access volume threshold according to the maximum number of data pages used in each preset sub-time period, and updating the preset time period division strategy according to the access threshold.
[0117] In the above step S222, assuming that the duration of the above preset sub-time period is page_t, and the duration of the training cycle is set to t, the number of preset sub-time periods can be obtained as t / page_t.
[0118] The usage record of each data page in the set training cycle obtained in the above step S212 includes the unique identification number of the data page accessed in the set training cycle and the timestamp of accessing each data page. After the set training cycle is divided into a plurality of preset sub-time periods, the start time and the end time of each preset sub-time period can be obtained first, and then the number of data pages used in each preset sub-time period and the unique identification number of each data page can be obtained according to the timestamp of accessing each data page.
[0119] In the above step S224, assuming that the maximum number of data pages accessed in each preset sub-time period is request_t, the access volume threshold is set to request_t / 2.
[0120] The preset time period division strategy obtained includes the number of sub-time periods into which the time period to be divided is divided, and the duration of each sub-time period. The preset time period division strategy determined according to the access threshold includes:
[0121] First, arrange the preset sub-time periods in chronological order, then determine whether the number of data pages accessed in the first preset sub-time period is greater than the access volume threshold. If so, use the first preset sub-time period as a training sub-time period, and then determine whether the number of data pages accessed in the second preset sub-time period is greater than the access volume threshold. If not, determine whether the sum of the number of data pages in the first preset sub-time period and the second preset sub-time period is greater than the access volume threshold. If so, merge the first preset sub-time period and the second preset sub-time period into one training sub-time period. And so on, merge multiple preset sub-time periods into multiple training sub-time periods.
[0122] Through the technical solution of this embodiment, after the set training cycle is divided into a plurality of training sub-time periods, it can be ensured that the number of data pages accessed in each training sub-time period is not less than the access volume threshold. Accordingly, after the target time period is divided into a plurality of target sub-time periods using a preset time period division strategy, it can also be ensured that the number of data pages used in each target sub-time period is not too small.
[0123] In some embodiments of the present invention, the method for determining whether the time series-based usage probability prediction model needs to be updated in step 103 is as follows: Figure 6 As shown, including:
[0124] Step S122: according to the operation status information of the database, obtaining the interval between the current time and the time when the time series-based usage probability prediction model was last updated;
[0125] Step S124: determining whether the interval between the current time and the time when the time series-based usage probability prediction model was last updated is greater than a set time threshold;
[0126] If so, it is determined that the time series-based usage probability prediction model needs to be updated, and step S114 is executed.
[0127] In this embodiment, after updating the time series-based usage probability prediction model, the database will record the timestamp of the update of the time series-based usage probability prediction model; in the above step S122, the interval between the current moment and the last time the time series model was updated can be obtained based on the current moment and the recorded timestamp of the time series-based usage probability prediction model update.
[0128] Through the technical solution of this embodiment, it is possible to implement periodic updating of the usage probability prediction model based on time series, thereby ensuring the timeliness of updating the usage probability prediction model based on time series and improving the reliability of the database.
[0129] In the above embodiment, the usage probability prediction model based on time series is periodically updated according to the set duration threshold; in other embodiments, the accuracy of the usage probability prediction model can be obtained after each future time period based on the difference between the actual usage probability of each data page in each future time period and the predicted usage probability of each data page in each future time period, and when the accuracy is less than the set accuracy threshold, the usage probability prediction model based on time series is updated.
[0130] In some embodiments of the present invention, before detecting whether the database is in a low-load state in the above step S102, the method further includes:
[0131] The configuration data set by the user is obtained, and at least the above-mentioned set duration threshold, set quantity, preset sub-time period and set training cycle are obtained according to the configuration data set by the user.
[0132] In this embodiment, the user can set the configuration data of the database according to the needs, for example, write the configuration data in the configuration file of the database to set the above-mentioned set time threshold and set quantity. By setting the above-mentioned set time threshold, the update frequency of the usage probability prediction model based on the time series in the database can be controlled to ensure that the usage probability prediction model is updated in time; by setting the above-mentioned set quantity, the number of data pages stored in the memory can be controlled to ensure that the data pages stored in the memory can meet the access requirements of the database and improve the reliability of the database operation. By setting the above-mentioned set training cycle, the reliability of the training of the usage probability prediction model based on the time series can be improved; by setting the above-mentioned preset sub-time period, the reliability of the preset time division strategy can be improved.
[0133] In some embodiments of the present invention, the method for detecting whether the database is in a low load state in step S102 includes:
[0134] Get the database throughput and determine whether the database is in a low-load state based on the throughput.
[0135] For database services, the 80 / 20 rule in database performance testing is that 80% of the business volume of most software is completed in 20% of the service time. Therefore, for a database that is serving the business, the database has 20% of the service time in a high-load operation state, and the rest of the service time is in a low-load state. That is, if the database is in a high-load operation state, the throughput h1 of the database service is
[0136]
[0137] If the database is under low load, the throughput h2 of the database service is
[0138]
[0139] In this embodiment, the business volume of the database in a time period can be counted first, and then the ratio between the business volume and the duration of the time period can be used as the throughput of the database service. If the difference between the throughput of the database service and the throughput h1 is within the first set threshold range, it is determined that the database is in a low load state; if the difference between the throughput of the database service and the throughput h2 is within the second set threshold range, it is determined that the database is in a high load operation state.
[0140] In some embodiments of the present invention, before detecting whether the database is in a low-load state in the above step S102, the method further includes:
[0141] Determine whether the database starts the optimization scheduling strategy for data pages;
[0142] If yes, then the above step S102 is executed to detect whether the database is in a low load state.
[0143] In this embodiment, the optimization scheduling method of the data page of this embodiment is asynchronously run by a sub-process of the database, and the user can choose whether to start the optimization scheduling strategy of the data page in the database. For example, the user can choose whether to start the optimization scheduling strategy by setting the configuration items of the database.
[0144] If the user starts the data page optimization scheduling strategy in the database, a subprocess of the database asynchronously runs the data page optimization scheduling method of this embodiment to reduce the probability of page missing in the database and improve the reliability of database operation.
[0145] Through the technical solution of this embodiment, the user can determine whether to start the optimization scheduling strategy of the data pages in the database according to the needs, thereby improving the controllability and flexibility of the database.
[0146] In some embodiments of the present invention, the optimization scheduling method of the data page of the present invention is as follows: Figure 7 As shown, the following steps are included:
[0147] Step S302: Detect whether the database starts the optimization scheduling strategy of the data page;
[0148] If yes, execute step S304;
[0149] Step S304: Acquire the configuration data set by the user, and acquire the set time threshold, set number, preset sub-time period and set training cycle according to the configuration data set by the user;
[0150] Step S306: Obtain the throughput of the database service, and determine whether the database is in a low-load state according to the throughput;
[0151] If yes, execute step S308;
[0152] Step S308: according to the operation status information of the database, obtaining the interval between the current time and the time when the time series-based usage probability prediction model was last updated;
[0153] Step S310: determining whether the interval between the current time and the time when the time series-based usage probability prediction model was last updated is greater than a set time threshold;
[0154] If yes, execute step S312; if no, execute step S324;
[0155] Step S312: obtaining the usage records of each data page within a set training cycle;
[0156] Step S314: acquiring the number of data pages used in each preset sub-time period according to the usage record of each data page in the set training cycle;
[0157] Step S316: obtaining an access volume threshold according to the maximum number of data pages used in each preset sub-time period, and updating the preset time period division strategy according to the access threshold;
[0158] Step S318: Calculate the usage probability of each data page in each training sub-time period using the naive Bayes algorithm according to the usage record of each data page in the training period;
[0159] Step S320: obtaining prediction data for each training sub-time period, and constructing a training data set according to the prediction data and the usage probability of each data page in each training sub-time period;
[0160] Step S322: retraining the time series-based usage probability prediction model using the training data set to update the time series-based usage probability prediction model;
[0161] Step S324: obtaining usage records of each data page in multiple historical time periods, and dividing each historical time period into multiple historical sub-time periods using a preset time period division strategy;
[0162] Step S326: Calculate the proportion of each historical sub-time period in the corresponding historical time period;
[0163] Step S330: Calculate the total usage frequency of each data page in each historical time period and the sub-frequency of each data page in each historical sub-time period according to the usage records of each data page in each historical time period;
[0164] Step S332: using a naive Bayes algorithm, the probability of use of each data page in each historical sub-time period is calculated according to the proportion of the duration of each historical sub-time period in the corresponding historical time period, the total frequency of use of each data page in each historical time period, and the sub-frequency of use of each data page in each historical sub-time period;
[0165] Step S334: using a usage probability prediction model based on time series, predicting the usage probability of each data page in multiple future time periods according to the usage probability of each data page in the historical sub-time period corresponding to the time period in each historical time period;
[0166] Step S336: obtaining pre-used data pages for each future time period and storing them in a disk, wherein the pre-used data pages are a pre-set number of data pages sorted from largest to smallest in terms of usage probability in the corresponding future time period;
[0167] Step S338: before each future time period, the corresponding pre-used data page is loaded into the memory.
[0168] The technical solution of this embodiment can reduce the number of page faults in the process of processing transactions in each future time period, that is, reduce the page fault rate of the database, thereby reducing the processing time of each transaction by the database and improving the throughput of the database service. In addition, this embodiment can also predict the probability of use of each data page in each future time period when the database is in a low-load state, improve the utilization rate of the CPU of the database, and achieve the purpose of rationally utilizing database resources.
[0169] Furthermore, in this embodiment, the Naive Bayes algorithm is used to calculate the usage probability of each data page in each historical sub-time period, which can also reduce the limitations of the existing page scheduling algorithm.
[0170] The flow chart provided by the present embodiment is not intended to indicate that the operation of the method will be performed in any particular order, or that all operations of the method are included in all every case. In addition, the above-mentioned methods may include additional operations. Within the scope of the technical ideas provided by the present embodiment method, additional changes may be made to the above-mentioned methods.
[0171] It should be understood that in some embodiments, each part can be implemented by hardware, software, firmware or a combination thereof. In the above embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system.
[0172] This embodiment also provides a computer program product 10 and a computer readable storage medium 20 . Figure 8 is a schematic diagram of a computer program product 10 according to an embodiment of the present invention, Fig. 9 is a schematic diagram of a computer-readable storage medium 20 according to an embodiment of the present invention. The computer program product 10 includes a computer program 11, which implements the steps of any of the above-mentioned data page optimization scheduling methods when the computer program 11 is executed by the processor 32. The computer-readable storage medium 20 stores the above-mentioned computer program 11 thereon, and the computer program 11 implements the steps of any of the above-mentioned data page optimization scheduling methods when the computer program 11 is executed by the processor 32.
[0173] The computer program 11 for performing the operation of the present invention may be an assembly instruction, an instruction set architecture (ISA) instruction, a machine instruction, a machine-related instruction, a microcode, a firmware instruction, a state setting data, a configuration data of an integrated circuit, or a source code or an object code written in any combination of one or more programming languages and process programming languages. The computer program 11 may be executed entirely on the user's computer, partially on the user's computer, as an independent software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the latter case, the remote computer may be connected to the user's computer via any type of network (including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., using an Internet service provider via the Internet). In some embodiments, in order to perform various aspects of the present invention, an electronic circuit including, for example, a programmable logic circuit, a field programmable gate array (FPGA) or a programmable logic array (PLA) may execute computer-readable program instructions by utilizing the state information of the computer-readable program instructions to personalize the electronic circuit.
[0174] In the description of this embodiment, the computer program product 10 is a related product including the computer program 11 .
[0175] For the purposes of the description of this embodiment, the computer-readable storage medium 20 is a tangible device capable of retaining and storing the computer program 11, which may be any device that can contain, store, communicate, propagate or transmit the program 11 for use with or in conjunction with an instruction execution system, device or apparatus. More specific examples (a non-exhaustive list) of the computer-readable storage medium 20 include the following: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a static random access memory (SRAM), a portable compact disk read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanical encoding device, and any suitable combination of the foregoing.
[0176] At this point, those skilled in the art should recognize that, although multiple exemplary embodiments of the present invention have been shown and described in detail herein, many other variations or modifications that conform to the principles of the present invention can still be directly determined or derived based on the content disclosed in the present invention without departing from the spirit and scope of the present invention. Therefore, the scope of the present invention should be understood and recognized as covering all these other variations or modifications.
Claims
1. A method for optimizing and scheduling data pages, characterized in that: include: Check whether the database is in a low load state; If yes, then obtain the usage records of each data page in multiple historical time periods; Using a preset time period division strategy to divide each of the historical time periods into a plurality of historical sub-time periods; Calculating the usage probability of each of the data pages in each of the historical sub-time periods according to each of the usage records; Using a usage probability prediction model based on time series, according to the usage probability of each data page in each historical sub-time period, predicting the usage probability of each data page in at least one future time period; Acquire pre-used data pages for each of the future time periods, wherein the pre-used data pages are a first set number of data pages sorted from largest to smallest in terms of usage probability within the corresponding future time period; Before each of the future time periods, the corresponding pre-used data pages are loaded into the memory.
2. The data page optimization scheduling method according to claim 1, characterized in that: The step of calculating the usage probability of each of the data pages in each of the historical sub-time periods according to each of the usage records includes: Calculate the proportion of the duration of each of the historical sub-time periods in the corresponding historical time period; Calculating, according to each of the usage records, a total usage frequency of each of the data pages in each of the set sub-time periods, and a sub-frequency of usage of each of the data pages in each of the historical sub-time periods; The Naive Bayes algorithm is adopted to calculate the usage probability of each of the data pages in each of the historical sub-time periods according to the total usage frequencies, the proportions and the sub-frequency of usage.
3. The data page optimization scheduling method according to claim 1, characterized in that: Before the step of dividing each of the historical time periods into a plurality of historical sub-time periods by using a preset time period division strategy, the method further includes: Acquiring operation status information of the database, and determining whether it is necessary to update the usage probability prediction model according to the operation status information; If so, a training data set is obtained, and the usage probability prediction model is trained using the training data set to update the usage probability prediction model.
4. The method for optimizing and scheduling data pages according to claim 3, characterized in that: The step of obtaining a training data set includes: Obtaining usage records of each of the data pages within a set training cycle; The preset time period division strategy is adopted to divide the set training cycle into a plurality of training sub-time periods, and based on the usage records of each data page in the set training cycle, the usage probability of each data page in each training sub-time period is calculated; Acquire prediction data for each of the training sub-time periods, and construct the training data set according to each of the prediction data and the probability of use of each of the data pages in each of the training sub-time periods; The prediction data is data used to predict the usage probability of each of the data pages in the corresponding training sub-time period.
5. The method for optimizing and scheduling data pages according to claim 4, characterized in that: Before the step of dividing the set training cycle into a plurality of training sub-time periods by using the preset time period division strategy, the method further includes: Dividing the set training cycle into a plurality of preset sub-time periods of equal duration; According to the usage record of each data page in the set training cycle, the number of data pages accessed in each preset sub-time period is obtained; The access volume threshold is obtained according to the maximum number of data pages accessed in each of the preset sub-time periods, and the preset time period division strategy is updated according to the access volume threshold so that the number of data pages accessed in each of the training sub-time periods is greater than or equal to the access volume threshold.
6. The method for optimizing and scheduling data pages according to claim 3, characterized in that: The step of determining whether the usage probability prediction model needs to be updated according to the operation status information comprises: According to the running status information, obtaining the interval between the current time and the time when the usage probability prediction model was last updated; Determine whether the interval duration is greater than a set duration threshold; If so, it is determined that the usage probability prediction model needs to be updated.
7. The method for optimizing and scheduling data pages according to claim 1, characterized in that: The step of detecting whether the database is in a low-load state comprises: The throughput of the database service is obtained, and whether the database is in the low-load state is determined according to the throughput.
8. The data page optimization scheduling method according to claim 1, characterized in that: Before the step of detecting whether the database is in a low-load state, the method further includes: Detecting whether the database has started an optimized scheduling strategy for data pages; If yes, the step of obtaining the throughput of the database service is performed.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the data page optimization scheduling method according to any one of claims 1 to 8 are implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the data page optimization scheduling method described in any one of claims 1 to 8 are implemented.
