Method and device for recommending prefetching page
By extracting and comparing the feature information of the history and current page sequence, the page number of the prefetched page is determined, which solves the problems of inconsistent page reading order in the database and the timeliness of the buffer pool pages, and improves the performance and accuracy of the database.
Patent Information
- Application Number
- CN202410013895.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2023-09-01
- Filing Date
- 2024-01-04
- Publication Date
- 2025-03-04
AI Technical Summary
Due to the inconsistent structure of the database page, the logical structure and physical storage structure are organized, so the pages are not necessarily read in the order of spatial locality. The pages in the buffer pool are time-sensitive, making it difficult to accurately predict the pages that users may read next.
By extracting the characteristic information of the historically read page sequence and comparing it with the currently read page sequence, the page number of the prefetched page is determined, thereby improving the accuracy of the recommended prefetched page.
Improves the accuracy of recommended prefetch pages, reduces I/O latency, and improves database performance.
Smart Images

Figure CN119557523A_ABST
Abstract
Description
[0001] This application claims priority to the Chinese patent application filed with the State Intellectual Property Office of China on September 1, 2023, with application number 202311122221.1 and application name “A data reading method, device and computing device cluster”, all contents of which are incorporated by reference in this application. Technical Field
[0002] The embodiments of the present application relate to the field of cloud computing, and more specifically, to a method and device for recommending pre-fetched pages. Background Art
[0003] To speed up data reading, the database will put some pages in the buffer pool to avoid reading the disk every time, thereby reducing input / output (I / O) latency and improving database performance. Since the buffer pool capacity is limited, the buffer pool manager will eliminate some pages and replace them with new pages based on algorithms such as least recently used (LRU) or least frequently used (LFU).
[0004] However, since database pages are organized in a tree structure, their logical structure and physical storage structure are inconsistent, resulting in pages not necessarily being read in the order of spatial locality. In addition, the pages in the buffer pool are also very time-sensitive, and it is necessary to accurately predict the pages that the user may read next based on the sequence of pages currently read by the user in order to more effectively cache pre-fetched pages. Therefore, how to improve the accuracy of recommending pre-fetched pages to the database to be cached in the buffer pool has become a technical problem that needs to be solved urgently. Summary of the invention
[0005] The embodiments of the present application provide a method and device for recommending pre-fetched pages, which extracts features of a historically read page sequence and compares them with a currently read page sequence, so that the pre-fetched pages can be determined based on the historically read page sequence, thereby improving the accuracy of the recommended pre-fetched pages.
[0006] In a first aspect, a method for recommending pre-fetched pages is provided. The method is applied to a database, wherein the database includes a buffer pool, and the buffer pool is used to cache pages in the database. The method includes: accepting a query request from a user, and reading pages in the database according to the query request; obtaining a first sequence, wherein the first sequence includes N page sequence numbers, the N page sequence numbers correspond one-to-one to the N pages read in the database, and the N page sequence numbers are arranged in the order of time when the N pages are read, and N is a positive integer greater than 1; extracting feature information of at least one window sequence of the first sequence according to an extraction window, wherein each window sequence includes M page sequence numbers, M is the size of the extraction window, and M is a positive integer greater than 1 and less than or equal to N; obtaining a second sequence, wherein the second sequence includes K page sequence numbers, the K page sequence numbers correspond one-to-one to the K pages read latest in the database, and the K page sequence numbers are arranged in the order of time when the K pages are read, and K is a positive integer less than M; determining the page sequence number of at least one pre-fetched page from at least one window sequence of the first sequence according to the feature information of at least one window sequence and the second sequence; and caching at least one pre-fetched page according to the page sequence number of at least one pre-fetched page.
[0007] According to the technical solution provided in the present application, by extracting the features of multiple subsequences (window sequences) of fixed extraction window lengths in the first sequence of historically read pages, and comparing them with the second sequence of currently read pages whose length is smaller than the fixed extraction window, the pre-fetched pages can be determined based on the features of the window sequence, thereby improving the accuracy of the recommended pre-fetched pages, thereby reducing I / O latency and improving database performance.
[0008] In combination with the first aspect, in certain implementations of the first aspect, the characteristic information of the window sequence is used to indicate the arrangement order of M page sequence numbers in the window sequence, and based on the characteristic information of at least one window sequence and the second sequence, the page sequence number of at least one pre-fetched page is determined from at least one window sequence of the first sequence, including: based on the characteristic information of each window sequence, L third sequences are determined from at least one window sequence, the L third sequences are the L rubbed port sequences whose first K page sequence numbers in at least one window sequence have the highest similarity with the second sequence, and L is a positive integer; based on the last H page sequence numbers in the L third sequences, the page sequence number of at least one pre-fetched page is determined, and H is the value of M minus K.
[0009] According to the above technical solution, by extracting and saving the feature information of the window sequence, the pre-fetched page is predicted based on one or more sequences (third sequences) in the window sequence with the highest feature similarity to the second sequence, thereby further improving the accuracy of the recommended pre-fetched page.
[0010] In combination with the first aspect, in certain implementations of the first aspect, determining the page number of at least one pre-fetched page based on the last H page numbers in the L third sequences includes: determining the last H page numbers in the fourth sequence as the page number of at least one pre-fetched page, the fourth sequence being a sequence in which the first K page numbers in the L third sequences have the highest similarity with the second sequence.
[0011] According to the above technical solution, the fourth sequence is a sequence in the third sequence that has the highest similarity to the second sequence, so that the pre-fetched page is predicted based on the closest feature information, thereby improving the success rate of predicting the pre-fetched page.
[0012] In combination with the first aspect, in certain implementations of the first aspect, the page number of at least one pre-fetched page is determined based on the last H page numbers in the L third sequences, including: determining the last H page numbers in the fifth sequence as the page number of at least one pre-fetched page, the fifth sequence being a sequence in which the page corresponding to the last page number in the L third sequences is read the latest.
[0013] According to the above technical solution, the fifth sequence is a sequence in which the page reading time is the latest in the third sequence, so that the pre-fetched pages are predicted according to the latest feature information, thereby improving the success rate of predicting the pre-fetched pages.
[0014] In combination with the first aspect, in certain implementations of the first aspect, when L is a positive integer greater than 1, determining the page number of at least one pre-fetched page based on the last H page numbers in the L third sequences includes: determining the page number of at least one pre-fetched page from the last H page numbers in the L third sequences, wherein the last H page numbers of each third sequence in the L third sequences include the page number of at least one pre-fetched page.
[0015] According to the above technical solution, by predicting and prefetching pages according to the intersection of multiple third sequences, the randomness of the prediction results is reduced, thereby improving the success rate of predicting and prefetching pages.
[0016] In combination with the first aspect, in certain implementations of the first aspect, the method further includes: when the amount of saved feature information is greater than a first threshold, deleting feature information of a sixth sequence, the sixth sequence being a window sequence in which a page corresponding to a first page number in at least one window sequence is read the earliest.
[0017] According to the above technical solution, by regularly eliminating the feature information of the sequence with an earlier storage time, the timeliness of the stored feature information is maintained when the storage space of the feature information is limited, thereby improving the accuracy of predicting pre-fetched pages based on the stored feature information.
[0018] In combination with the first aspect, in certain implementations of the first aspect, the method further includes: obtaining feedback information, the feedback information being used to indicate a proportion of at least one pre-fetched page being read; and when the proportion is less than a second threshold, deleting L feature information of the third sequence.
[0019] According to the above technical solution, by obtaining the predicted hit rate of the pre-fetched page, the feature information with a low predicted hit rate is deleted, so that the saved feature information is dynamically updated according to the prediction result, thereby improving the accuracy of predicting the pre-fetched page based on the saved feature information.
[0020] In combination with the first aspect, in certain implementations of the first aspect, the values of at least two adjacent page numbers included in the M page numbers in each window sequence are discontinuous.
[0021] According to the above technical solution, since the pre-fetched pages of the sequence read in the order of page numbers do not need to be predicted, by only extracting specific subsequences in the first sequence that are not completely read in the order of page numbers within a fixed-length extraction window, more valid subsequences can be extracted for recommending pre-fetched pages when storage space and / or computing power are limited, thereby improving the accuracy of recommended pre-fetched pages.
[0022] In a second aspect, a device for recommending pre-fetched pages is provided, the device is arranged in a database, the database includes a buffer pool, the buffer pool is used to cache pages in the database, the device includes: a query module, used to accept a user's query request, and read the pages in the database according to the query request; a collection module, used to obtain a first sequence, the first sequence includes N page numbers, the N page numbers correspond to the N pages read in the database, the N page numbers are arranged in the time sequence when the N pages are read, and N is a positive integer greater than 1; a learning module, used to extract feature information of at least one window sequence of the first sequence according to the extraction window, in each window sequence It includes M page numbers, M is the size of the extraction window, and M is a positive integer greater than 1 and less than or equal to N; the acquisition module is also used to obtain a second sequence, the second sequence includes K page numbers, the K page numbers correspond to the K pages read latest in the database, the K page numbers are arranged in the order of the time when the K pages are read, and K is a positive integer less than M; the learning module is also used to determine the page number of at least one pre-fetched page from at least one window sequence of the first sequence according to the feature information of at least one window sequence and the second sequence; the cache module is used to cache at least one pre-fetched page according to the page number of at least one pre-fetched page.
[0023] In combination with the second aspect, in certain implementations of the second aspect, the characteristic information of the window sequence is used to indicate the arrangement order of M page numbers in the window sequence, and the learning module is used to: determine L third sequences from at least one window sequence based on the characteristic information of each window sequence, the L third sequences are the L window sequences in which the first K page numbers of at least one window sequence have the highest similarity with the second sequence, and L is a positive integer; determine the page number of at least one pre-fetched page based on the last H page numbers in the L third sequences, and H is the value of M minus K.
[0024] In combination with the second aspect, in certain implementations of the second aspect, the learning module is used to: determine that the last H page numbers in the fourth sequence are the page numbers of at least one pre-fetched page, and the fourth sequence is a sequence in which the first K page numbers of the L third sequences have the highest similarity with the second sequence.
[0025] In combination with the second aspect, in certain implementations of the second aspect, the learning module is used to: determine that the last H page numbers in the fifth sequence are the page numbers of at least one pre-fetched page, and the fifth sequence is a sequence in which the page corresponding to the last page number in the L third sequences is read the latest.
[0026] In combination with the second aspect, in certain implementations of the second aspect, when L is a positive integer greater than 1, the learning module is used to: determine the page number of at least one pre-fetched page from the last H page numbers of L third sequences, wherein the last H page numbers of each third sequence in the L third sequences include the page number of at least one pre-fetched page.
[0027] In combination with the second aspect, in certain implementations of the second aspect, the learning module is also used to: when the amount of saved feature information is greater than a first threshold, delete the feature information of the sixth sequence, the sixth sequence being a window sequence in which the page corresponding to the first page number in at least one window sequence is read the earliest.
[0028] In combination with the second aspect, in certain implementations of the second aspect, the learning module is further used to: obtain feedback information, the feedback information is used to indicate the proportion of at least one pre-fetched page read; when the proportion is less than a second threshold, delete the feature information of L third sequences.
[0029] In combination with the second aspect, in certain implementations of the second aspect, the values of at least two adjacent page numbers included in the M page numbers in each window sequence are discontinuous.
[0030] In a third aspect, a computing device is provided, comprising a processor and a memory, wherein the memory is used to store instructions, and the processor is used to call and execute the instructions from the memory, so that the computing device executes the method in the first aspect or any possible implementation of the first aspect.
[0031] In a fourth aspect, a computing device cluster is provided, comprising at least one computing device, each computing device comprising a processor and a memory, wherein the memory is used to store instructions, and the processor is used to call and execute the instructions from the memory, so that the computing device cluster executes the method in the first aspect or any possible implementation of the first aspect.
[0032] Optionally, the processor may be a general-purpose processor, which may be implemented by hardware or software. When implemented by hardware, the processor may be a logic circuit, an integrated circuit, etc.; when implemented by software, the processor may be a general-purpose processor, which is implemented by reading software code stored in a memory, which may be integrated in the processor or may be located outside the processor and exist independently.
[0033] In a fifth aspect, a chip is provided, which obtains instructions and executes the instructions to implement the method in the above-mentioned first aspect or any possible implementation manner of the first aspect.
[0034] Optionally, as an implementation, the chip includes a processor and a data interface, and the processor reads instructions stored in the memory through the data interface to execute the method in the above-mentioned first aspect or any possible implementation of the first aspect.
[0035] Optionally, as an implementation method, the chip may also include a memory, in which instructions are stored, and the processor is used to execute the instructions stored in the memory. When the instructions are executed, the processor is used to execute the method in the above-mentioned first aspect or any possible implementation method of the first aspect.
[0036] In a sixth aspect, a computer program product comprising instructions is provided. When the instructions are executed by a computing device cluster, the computing device cluster executes the method in the above-mentioned first aspect or any possible implementation manner of the first aspect.
[0037] In a seventh aspect, a computer-readable storage medium is provided, comprising computer program instructions. When the computer program instructions are executed by a computing device cluster, the computing device cluster executes the method in the above-mentioned first aspect or any possible implementation manner of the first aspect.
[0038] By way of example, these computer-readable storage media include, but are not limited to, one or more of the following: read-only memory (ROM), programmable ROM (PROM), erasable PROM (EPROM), Flash memory, electrically EPROM (EEPROM), and hard drive.
[0039] Optionally, as an implementation manner, the above-mentioned storage medium may specifically be a non-volatile storage medium. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Figure 1 It is a schematic diagram of the page storage structure and logical structure in the database.
[0041] Figure 2 It is a schematic diagram of the system architecture of an embodiment of the present application.
[0042] Figure 3 It is a schematic flowchart of a method for recommending pre-fetched pages provided in an embodiment of the present application.
[0043] Figure 4 It is a schematic diagram of a method for recommending pre-fetching pages provided in an embodiment of the present application.
[0044] Figure 5 It is a schematic structural block diagram of a device for recommending pre-fetched pages provided in an embodiment of the present application.
[0045] Figure 6 It is a schematic structural block diagram of a computing device provided in an embodiment of the present application.
[0046] Figure 7 It is a schematic structural block diagram of a computing device cluster provided in an embodiment of the present application.
[0047] Figure 8 It is a schematic structural block diagram of another computing device cluster provided in an embodiment of the present application. DETAILED DESCRIPTION
[0048] The technical solution in this application will be described below in conjunction with the accompanying drawings.
[0049] The present application will present various aspects, embodiments or features around a system including multiple devices, components, modules, etc. It should be understood and appreciated that each system may include additional devices, components, modules, etc., and / or may not include all devices, components, modules, etc. discussed in conjunction with the figures. In addition, combinations of these schemes may also be used.
[0050] In addition, in the embodiments of the present application, words such as "exemplary" and "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described as "exemplary" in the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of the word "exemplary" is intended to present concepts in a concrete way.
[0051] In the embodiments of the present application, "corresponding (corresponding, relevant)" and "corresponding (corresponding)" can sometimes be used interchangeably. It should be pointed out that when the distinction between them is not emphasized, the meanings they intend to express are consistent.
[0052] The network architecture and business scenarios described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application, and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. A person of ordinary skill in the art can appreciate that with the evolution of the network architecture and the emergence of new business scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0053] References to "one embodiment" or "some embodiments" etc. described in this specification mean that a particular feature, structure or characteristic described in conjunction with the embodiment is included in one or more embodiments of the present application. Thus, the phrases "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear at different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0054] In the present application, "at least one" means one or more, and "plurality" means two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can mean: including the existence of A alone, the existence of A and B at the same time, and the existence of B alone, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following items" or similar expressions refers to any combination of these items, including any combination of single items or plural items. For example, at least one of a, b, or c can mean: a, b, c, ab, ac, bc, or abc, where a, b, c can be single or multiple.
[0055] To facilitate understanding, relevant terms and concepts that may be involved in the embodiments of the present application are first introduced below.
[0056] 1. Tablespace: A logical space for storing data in a database. A tablespace consists of segments, extents, and pages.
[0057] A page can also be called a page, data page or block, and is the smallest unit of database disk management. The size of each page is generally 8 kilobytes (KB) or 16KB, and can be other sizes according to the actual needs of the database, which is not specifically limited in this application.
[0058] An extent is a collection of continuous pages. Each extent may generally contain 64 continuous pages, and the default size is 1 megabyte (MB), which is not specifically limited in this application.
[0059] A segment is a collection of zones. According to different functions, the segments contained in the tablespace can be divided into, for example, index segments, data segments, rollback segments, etc. Usually, each segment can contain 256 zones, which is not specifically limited in this application.
[0060] 2. Page number (PageNo): Each page corresponds to a page number, which is used to indicate the storage location and order of the page in the database. The page number can be an integer, which can be composed of two parts. The high bits of the page number, that is, the first several bits of the integer from left to right, can be used to indicate the identification value (identify, ID) of the table space to which the page belongs. The low bits of the page number, that is, the last several bits of the integer from left to right, can be used to identify the offset of the page relative to the first page in the table space to which it belongs.
[0061] For example, the ID of the tablespace can be a continuous positive integer. For example, if the tablespace ID is 5, it means that the page is included in the 5th tablespace in the database. For another example, the offset of the page in the tablespace can be expressed in bytes. Assuming that the size of each page is 16KB, page 0 is the first page in the tablespace, then page 0 is used as a reference and its offset is 0. Page 1 is a page continuous with page 0 in the same tablespace, and its offset can be 16384, indicating that page 1 is offset by 16×1024=16384 bytes relative to page 0. Similarly, the offset of page 2 can be 32768. The above-mentioned numbering rules of page numbers, as well as the corresponding numbering rules of tablespace IDs and offsets are for illustration purposes only. Other numbering rules can also be used according to the actual needs of the database, and this application does not make specific limitations on this.
[0062] It should be understood that in other technical solutions, the page number may also be replaced by other terms, such as page ID, etc. However, any identification value that can be used to indicate the storage location and order of pages in the database and has a one-to-one correspondence with the page can be considered to belong to the same concept as the page number mentioned in the technical solution of this application.
[0063] 3. Buffer pool: It can also be called a buffer zone. It is a fixed memory area allocated in the database process. It is used to obtain and save the content of the page from the database in advance, so that when the user requests to read the content of this part of the page, it can be directly obtained from the memory area without reading the disk where the database stores data, thereby shortening the input / output (I / O) delay when the user reads the page. The pages obtained and saved in advance from the database by the buffer pool can be called pre-fetched pages.
[0064] However, due to the limited capacity of the buffer pool, the buffer pool can only cache data of some pages in the database, and the buffer pool manager will eliminate some pages and replace them with new pages according to algorithms such as least recently used (LRU) or least frequently used (LFU). If the pages obtained and eliminated by the buffer pool can be made more accurate, that is, the probability of the page being stored in the buffer pool when the user requests to read the page is increased, so that the pages requested by the user are obtained from the buffer pool instead of the disk as much as possible, the average I / O delay of the read can be reduced and the database performance can be improved. Therefore, how to improve the accuracy of recommending pre-fetched pages to the database to be cached in the buffer pool has become a technical problem that needs to be solved urgently.
[0065] In traditional solutions, pre-fetched pages can be determined based on the spatial locality of the page. That is, if the number of pages with consecutive page numbers that the user has read reaches a certain threshold, then several pages with consecutive page numbers are determined as pre-fetched pages. However, since database pages are organized in a tree structure, their logical structure and physical storage structure are inconsistent, resulting in pages not necessarily being read in the order of spatial locality. Figure 1 In the example shown, P1 to P7 represent 7 pages with consecutive page numbers, and their storage structure is consistent with the order of the page numbers. Their logical structure is as follows: the child nodes of P1 are P2, P3 and P4, and further the child nodes of P2 are P5, P6 and P7. In the above case, P2 is not physically stored continuously with P5, P6 and P7, but they are logically continuous, so that after P1 and P2 are read, the next page that may be read is P5, P6 or P7 but not necessarily P3. Therefore, when the page numbers of the pages to be read are not continuous, the above scheme cannot determine the pre-fetched pages.
[0066] Traditional solutions can also determine the pre-fetched pages based on the symbiotic relationship of pages. For example, historical statistics of user page readings show that the frequency of page 2 being read when page 1 is read exceeds a certain threshold, then the next time the user reads page 1, page 2 will be determined as the pre-fetched page, or the next time the user reads page 2, page 1 will be determined as the pre-fetched page. However, the pages in the buffer pool also have a strong timeliness. For example, assuming that in the historical records of page 1 and page 2 being read by the user together, page 2 is actually read first and then page 1. If the user reads page 1 alone next time, the probability that page 2 is requested to be read after page 1 as a pre-fetched page is not high, resulting in a reduced prediction accuracy.
[0067] In view of this, an embodiment of the present application provides a method for recommending pre-fetched pages, by extracting the features of the historically read page sequence and comparing it with the currently read page sequence, so that the pre-fetched pages can be determined according to the timing of the historically read page sequence, thereby improving the accuracy of the recommended pre-fetched pages.
[0068] Figure 2 : is a schematic diagram of a system architecture applicable to an embodiment of the present application. The system may include a database, and the database may include a disk / storage resource pool 210, a cache management module 220, and a database engine (DB Engine) 230. Among them, the disk / storage resource pool 210 can be used to persistently store pages in the database. The cache management module 220 can be used to obtain pages from the disk / storage resource pool 210 and cache them in the buffer pool. Optionally, the cache management module 220 can also eliminate cached pages in the buffer pool, for example, eliminating pages according to the LRU and / or LFU algorithm. The database engine 230 is used to execute the query statement entered by the user and read the corresponding page according to the query statement. When reading a page, the database engine 230 can first request the cache management module 220. If the page has been cached in the buffer pool, the database engine 230 reads the page from the buffer pool, otherwise the database engine 230 reads the page from the disk / storage resource pool 210.
[0069] The above system may also include a collection module (collector) 240 and a learning module (learner) 250, and the collection module 240 and the learning module 250 may be used to implement the method for recommending pre-fetched pages provided in the embodiment of the present application. Among them, the collection module 240 may be used to obtain the page sequence number of the page read by the user from the database engine 230, and to sort out the sequence information of the historically read pages, which may include the page sequence numbers of multiple pages arranged in the order of the time when they were read, and send the sorted sequence information of the historically read pages to the learning module 250.
[0070] The learning module 250 can be used to determine the pre-fetched pages and recommend them to the cache management module 220 based on the sequence information of the historically read pages. Optionally, the learning module 250 can first determine whether the way the pages in the current database are read is "sequential mode" based on whether the page numbers in the sequence information are continuous. For example, if the page numbers in the sequence information are completely continuous, the learning module 250 can determine that the current mode is "sequential mode", then the learning module 250 can make no additional predictions, so that the cache management module 220 caches the pages in sequence; otherwise, the learning module 250 can determine that the current mode is "non-sequential mode", then the learning module 250 can extract and save the feature information in the sequence information, and use it to predict the pre-fetched pages based on the similarity of the feature information. Optionally, the learning module 250 recommends that the pre-fetched pages cached by the cache management module 220 can be cached in an independent partition divided from the buffer pool, thereby preventing the accuracy of the pre-fetched page prediction from having a significant impact on the original buffer pool. Optionally, the cache management module 220 may also feed back the prediction effect of the pre-fetched pages to the learning module 250, so that the learning module 250 adjusts the prediction method for the pre-fetched pages according to the effect feedback.
[0071] It should be understood that the internal processing flow of the above-mentioned learning module 250 is only used as an example for illustration, and the learning module 250 can also determine the pre-fetched pages according to the sequence information of the historically read pages in other ways, and this application does not make any specific limitation on this.
[0072] Optionally, the acquisition module 240 and the learning module 250 may be two independent modules, or their functions may be integrated into one module. For example, the function of the acquisition module 240 may be integrated into the learning module 250. In this case, the learning module 250 is used to obtain and organize the sequence information of the historically read pages, and recommend pre-fetched pages based on the sequence information.
[0073] It should be understood that the above-mentioned acquisition module 240 and learning module 250 can be deployed outside the database as independent modules and used in conjunction with the database, or they can be deployed inside the database as components of the database. This application does not make specific limitations on this.
[0074] Combine the following Figure 3 , describes in detail the method for recommending pre-fetching pages of the present application. Optionally, Figure 3 The method shown can be applied to Figure 2 The system shown.
[0075] It should be understood that for ease of description, the following embodiments are Figure 2The system shown in is used as the execution subject to introduce the method for recommending pre-fetched pages provided by the embodiment of the present application, but the execution subject of the method for recommending pre-fetched pages provided by the embodiment of the present application is not limited to this. For example, the following step S320 can be executed by the acquisition module 240, and steps S330 to S350 can be executed by the learning module 250; and when the functions of the acquisition module 240 and the learning module 250 are integrated inside the database, the above steps can also be executed by the modules inside the database, such as the cache management module 220, and this application does not make specific limitations on this.
[0076] like Figure 3 As shown, the method includes the following steps.
[0077] Step S310: accepting a user's query request and reading pages in the database according to the query request.
[0078] For example, in step S310, the database engine 230 may obtain a query statement input by a user, and the query statement is used to query data in the database. The database engine 230 may parse the query statement and read the page where the data indicated by the query statement is located. Optionally, the database engine 230 may read the page from the disk / storage resource pool 210 or from the buffer pool, which is not specifically limited in this application.
[0079] It should be understood that the above step S310 may be repeatedly executed multiple times, that is, there may be multiple pages in the database that have been read by the user at different times.
[0080] Step S320: Acquire the first sequence.
[0081] For example, in step S320, the acquisition module 240 can obtain a first sequence. The first sequence can be the sequence information of the historically read pages. Specifically, the first sequence can include N page numbers, which correspond one-to-one to the N pages read in the database, and the N page numbers are arranged in the time sequence when the corresponding N pages are read, and N is a positive integer greater than 1. As an example, after each execution of step S310, that is, after a page in the database is read, the acquisition module 240 can obtain the page number of the page read this time from the database engine 230, and the acquisition module 240 records the page number obtained each time in the acquisition order to form a first sequence.
[0082] The above-mentioned N page numbers may include the same page number or different page numbers, wherein the same page number corresponds to the same page, and different page numbers correspond to different pages. For example, assuming that P1 to P9 represent 9 different pages in the database, and the page numbers corresponding to P1 to P9 are respectively represented by positive integers 1 to 9, if the user reads pages P1, P2, P5, P9, P2, and P6 in a period of time, the first sequence corresponding to the period can be represented as 125926. It should be understood that the above-mentioned representation of the page number is only for illustration, and the embodiment of the present application does not specifically limit the specific representation rules of the page number.
[0083] Step S330: extracting feature information of at least one window sequence of the first sequence according to the extraction window.
[0084] For example, in step S330, the learning module 250 may extract at least one continuous subsequence from the first sequence as a window sequence. Specifically, at least one window sequence may have the same and fixed length. For example, each window sequence may include M page numbers, where M is a positive integer greater than 1 and less than or equal to N. Among them, a continuous subsequence refers to a sequence consisting of a number of consecutive page numbers in the original sequence starting from a certain page number in the original sequence. For example, assuming that the first sequence is 125926, where each bit represents a page number, the continuous subsequence of the first sequence length of 3 may include 125, 259, 592, and 926.
[0085] For example, the learning module 250 can set an extraction window with a length of M pages, slide the extraction window backward from the first page number in the first sequence, and sequentially use the page numbers contained in the extraction window as a window sequence. The distance of each sliding extraction window can be determined according to actual needs, and the present application does not make specific restrictions on this. The shorter the sliding distance each time, the more window sequences can be extracted, thereby increasing the amount of information that can be used to predict pre-fetched pages and improving the prediction accuracy; the longer the sliding distance each time, the fewer window sequences can be extracted, thereby saving the time required to store the window sequence and improving the feature extraction efficiency. For example, assuming that the extraction window length is M and the sliding distance of each extraction window is P, the window sequence extracted for the first time is the page numbers from 1 to M in the first sequence, and the window sequence extracted for the second time is the page numbers from 1+P to M+P in the first sequence, where P is a positive integer, and so on.
[0086] After determining at least one window sequence, the learning module 250 can also obtain and save the characteristic information of each window sequence, and the characteristic information is used to indicate the arrangement order of the M page numbers in the corresponding window sequence. It should be understood that since the page number can have multiple representations, the corresponding sequence of page numbers can also have multiple representations, so the characteristic information of the window sequence can also have different representations. For example, the characteristic information of the window sequence can be the specific value of each page number in the window sequence and the list of the arrangement order of each value; or the characteristic information of the window sequence can also include but is not limited to the frequency of each page number in the window sequence, the average distance between any two page numbers in the window sequence, the frequency of the order in which any two page numbers appear in the window sequence, etc. The present application does not specifically limit the form of the characteristic information.
[0087] Optionally, in some possible implementations, the M page numbers in each window sequence include at least two adjacent page numbers whose values are discontinuous. That is, each window sequence is in a "non-sequential mode". The opposite of the "non-sequential mode" is the "sequential mode", which means that the arrangement order of each page number in the sequence is consistent with the numbering order of the page numbers, that is, the order in which the pages are read is consistent with the numbering order of their page numbers.
[0088] As mentioned above, the mode in which pages are read in the database can be divided into "sequential mode" and "non-sequential mode". If the page currently being read by the user conforms to the sequential mode, the buffer pool can directly cache subsequent pages in the order of page numbers without the need for the learning module 250 to make predictions, so the learning module 250 can only make predictions when the page currently being read by the user does not conform to the sequential mode. In this case, when the learning module 250 needs to make a prediction, it means that the page currently being read by the user is in "non-sequential mode", so only the subsequence of "non-sequential mode" in the first sequence may contribute to the prediction result, so at least one window sequence determined by the learning module 250 from the first sequence can all be "non-sequential mode".
[0089] It should be understood that the "continuous page number values" mentioned in the above embodiment means that according to the numbering rule of page numbers, no other page number can be inserted between two page numbers, and the value of the previous page number is less than the value of the next page number according to the numbering rule. In other words, if the page numbers of page a and page b are continuous, it means that according to the numbering rule of page numbers, the next page number of the page number of page a is the page number of page b. For example, assuming that the numbering rule of page numbers is the offset in the table space mentioned above, and the size of each page is 16KB, i.e., 16384 bytes, the minimum difference between each page number is 16384. In this case, page number 0 and page number 16384 are two consecutive page numbers, and page number 16384 and page number 32768 are also two consecutive page numbers.
[0090] For example, when the learning module 250 slides the extraction window on the first sequence to determine the window sequence, after each sliding, it can first determine whether the page number in the extraction window is in "sequential mode". If so, the extraction window is directly slid backward to the next position to continue the determination; otherwise, the page number in the extraction window is saved as a window sequence and continues to slide backward.
[0091] For example, assume that the numbering rule of the page numbers is a positive integer from 1 to 9, the first sequence is 2123478, the extraction window length of the window sequence is 3, and the extraction window sliding distance is 1. In this case, the subsequences of the first sequence obtained by the learning module 250 sliding the extraction window are 212, 123, 234, 347, and 478. Among them, the three page numbers in the subsequence 123 are completely continuous, and the three page numbers in the subsequence 234 are also completely continuous. Therefore, these two subsequences belong to the "sequential mode" and are not saved by the learning module 250. Therefore, the at least one window sequence finally determined by the learning module 250 is 212, 347, and 478.
[0092] Through the above solution, when the storage space and / or computing power of the learning module 250 is limited, more valid subsequences can be extracted for recommending pre-fetched pages, thereby improving the accuracy of recommending pre-fetched pages.
[0093] Step S340: Acquire the second sequence.
[0094] For example, in step S340, the acquisition module 240 may acquire a second sequence. The second sequence may be a sequence of pages currently being read in the database. Specifically, the second sequence may include K page numbers, the N page numbers correspond one-to-one to the K pages read latest in the database, and the K page numbers are arranged in the order of the time when the corresponding K pages are read, and K is a positive integer less than M.
[0095] It should be understood that the first sequence can be continuously acquired and updated, that is, each time a page is read in the database, the acquisition module 240 can add the page number of the page at the end of the first sequence to update it to a new first sequence. Therefore, at the time when step S330 is executed, the first sequence can include the page numbers of all pages read from the starting time to the current time. That is, the first sequence can include the page numbers of the last K pages read before the current time. Therefore, the second sequence can also be considered as the last continuous subsequence of length K in the first sequence at the current time.
[0096] Step S350: Determine a page sequence number of at least one pre-fetched page from at least one window sequence of the first sequence according to the characteristic information of at least one window sequence and the second sequence.
[0097] For example, in step S350, the learning module 250 may predict the page number of at least one subsequent pre-fetched page of the second sequence according to the similarity between the second sequence and at least one window sequence. The pre-fetched page refers to the page that the learning module 250 predicts may be read after the current moment, that is, the page that the learning module 250 recommends to be cached in the buffer pool.
[0098] As an example, the learning module 250 can determine L third sequences from at least one window sequence based on the characteristic information of each window sequence, and the L third sequences are the L window sequences in which the first K page numbers in at least one window sequence have the highest similarity with the second sequence, and L is a positive integer. Specifically, the learning module 250 can determine the arrangement order of the first K page numbers in each window sequence based on the characteristic information of the window sequence, and compare the arrangement order of the first K page numbers in each window sequence with the arrangement order of K page numbers in the second sequence, thereby determining the L window sequences in which the arrangement order of the first K page numbers has the highest similarity with the second sequence, and the L window sequences can be called third sequences, which can be used to predict the page numbers of pre-fetched pages.
[0099] After determining the L third sequences, the learning module 250 can determine the page sequence number of at least one pre-fetched page based on the last H page sequence numbers in the L third sequences, where H is the value of M minus K, that is, H=MK. Since the length of the second sequence is longer than the third sequence, and the arrangement order of the first K page sequence numbers of the third sequence is highly similar to the second sequence, there is a high possibility that the arrangement order of the page sequence numbers after the second sequence will develop according to the third sequence. That is, the page sequence number of the pre-fetched page may also have a high similarity with the last H page sequence numbers in the four sequences. Therefore, predicting the page sequence number of at least one pre-fetched page based on the last H page sequence numbers in the L third sequences can further improve the accuracy of recommending pre-fetched pages.
[0100] In conjunction with three specific embodiments, a method for determining the page sequence number of at least one pre-fetched page according to the last H page sequence numbers in the L third sequences is described below.
[0101] Embodiment 1: determining the page sequence number of the pre-fetched page according to a sequence with the highest similarity to the second sequence among a plurality of third sequences.
[0102] For example, the learning module 250 may select one from the L third sequences as the fourth sequence, wherein the fourth sequence is a sequence in which the arrangement order of the first K page numbers in the L third sequences has the highest similarity to the second sequence. After determining the fourth sequence, the learning module 250 may determine all the last H page numbers in the fourth sequence as the page numbers of the pre-fetched pages. Through the above scheme, the pre-fetched pages are predicted based on the closest feature information, thereby improving the prediction success rate.
[0103] Embodiment 2: determining the page sequence number of the pre-fetched page according to a sequence with the latest page reading time among multiple third sequences.
[0104] For example, the learning module 250 may select one from the L third sequences as the fifth sequence, wherein the fifth sequence is a sequence in which the page corresponding to the last page sequence number in the L third sequences is read the latest. That is, the page corresponding to the page sequence number in the fifth sequence is read the closest to the current moment. After determining the fifth sequence, the learning module 250 may determine all of the last H page sequence numbers in the fifth sequence as the page sequence numbers of the pre-fetched pages. Through the above scheme, the pre-fetched pages are predicted based on the latest feature information, thereby improving the prediction success rate.
[0105] Embodiment 3: determining the page sequence number of the pre-fetched page according to the intersection of multiple third sequences.
[0106] For example, when L is a positive integer greater than 1, the learning module 250 can determine the last H page numbers of each third sequence in the L third sequences, and determine the intersection of the last H page numbers of each third sequence as the page number of the pre-fetched page, that is, the last H page numbers of each third sequence include the page number of the at least one pre-fetched page. In other words, the page number of at least one pre-fetched page is a page number that appears in the last H page numbers of each third sequence. Through the above scheme, the pre-fetched page is predicted according to the intersection of multiple feature information, reducing the randomness of the prediction result.
[0107] It should be understood that the above three solutions are only examples, and the learning module 250 can also predict the page number of the pre-fetched page according to the L third sequences in other ways, and this application does not make specific limitations on this. For example, the learning module 250 can make predictions by combining all or part of the above embodiments. As an example, the learning module 250 can determine the intersection of the fourth sequence and the fifth sequence as the page number of the pre-fetched page, and this application does not make specific limitations on this.
[0108] Through the above scheme, by extracting and saving the characteristic information of the window sequence, the pre-fetched page is predicted based on one or more sequences (third sequences) in the window sequence with the highest characteristic similarity to the second sequence, thereby further improving the accuracy of the recommended pre-fetched page.
[0109] Step S360: caching at least one pre-fetched page according to the page sequence number of the at least one pre-fetched page.
[0110] For example, in step S360, the cache management module 220 may instruct the buffer pool to cache the pre-fetched page according to the page sequence number of the pre-fetched page. As an example, the learning module 250 may send instruction information to the cache management module 220, and the instruction information may be used to instruct the buffer pool to obtain at least one pre-fetched page from the database. For example, the instruction information may include the page sequence number of at least one pre-fetched page, so that the buffer pool may request the corresponding at least one pre-fetched page from the disk / storage resource pool of the database according to the page sequence number, thereby caching the at least one pre-fetched page in the buffer pool.
[0111] Through the technical solution of the embodiment of the present application, the features of multiple subsequences (window sequences) of fixed extraction window lengths in the first sequence of historically read pages are extracted, and compared with the second sequence of currently read pages whose length is smaller than the fixed extraction window, so that the pre-fetched pages can be determined according to the window sequence, thereby improving the accuracy of the recommended pre-fetched pages, thereby reducing I / O latency and improving database performance.
[0112] Combine the following Figure 4 , introduced through specific embodiments Figure 3 Application of the method shown.
[0113] Figure 4 Each rectangle in the figure represents a page, and the number in the rectangle represents the page number of the page. It is assumed that the page numbering rule is a positive integer from 1 to 9. The rectangle with a solid border represents the page that has been read before the current moment, and is arranged from left to right in the order of the time when it was read. Figure 4As shown in FIG. 1 , the first sequence may be a sequence consisting of the page numbers of all pages that have been read. Assume that the extraction window length for extracting the window sequence from the first sequence is 5, and the extraction window sliding distance is 3. In this case, the continuous subsequences that can be extracted from the first sequence include 612345, 345678, 678895, 895273, and 273649, among which 345678 is read in "sequential mode", so four candidate window sequences 612345, 678895, 895273, and 273649 can be determined. Figure 4 As shown, assume that the length of the second sequence is 4, that is, the second sequence is a subsequence composed of the last 4 page numbers in the first sequence, that is, 4952. In this case, the first 4 page numbers in each window sequence, 6123, 6788, 8952, and 2736, can be compared with the second sequence 4952. Among them, 8952 is the sequence with the highest similarity to 4952, so the page number of the pre-fetched page can be predicted based on the corresponding window sequence 895273. For example, the last two page numbers 7 and 3 in the window sequence 895273 can be used as the page numbers of the next two pre-fetched pages. As shown in Figure 4 As shown, the rectangle with a dotted border represents the pre-fetched pages recommended for buffering out of the cache, and 7 and 3 are the page numbers of the two pre-fetched pages. If there are no pages with page numbers 7 and 3 in the current buffer pool, the buffer pool can obtain and save pages with page numbers 7 and 3 from the database.
[0114] Optionally, in some possible implementations, the method for recommending pre-fetched pages provided in the embodiment of the present application may further include eliminating window sequence feature information. The following describes the feature information elimination method in conjunction with two specific embodiments.
[0115] Embodiment 1: Eliminate old feature information.
[0116] For example, the learning module 250 may delete the feature information of the sixth sequence when the number of feature information stored is greater than the first threshold, wherein the sixth sequence may be a sequence in which the page corresponding to the first page number in all window sequences is read the earliest. As an example, the learning module 250 may eliminate feature information according to a first in first out (FIFO) method. For example, when the learning module 250 saves the feature information of the window sequence, it may first save the feature information of the window sequence composed of the page numbers of the pages read earlier according to the order in which the pages are read, so that when the feature information needs to be deleted, it starts to delete from the earliest saved feature information in the current feature information.
[0117] For example, when the learning module 250 obtains a window sequence, it can slide the extraction window from left to right on the first sequence. Each time it slides, if the subsequence in the extraction window is a window sequence that meets the conditions, the feature information of the current subsequence is extracted and saved, so that the feature information is saved in the order in which the pages are read.
[0118] It should be understood that the above examples are only for eliminating old feature information, and the newness of feature information can also be determined by other means. For example, the reading time of the page corresponding to the first page number in each window sequence can be recorded separately as part of the feature information, so that when the feature information is eliminated, the newness of the feature information can be determined based on the content of this part. This application does not make specific limitations on this.
[0119] Through the above scheme, feature information of sequences with earlier storage time is periodically eliminated, so that the timeliness of the stored feature information is maintained when the storage space of the feature information is limited, thereby improving the accuracy of predicting pre-fetched pages based on the stored feature information.
[0120] Embodiment 2: Eliminate feature information with low prediction accuracy.
[0121] For example, after the aforementioned step S360, the learning module 250 may also obtain feedback information, which may be used to indicate the ratio of the aforementioned at least one pre-fetched page being read; the learning module 250 may determine whether to retain or delete the feature information used to predict the page sequence number of the at least one pre-fetched page according to the ratio of the at least one pre-fetched page being read. As an example, the learning module 250 may delete the feature information of the aforementioned L third sequences when the ratio of the at least one pre-fetched page being read is less than the second threshold, wherein the feature information of the aforementioned L third sequences is used to predict the sequence of the at least one pre-fetched page in step S340. For example, assuming that the second threshold is 50%, the learning module 250 predicts the page sequence numbers of 3 pre-fetched pages according to the feature information of the L third sequences, and if at least two of the 3 pre-fetched pages are subsequently read by the user, the prediction accuracy is greater than 50%, and thus the feature information corresponding to the third sequence is retained; on the contrary, if the number of the 3 pre-fetched pages subsequently read by the user is less than or equal to one, the prediction accuracy is less than 50%, and thus the feature information corresponding to the third sequence is deleted.
[0122] Optionally, the learning module 250 may determine whether to retain or delete the feature information based on the comprehensive results of multiple feedback information. For example, when the feature information of a certain window sequence is used more than or equal to a certain number of times, for example, more than or equal to 3 times, the learning module 250 may compare the average proportion of pre-fetched pages read in 3 times with a specific threshold, and delete the feature information if it is less than the specific threshold.
[0123] Through the above scheme, the predicted hit rate of the pre-fetched page is obtained, and the feature information with a low predicted hit rate is deleted, so that the saved feature information is dynamically updated according to the prediction result, thereby improving the accuracy of predicting the pre-fetched page based on the saved feature information.
[0124] It should be understood that the above two schemes are only examples, and the learning module 250 can also eliminate feature information in other ways, and the present application does not make specific limitations on this. For example, the learning module 250 eliminates feature information in combination with the above two methods. As an example, the learning module 250 can first save the feature information of the window sequence composed of the page numbers of the pages read earlier in the FIFO table according to the FIFO method, according to the order in which the pages are read, and give priority to deleting the feature information at the bottom of the FIFO table when the amount of feature information is too much; however, in addition, if a certain feature information is used to predict the pre-fetched page, and the proportion of the pre-fetched page read exceeds a certain threshold, the learning module 250 can move this feature information from the original position in the FIFO table to the top of the FIFO table, so that some feature information that is saved early but has a low prediction accuracy will not be eliminated first.
[0125] Combination of the above Figure 3 and Figure 4 The method embodiment of the present invention for recommending pre-fetched pages is described below. Figures 5 to 8 , an embodiment of the device for recommending pre-fetched pages provided in this application is described.
[0126] Figure 5 A schematic structural diagram of a device 500 for recommending pre-fetched pages provided in an embodiment of the present application is shown. The device 500 may be arranged in a database, and the database may include a buffer pool, which may be used to cache pages in the database.
[0127] like Figure 5 As shown, the device 500 for recommending pre-fetched pages includes: a query module 510 , a collection module 520 , a learning module 530 , and a cache module 540 .
[0128] Specifically, the query module 510 is used to accept a user's query request and read pages in the database according to the query request.
[0129] Specifically, the acquisition module 520 is used to obtain a first sequence, which includes N page numbers, which correspond one-to-one to the N pages read from the database, and are arranged in the time sequence when the N pages are read, and N is a positive integer greater than 1.
[0130] Specifically, the learning module 530 is used to extract feature information of at least one window sequence of the first sequence according to the extraction window, each window sequence includes M page numbers, M is the size of the extraction window, and M is a positive integer greater than 1 and less than or equal to N.
[0131] Optionally, the M page numbers in each window sequence include at least two adjacent page numbers whose values are discontinuous.
[0132] Specifically, the acquisition module 520 is also used to obtain a second sequence, which includes K page numbers, which correspond one-to-one to the K pages read latest in the database, and are arranged in the order of the time when the K pages are read, and K is a positive integer less than M.
[0133] Specifically, the learning module 530 is further configured to determine a page sequence number of at least one pre-fetched page from at least one window sequence of the first sequence according to feature information of at least one window sequence and the second sequence.
[0134] Optionally, the learning module 530 is specifically used to determine L third sequences from at least one window sequence based on the feature information of each window sequence, where the L third sequences are the L window sequences whose first K page numbers in at least one window sequence have the highest similarity with the second sequence, and L is a positive integer; and determine the page number of at least one pre-fetched page based on the last H page numbers in the L third sequences, where H is the value of M minus K.
[0135] Optionally, the learning module 530 is specifically configured to determine that the last H page numbers in the fourth sequence are the page numbers of at least one pre-fetched page, and the fourth sequence is a sequence in which the first K page numbers of the L third sequences have the highest similarity with the second sequence.
[0136] Optionally, the learning module 530 is specifically configured to determine that the last H page numbers in the fifth sequence are the page numbers of at least one pre-fetched page, and the fifth sequence is a sequence in which the page corresponding to the last page number in the L third sequences is read the latest.
[0137] Optionally, when L is a positive integer greater than 1, the learning module 530 is specifically used to determine the page number of at least one pre-fetched page from the last H page numbers of L third sequences, wherein the last H page numbers of each third sequence in the L third sequences include the page number of at least one pre-fetched page.
[0138] Specifically, the cache module 540 is used to cache at least one pre-fetched page according to the page sequence number of the at least one pre-fetched page.
[0139] Optionally, the learning module 530 is further configured to delete the feature information of a sixth sequence when the amount of feature information stored is greater than a first threshold, the sixth sequence being a window sequence in which a page corresponding to a first page number in at least one window sequence is read earliest.
[0140] Optionally, the learning module 530 is further used to obtain feedback information, where the feedback information is used to indicate a ratio of at least one pre-fetched page being read; when the ratio is less than a second threshold, delete L feature information of the third sequence.
[0141] Among them, the above modules can be implemented by software or hardware. Exemplarily, the implementation of the learning module 530 is introduced below by taking the learning module 530 as an example. Similarly, the implementation of the query module 510, the acquisition module 520 and the cache module 540 can refer to the implementation of the learning module 530.
[0142] As an example of a software functional unit, the learning module 530 may include code running on a computing instance. Among them, the computing instance may include at least one of a physical host (computing device), a virtual machine, and a container. Furthermore, the above-mentioned computing instance may be one or more. For example, the learning module 530 may include code running on multiple hosts / virtual machines / containers. It should be noted that the multiple hosts / virtual machines / containers used to run the code can be distributed in the same region (region) or in different regions. Furthermore, the multiple hosts / virtual machines / containers used to run the code can be distributed in the same availability zone (AZ) or in different AZs, each AZ including one data center or multiple data centers with close geographical locations. Among them, usually a region can include multiple AZs.
[0143] Similarly, multiple hosts / virtual machines / containers used to run the code can be distributed in the same virtual private cloud (VPC) or in multiple VPCs. Usually, a VPC is set up in a region. For cross-region communication between two VPCs in the same region and between VPCs in different regions, a communication gateway needs to be set up in each VPC to achieve interconnection between VPCs through the communication gateway.
[0144] As an example of a hardware functional unit, the learning module 530 may include at least one computing device, such as a server, etc. Alternatively, the learning module 530 may also be a device implemented using an application-specific integrated circuit (ASIC) or a programmable logic device (PLD). The PLD may be a complex programmable logical device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof.
[0145] The multiple computing devices included in the learning module 530 can be distributed in the same region or in different regions. The multiple computing devices included in the learning module 530 can be distributed in the same AZ or in different AZs. Similarly, the multiple computing devices included in the learning module 530 can be distributed in the same VPC or in multiple VPCs. The multiple computing devices can be any combination of computing devices such as servers, ASICs, PLDs, CPLDs, FPGAs, and GALs.
[0146] It should be noted that, in other embodiments, the query module 510, the acquisition module 520, the learning module 530 and the cache module 540 can be used to execute any step in the above-mentioned method for recommending pre-fetching pages, and the steps that the query module 510, the acquisition module 520, the learning module 530 and the cache module 540 are responsible for implementing can be specified as needed. The query module 510, the acquisition module 520, the learning module 530 and the cache module 540 respectively implement different steps in the above-mentioned method for recommending pre-fetching pages to realize all the functions of the device 500.
[0147] The present application also provides a computing device 100. Figure 6 As shown, the computing device 100 includes: a bus 102, a processor 104, a memory 106, and a communication interface 108. The processor 104, the memory 106, and the communication interface 108 communicate with each other through the bus 102. The computing device 100 can be a server or a terminal device. It should be understood that the present application does not limit the number of processors and memories in the computing device 100.
[0148] The bus 102 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 6 The bus 102 is represented by only one line, but it does not mean that there is only one bus or one type of bus. The bus 102 may include a path for transmitting information between various components of the computing device 100 (eg, the memory 106, the processor 104, and the communication interface 108).
[0149] The processor 104 may include any one or more of a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
[0150] The memory 106 may include a volatile memory, such as a random access memory (RAM). The memory 106 may also include a non-volatile memory, such as a read-only memory (ROM), a flash memory, a hard disk drive (HDD), or a solid state drive (SSD).
[0151] The memory 106 stores executable program codes, and the processor 104 executes the executable program codes to respectively implement the functions of the query module, the acquisition module, the learning module, and the cache module, thereby implementing the method for recommending pre-fetched pages. That is, the memory 106 stores instructions for executing the method for recommending pre-fetched pages.
[0152] The communication interface 108 uses a command distribution module such as, but not limited to, a network interface card, a transceiver, etc. to implement communication between the computing device 100 and other devices or a communication network.
[0153] The embodiment of the present application also provides a computing device cluster. The computing device cluster includes at least one computing device. The computing device can be a server, such as a central server, an edge server, or a local server in a local data center. In some embodiments, the computing device can also be a terminal device such as a desktop computer, a laptop computer, or a smart phone.
[0154] like Figure 7 As shown, the computing device cluster includes at least one computing device 100. The memory 106 in one or more computing devices 100 in the computing device cluster may store the same instructions for executing the above method for recommending pre-fetching pages.
[0155] In some possible implementations, the memory 106 of one or more computing devices 100 in the computing device cluster may also store partial instructions for executing the method for recommending prefetching pages. In other words, the combination of one or more computing devices 100 may jointly execute instructions for executing the method for recommending prefetching pages.
[0156] It should be noted that the memory 106 in different computing devices 100 in the computing device cluster can store different instructions, which are respectively used to execute part of the functions of the apparatus for recommending pre-fetched pages. That is, the instructions stored in the memory 106 in different computing devices 100 can implement the functions of one or more modules among the query module, the acquisition module, the learning module and the cache module.
[0157] In some possible implementations, one or more computing devices in the computing device cluster may be connected via a network, which may be a wide area network or a local area network. Figure 8 A possible implementation is shown. Figure 8 As shown, two computing devices 100A and 100B are connected via a network. Specifically, the network is connected via a communication interface in each computing device. In this type of possible implementation, the memory 106 in the computing device 100A stores instructions for executing the functions of the query module and the cache module. At the same time, the memory 106 in the computing device 100B stores instructions for executing the functions of the acquisition module and the learning module.
[0158] It should be understood that Figure 8 The functions of the computing device 100A shown in FIG. 1 may also be completed by multiple computing devices 100. Similarly, the functions of the computing device 100B may also be completed by multiple computing devices 100.
[0159] An embodiment of the present application further provides a chip, which includes a processor and a data interface. The processor reads instructions stored in a memory through the data interface to execute the above-mentioned method for recommending pre-fetching pages.
[0160] The embodiment of the present application also provides a computer program product including instructions. The computer program product may be software or a program product including instructions that can be run on a computing device or stored in any available medium. When the computer program product is run on at least one computing device, the at least one computing device executes the above-mentioned method for recommending pre-fetched pages.
[0161] The embodiment of the present application also provides a computer-readable storage medium. The computer-readable storage medium can be any available medium that can be stored by a computing device or a data storage device such as a data center that contains one or more available media. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk). The computer-readable storage medium includes instructions that instruct the computing device to execute the above-mentioned method for recommending pre-fetching pages.
[0162] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0163] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the protection scope of the technical solutions of the embodiments of the present application.
Claims
1. A method for recommending pre-fetched pages, characterized in that: The method is applied to a database, wherein the database includes a buffer pool, and the buffer pool is used to cache pages in the database. The method includes: Accepting a user's query request and reading a page in the database according to the query request; Acquire a first sequence, wherein the first sequence includes N page numbers, the N page numbers correspond one-to-one to the N pages read from the database, the N page numbers are arranged in a time sequence when the N pages are read, and N is a positive integer greater than 1; Extracting feature information of at least one window sequence of the first sequence according to the extraction window, each window sequence includes M page numbers, where M is the size of the extraction window and M is a positive integer greater than 1 and less than or equal to N; Obtain a second sequence, wherein the second sequence includes K page numbers, the K page numbers correspond one-to-one to the K pages read latest in the database, the K page numbers are arranged in the order of the time when the K pages are read, and K is a positive integer less than M; Determining a page sequence number of at least one pre-fetched page from at least one window sequence of the first sequence according to the characteristic information of the at least one window sequence and the second sequence; The at least one pre-fetched page is cached according to the page sequence number of the at least one pre-fetched page.
2. The method according to claim 1, characterized in that The characteristic information of the window sequence is used to indicate the arrangement order of the M page numbers in the window sequence. The step of determining, according to the feature information of the at least one window sequence and the second sequence, a page sequence number of at least one pre-fetched page from at least one window sequence of the first sequence comprises: Determine L third sequences from the at least one window sequence according to the characteristic information of each window sequence, the L third sequences being L window sequences whose first K page numbers in the at least one window sequence have the highest similarity with the second sequence, where L is a positive integer; The page sequence number of the at least one pre-fetched page is determined according to the last H page sequence numbers in the L third sequences, where H is the value of M minus K.
3. The method according to claim 2, characterized in that The determining the page sequence number of the at least one pre-fetched page according to the last H page sequence numbers in the L third sequences includes: Determine the last H page sequence numbers in the fourth sequence as the page sequence number of the at least one pre-fetched page, the fourth sequence being a sequence in which the first K page sequence numbers of the L third sequences have the highest similarity with the second sequence.
4. The method according to claim 2 or 3, characterized in that: The determining the page sequence number of the at least one pre-fetched page according to the last MK page sequence numbers in the L third sequences comprises: The last H page sequence numbers in the fifth sequence are determined as the page sequence numbers of the at least one pre-fetched page, and the fifth sequence is a sequence in which the page corresponding to the last page sequence number in the L third sequences is read the latest.
5. The method according to claim 2, characterized in that: In the case where L is a positive integer greater than 1, determining the page number of the at least one pre-fetched page according to the last H page numbers in the L third sequences includes: The page sequence number of the at least one pre-fetched page is determined from the last H page sequence numbers of the L third sequences, wherein the last H page sequence numbers of each third sequence in the L third sequences include the page sequence number of the at least one pre-fetched page.
6. The method according to any one of claims 2 to 5, characterized in that The method further comprises: When the amount of stored feature information is greater than the first threshold, the feature information of the sixth sequence is deleted, wherein the sixth sequence is a window sequence in which a page corresponding to the first page sequence number in the at least one window sequence is read earliest.
7. The method according to any one of claims 2 to 6, characterized in that The method further comprises: Acquire feedback information, where the feedback information is used to indicate a ratio of the at least one prefetched page being read; When the ratio is less than a second threshold, the feature information of the L third sequences is deleted.
8. The method according to any one of claims 1 to 7, characterized in that The values of at least two adjacent page numbers among the M page numbers in each window sequence are discontinuous.
9. A device for recommending pre-fetched pages, characterized in that: The device is arranged in a database, the database includes a buffer pool, the buffer pool is used to cache pages in the database, and the device includes: A query module, used to accept a user's query request and read pages in the database according to the query request; A collection module, used to obtain a first sequence, wherein the first sequence includes N page numbers, the N page numbers correspond one-to-one to the N pages read from the database, the N page numbers are arranged in a time sequence when the N pages are read, and N is a positive integer greater than 1; A learning module, configured to extract feature information of at least one window sequence of the first sequence according to an extraction window, each window sequence including M page numbers, where M is a size of the extraction window and M is a positive integer greater than 1 and less than or equal to N; The acquisition module is further used to obtain a second sequence, wherein the second sequence includes K page numbers, the K page numbers correspond one-to-one to the K pages read latest in the database, the K page numbers are arranged in the order of the time when the K pages are read, and K is a positive integer less than M; The learning module is further used to determine a page sequence number of at least one pre-fetched page from at least one window sequence of the first sequence according to the feature information of the at least one window sequence and the second sequence; The cache module is used to cache the at least one pre-fetched page according to the page sequence number of the at least one pre-fetched page.
10. The device according to claim 9, characterized in that The characteristic information of the window sequence is used to indicate the arrangement order of the M page numbers in the window sequence. The learning module is used to: Determine L third sequences from the at least one window sequence according to the characteristic information of each window sequence, the L third sequences being L window sequences whose first K page numbers in the at least one window sequence have the highest similarity with the second sequence, where L is a positive integer; The page sequence number of the at least one pre-fetched page is determined according to the last H page sequence numbers in the L third sequences, where H is the value of M minus K.
11. The device according to claim 10, characterized in that The learning module is used to: Determine the last H page sequence numbers in the fourth sequence as the page sequence number of the at least one pre-fetched page, the fourth sequence being a sequence in which the first K page sequence numbers of the L third sequences have the highest similarity with the second sequence.
12. The device according to claim 10 or 11, characterized in that The learning module is used to: The last H page sequence numbers in the fifth sequence are determined as the page sequence numbers of the at least one pre-fetched page, and the fifth sequence is a sequence in which the page corresponding to the last page sequence number in the L third sequences is read the latest.
13. The device according to claim 10, characterized in that When L is a positive integer greater than 1, the learning module is used to: The page sequence number of the at least one pre-fetched page is determined from the last H page sequence numbers of the L third sequences, wherein the last H page sequence numbers of each third sequence in the L third sequences include the page sequence number of the at least one pre-fetched page.
14. The device according to any one of claims 10 to 13, characterized in that The learning module is also used to: When the amount of stored feature information is greater than the first threshold, the feature information of the sixth sequence is deleted, wherein the sixth sequence is a window sequence in which a page corresponding to the first page sequence number in the at least one window sequence is read earliest.
15. The device according to any one of claims 10 to 14, characterized in that The learning module is also used to: Acquire feedback information, where the feedback information is used to indicate a ratio of the at least one prefetched page being read; When the ratio is less than a second threshold, the feature information of the L third sequences is deleted.
16. The device according to any one of claims 9 to 15, characterized in that The values of at least two adjacent page numbers among the M page numbers in each window sequence are discontinuous.
17. A computing device, characterized in that The computer comprises a processor and a memory, wherein the processor is configured to execute instructions stored in the memory so that the computing device executes the method according to any one of claims 1 to 8.
18. A computing device cluster, characterized in that: comprising at least one computing device, each computing device comprising a processor and a memory; The processor of the at least one computing device is configured to execute instructions stored in the memory of the at least one computing device, so that the computing device cluster executes the method according to any one of claims 1 to 8.
19. A computer-readable storage medium, characterized in that: The method comprises computer program instructions, which, when executed by a computing device cluster, cause the computing device cluster to perform the method according to any one of claims 1 to 8.