Intelligent prefetching method and system for mixed workload databases
By constructing a query intent graph and a locality-sensitive hashing algorithm, combined with a probability-cost model and a differentiated prefetching strategy, the problem that database caching mechanisms cannot predict future cross-modal data access is solved. This achieves efficient integration of cross-modal prefetching and a vectorized execution engine, improving query performance and cache hit rate.
Patent Information
- Application Number
- CN202611694749.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-30
- Publication Date
- 2026-11-27
AI Technical Summary
Existing database caching mechanisms cannot predict future cross-modal data access, leading to IO bottlenecks. Furthermore, their prefetching strategies are too simplistic to meet the batch processing needs of vectorized execution engines, and their lack of understanding of query semantics results in low prefetching accuracy.
By constructing a query intent graph, using locality-sensitive hashing (LSH) for hash encoding, and combining a probability-cost model and a differentiated prefetching strategy, cross-modal prefetching is achieved. This supports unified prefetching of row storage, column storage, and vector indexes, and integrates with the vectorized execution engine through zero-copy pointer passing.
It improved cache hit rate, reduced CPU overhead, enhanced query performance, and adapted to load changes by self-optimizing, thus meeting the batch processing requirements of the vectorized execution engine.
Smart Images

Figure CN123178034A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of database technology, and in particular relates to an intelligent prefetching method and system for hybrid workload databases. Background Technology
[0002] With the advent of the big data era, database systems need to handle both transactional OLTP and analytical OLAP workloads simultaneously, i.e., HTAP hybrid workloads. In OLAP scenarios, complex queries, such as multi-table join queries in the TPC-H benchmark, typically involve scanning, joining, and aggregation operations on large amounts of data, making IO bottlenecks a key factor restricting query performance.
[0003] Existing database caching mechanisms primarily rely on passive caching based on historical access frequency, such as the commonly used LRU (Least Recently Used) and LFU (Least Frequently Used) algorithms. These mechanisms determine cache retention strategies solely based on whether a data page has been accessed and the frequency of access, essentially acting as a reactive mechanism that cannot predict future data access needs. When a query is accessed for the first time or when the access pattern changes, the cache hit rate drops sharply, leading to significant I / O wait times.
[0004] Some commercial database systems, such as Oracle Exadata's Storage Index and SQL Server's Read-Ahead mechanism, implement prefetching functionality based on sequential scans. However, their prefetching strategies are singular, primarily targeting sequential page access in row-store mode, lacking unified support for newer storage modes such as column-store and vector indexes. In hybrid workload databases, a single query may involve access to row-store tables, column-store tables, and vector indexes simultaneously. Existing technologies cannot predict and prefetch data across modalities based on query intent.
[0005] In recent years, vectorized execution engines have become a mainstream technology for improving OLAP performance. Database systems such as GBase 8c, PostgreSQL, and Apache Doris all adopt vectorized execution technology. Vectorized execution engines process data in batches, with each batch typically containing 1,000 to 10,000 rows of data, making full use of SIMD instructions to accelerate computation. However, existing prefetching technology is severely out of sync with vectorized execution engines: prefetching typically loads data in single-page or small-page units, while vectorized execution requires large batches of data; after prefetched data reaches the cache, it needs to undergo additional memory copying before entering the batch processing pipeline of the vectorized execution engine, causing unnecessary overhead.
[0006] Furthermore, existing prefetching techniques lack an understanding of query semantics. Even when accessing the same table, different SQL queries may exhibit completely different data access patterns. For example, a query filtering an order table by date range tends to sequentially scan recent data blocks, while a query filtering an order table by customer number randomly accesses data blocks related to specific customers. Existing techniques cannot distinguish these differences in query intent, resulting in low prefetching accuracy.
[0007] Therefore, there is an urgent need for an intelligent prefetching technology that can understand query intent, support cross-modal storage, and be deeply integrated with vectorized execution engines to solve the IO bottleneck problem in hybrid workload databases. Summary of the Invention
[0008] In view of this, the present invention aims to propose an intelligent prefetching method and system for hybrid workload databases to solve the IO bottleneck problems caused by the inability of existing database caching mechanisms to predict future cross-modal data access and the disconnect between prefetching strategies and vectorized execution engines. Specifically, the technical problems to be solved by the present invention include: First, the existing passive caching mechanism based on access frequency cannot predict future data access needs of queries, resulting in a sharp drop in hit rate during the first access or when the mode changes; Second, the existing prefetching strategy is singular, only oriented towards row-oriented sequential access, lacking unified support for storage modes such as column storage and vector indexes, and lacking cross-modal prediction capabilities; Third, the existing prefetching and vectorized execution engines are disconnected in terms of granularity and data provisioning methods, with single-page prefetching failing to meet batch processing requirements and incurring additional memory copying issues; Fourth, the existing prefetching lacks understanding of query semantics and cannot distinguish the differences in data access patterns of the same table for different query intentions, resulting in low prefetching accuracy.
[0009] To achieve the above objectives, the technical solution of the present invention is implemented as follows: This invention provides an intelligent prefetching method for hybrid workload databases, comprising the following steps: S1. Query Intent Extraction Steps: Receive the SQL query statement, perform syntax tree parsing, and extract the query feature vector. ,in To query the set of tables involved, To query the set of columns involved, This is a feature of predicate selectivity. For table join type characteristics, Features for sorting keys; S2. Query Intent Graph Construction Steps: Using the feature vector of each query in the historical query sequence as a node, construct directed edges according to the time order of query execution, and use the weighted value of the similarity and transition frequency of adjacent queries as the edge weights to construct the query intent graph. ,in , , These are the node set, the edge set, and the edge weight set, respectively. S3. Similarity Query Matching Steps: Hash the feature vectors of nodes in the query intent graph using the Locality Sensitive Hash (LSH) algorithm to construct an LSH index; quickly match the current query's feature vector using the LSH index to retrieve a preset number of similar queries. A number of similar historical query patterns; S4. Prefetch Object Prediction Steps: Analysis Given a set of data objects accessed in subsequent queries based on similar historical query patterns, calculate the access probability of each data object. The data objects include row-stored data blocks, column-stored data blocks, and vector index pages; S5. Prefetch priority sorting step: Estimate the I / O load cost of each data object. Prefetch priority score is calculated based on the ratio of access probability to IO loading cost. Generate a prefetch task queue in descending order of prefetch priority score; S6. Cross-modal prefetching execution steps: Based on the storage modality type of the data objects in the prefetching task queue, the corresponding prefetching executor is called to asynchronously load the data objects from the persistent storage layer to the multi-level cache layer; the storage modality types include row storage modality, column storage modality and vector index modality, each modality corresponds to a different prefetching strategy, and multiple prefetching executors work in parallel; S7. Vectorized pipeline injection step: The batch data prefetched from the multi-level cache layer is injected into the input of the scan operator of the vectorized execution engine through zero-copy pointer passing.
[0010] Furthermore, the predicate selectivity feature in step S1 The calculation method includes: extracting the predicate conditions of the WHERE clause in the SQL query statement, calculating the selectivity of each predicate condition, and using the selectivity vector and the predicate logical relation encoding as the predicate selectivity features. Predicate logical relation encoding includes bitmap encoding of AND, OR, and NOT relations; In step S2, query the intent graph. The construction method also includes: dividing the historical query sequence into sliding window segments, with a window size of [missing information]. The step size is 1. The number of queries contained in each sliding window, and the query sequence within each window, are constructed into a local subgraph; local subgraphs are connected through shared nodes to form a global query intent graph; the global query intent graph is periodically pruned, removing edges with weights below a threshold. Edges and isolated nodes.
[0011] Furthermore, the hash function of the locality-sensitive hashing algorithm in step S3 is: ,in For random projection vectors, For random offsets, For the barrel width parameter, To query the feature vector of the i-th node in the intent graph G, for The result of rounding down; using multiple hash table strategies to construct... Each hash table uses a separate hash table, and each hash table uses... Several hash functions; fast matching includes: mapping the current query feature vector to the corresponding buckets in each hash table, taking the union of candidate nodes in each bucket as the candidate set, and then performing precise similarity calculation in the candidate set to filter out... A number of similar historical query patterns; precise similarity calculation uses cosine similarity or Jaccard similarity.
[0012] Furthermore, the access probability in step S4 The calculation formula is: ; in For the first The similarity weight of each similar historical query. For indicator functions, For the current query, Indicates the first The summation is performed on the set of data objects accessed by subsequent queries of similar historical queries. From 1 to conduct; IO loading cost in step S5 The calculation formula is: ; in For the size of the data object, For storage device bandwidth, This is an estimate of the head seek time. This is an estimate of the data decompression time.
[0013] Furthermore, the differentiated prefetch strategies in step S6 include: For row storage mode, an asynchronous sequential prefetch strategy is adopted, continuously reading data pages into the Buffer Pool according to page number, with the prefetch depth dynamically adjusted according to the current query's scan range; the depth is 64 pages for a full table scan and 16 pages for a range scan; For column storage mode, a batch column vector prefetch strategy is adopted, reading consecutive compressed data blocks of the target column into the column storage cache at once, decompressing and organizing them according to vector batch alignment, and supporting multi-column parallel prefetching; For vector index mode, a neighborhood prefetch strategy is adopted, preloading data blocks whose distance from the currently accessed node is less than a threshold. For the neighborhood vector page, the HNSW index prefetches the neighborhood nodes of the current layer and the next layer; for the IVF index, it prefetches the nearest neighbor node to the current query vector. The inverted list page corresponding to each cluster center.
[0014] Furthermore, the zero-copy pointer passing method in step S7 includes: pre-allocating memory pages aligned with the batch size of the vectorized execution engine in the multi-level cache layer, with the memory pages allocated using posix_memalign for 64-byte alignment; after the prefetch executor loads data into the memory pages, directly registering the physical address pointer of the memory pages into the input descriptor of the vectorized execution engine scan operator; the prefetched batch data is buffered by a prefetch circular buffer aligned with the batch size and then supplied to the scan operator via pointer passing; after the scan operator completes batch processing, the memory pages are released through a reference counting mechanism.
[0015] Furthermore, the intelligent prefetching method for hybrid workload databases also includes step S8, the execution feedback and adaptive adjustment step: collecting execution feedback information from the vectorized execution engine, including prefetch hit rate, query latency, and throughput; dynamically adjusting the depth, width, and prefetch trigger threshold of the prefetch task queue based on the execution feedback information; and incrementally updating the query intent graph online according to the execution results of the current query; wherein, dynamically adjusting the depth of the prefetch task queue includes: reducing the prefetch depth when the prefetch hit rate is lower than the first threshold and the query latency is higher than the second threshold; increasing the prefetch depth when the prefetch hit rate is higher than the third threshold and the storage IO utilization is lower than the fourth threshold; the adjustment step size of the prefetch depth is... The adjustment cycle is Individual query batches; online incremental updates to the query intent graph include: adding the current query as a new node to the graph, establishing connections with the most recent queries. Connect the edges of each historical query, update the edge weights, and trigger pruning if the graph size exceeds the upper limit.
[0016] Based on the same concept, the present invention also provides an intelligent prefetching system for hybrid workload databases, comprising: The query intent extraction module receives SQL query statements, performs syntax tree parsing, and extracts query feature vectors. ; The query intent graph storage module is used to store query intent graphs constructed based on historical query sequences. It also provides an index retrieval interface based on the locality-sensitive hashing algorithm; The similarity query matching module is used to quickly match the feature vector of the current query using the LSH index and retrieve a preset number of results. A number of similar historical query patterns; The prefetch decision engine module is used to analyze subsequent access objects with similar historical query patterns, calculate access probability and IO loading cost, and generate a prefetch task queue sorted by prefetch priority score. The cross-modal prefetch executor module includes a row-store prefetch executor, a column-store prefetch executor, and a vector index prefetch executor. It is used to call the corresponding prefetch executor according to the storage modality type of the data object, and asynchronously load the data from the persistent storage layer to the multi-level cache layer. The multi-level cache layer includes a Buffer Pool cache area for row storage modality, a column-store cache area for column storage modality, and a vector page cache area for vector index modality. The vectorized execution engine module is used to receive prefetched batch data from multi-level cache layers in a zero-copy manner and execute the batch processing pipeline. The execution feedback acquisition module is used to collect execution feedback information from the vectorized execution engine and transmit it to the adaptive adjustment module. The adaptive adjustment module is used to dynamically adjust the prefetch strategy parameters based on execution feedback information and to incrementally update the query intent graph online.
[0017] Based on the same concept, the present invention also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements an intelligent prefetching method for a mixed-load database.
[0018] Based on the same concept, the present invention also provides an electronic device, including a processor and a memory, wherein a computer program is stored in the memory, and when the processor executes the computer program, it implements an intelligent prefetching method for a mixed-load database.
[0019] Compared with existing technologies, the intelligent prefetching method and system for hybrid workload databases of the present invention have the following advantages: Firstly, this invention transforms query semantics into computable graph structure knowledge through multidimensional query feature vectors and query intent graphs, capturing the temporal correlation and semantic similarity of historical queries, thus transforming prefetching from a passive post-event response to an active pre-event prediction, alleviating the problem of a sharp drop in cache hit rate when a query is first accessed or when the access pattern changes.
[0020] Secondly, this invention utilizes the Locality Sensitive Hash (LSH) algorithm to hash the feature vectors of query intent graph nodes. Through a two-stage retrieval process involving candidate set union and precise similarity calculation, the time complexity of similar query retrieval is reduced from... Reduce to This meets the real-time requirements of database query processing.
[0021] Third, this invention uses a probability-cost model to uniformly characterize the prefetching value of three types of data objects: row-based storage, column-based storage, and vector indexing. It calculates a prefetching priority score based on the ratio of access probability to I / O loading cost. Given limited IO bandwidth and cache capacity, it prioritizes the prefetching of data objects with the highest unit cost benefit, and achieves unified intelligent prefetching across different storage modes by matching the physical characteristics of each storage mode with differentiated prefetching strategies.
[0022] Fourth, this invention eliminates the memory copy overhead of prefetched data entering the batch processing pipeline by aligning the prefetch circular buffer with the batch granularity of the vectorized execution engine, registering zero-copy pointers, and releasing reference counts. This enables prefetching and execution to run in parallel at the pipeline level, reducing CPU overhead by approximately 15% in the TPC-H SF100 dataset test.
[0023] Fifth, this invention forms a closed loop through execution feedback and adaptive adjustment, dynamically adjusts the prefetch depth, width and trigger threshold, and incrementally updates the query intent graph online, so that the system can continuously self-optimize as the workload changes, avoid cache pollution and improve the prefetch hit rate. Attached Figure Description
[0024] The accompanying drawings, which form part of this invention, are used to provide a further understanding of the invention. The illustrative embodiments of the invention and their descriptions are used to explain the invention and do not constitute an undue limitation of the invention. In the drawings: Figure 1 This is a diagram of the overall system architecture of the present invention; Figure 2 This is a flowchart illustrating the query intent graph construction and LSH matching process of this invention. Figure 3 This is a flowchart illustrating the cross-modal prefetching decision and execution process of the present invention; Figure 4 This is a schematic diagram of the vectorized execution engine integration of the present invention. Detailed Implementation
[0025] It should be noted that, unless otherwise specified, the embodiments and features described in the present invention can be combined with each other.
[0026] In the description of this invention, it should be understood that the terms "center," "longitudinal," "lateral," "upper," "lower," "front," "rear," "left," "right," "vertical," "horizontal," "top," "bottom," "inner," and "outer," etc., indicating orientations or positional relationships based on the orientations or positional relationships shown in the accompanying drawings, are only for the convenience of describing the invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of the invention. Furthermore, the terms "first," "second," etc., are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, a feature defined with "first," "second," etc., may explicitly or implicitly include one or more of that feature. In the description of this invention, unless otherwise stated, "a plurality of" means two or more.
[0027] In the description of this invention, it should be noted that, unless otherwise explicitly specified and limited, the terms "installation," "connection," and "linking" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art will understand the specific meaning of the above terms in this invention based on the specific circumstances.
[0028] The present invention will now be described in detail with reference to the accompanying drawings and embodiments.
[0029] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be clearly and completely described below with reference to the accompanying drawings and embodiments. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention. Where there is no conflict, the embodiments and features in the embodiments of this invention can be combined with each other, and the technical features of each embodiment can be combined with the technical features of any other embodiment.
[0030] The execution order of each step in the embodiments of the present invention is not limited by the step number, except that there is a necessary functional dependency. For example, the query intent graph construction and pruning in step S2 can be executed offline or asynchronously in the background. The cross-modal prefetching execution in step S6 and the vectorized pipeline injection in step S7 overlap and run in parallel with the execution of the current query in time. The collection and adjustment in step S8 are background processes that are executed together.
[0031] The product names such as GBase 8c, PostgreSQL, openGauss, Oracle Exadata, and SQL Server, as well as benchmark tests such as TPC-H and TPC-C mentioned in the embodiments of this invention, are merely examples describing the operating environment or test benchmarks and do not constitute a limitation of this invention.
[0032] This invention operates on a hybrid HTAP database system that simultaneously carries transactional OLTP and analytical OLAP workloads. The database system employs three storage modes: row storage, column storage, and vector indexing. It is configured with a vectorized execution engine that processes data in batches and accelerates computation using SIMD instructions. SIMD instructions include, for example, AVX2, AVX-512, or ARM NEON.
[0033] The main symbols used in the embodiments of this invention and their meanings are as follows: To query feature vectors; For the set of tables involved in the query; For the set of columns involved in the query; This is a feature of predicate selectivity; This is a characteristic of table join types; Features for sorting keys; For query intent graph; A set of nodes; Let it be the set of edges; This is the set of edge weights; To adjust the sliding window size; This is the pruning threshold; Set a similarity threshold for filtering; The number of hash tables; The number of hash functions used for each hash table; The number of similar historical queries, i.e., K in Top-K; This refers to the barrel width parameter; It is a random projection vector; This is a random offset; The dimension of the feature vector; Let be the similarity weight of the i-th similar historical query; For indicator functions; The set of data objects accessed by subsequent queries of the i-th similar historical query; For data objects; For the current query; Size of the data object; For storage device bandwidth; This is an estimate of the head seek time; This is an estimate of the data decompression time. To prefetch priority scores; The neighborhood distance threshold; This represents the number of IVF cluster centers; Adjust the step size to prefetch depth; To adjust the cycle; The number of recent visits considered for the LRU-K strategy; The size parameter for the HNSW candidate set; This represents the number of neighboring connections of the currently accessing node.
[0034] Example 1 This embodiment provides an intelligent prefetching method for hybrid workload databases. Please refer to [link / reference]. Figure 2 and Figure 3 The method includes steps S1 to S7.
[0035] Step S1, Query Intent Extraction Step: Receive the SQL query statement, perform syntax tree parsing, and extract the query feature vector. (1); The meanings of each symbol in equation (1) are as described above; syntax tree parsing can be implemented based on the parser of PostgreSQL or openGauss.
[0036] Step S2, Query Intent Graph Construction Steps: Using the feature vector of each query in the historical query sequence as a node, construct directed edges according to the time order of query execution, and use the weighted value of the similarity and transition frequency of adjacent queries as the edge weights to construct the query intent graph. (2); The meanings of each symbol in Equation (2) are as explained above; this graph structure can capture the temporal correlation and semantic similarity between queries, providing a knowledge base for subsequent prefetching prediction.
[0037] Step S3, Similarity Query Matching Step: The feature vectors of nodes in the query intent graph are hashed using the Locality Sensitive Hash (LSH) algorithm to construct an LSH index; the feature vector of the current query is then quickly matched using the LSH index to retrieve Top-... Similar historical query patterns; the LSH index uses the LSH algorithm's hash function, which is: (3); In equation (3), To query the feature vector of the i-th node in the intent graph G The hash value is given, and the meanings of the other symbols are as described in the symbol explanation above. Indicates rounding down, optional And it follows a standard normal distribution. And it follows a uniform distribution.
[0038] Step S4, Prefetch Object Prediction Step: Analyze Top- Given a set of data objects accessed in subsequent queries based on similar historical query patterns, calculate the access probability of each data object. (4); The meanings of the symbols in equation (4) are as explained in the symbol description above. Optional Softmax normalization; data objects include three categories: row-stored data blocks (Pages), column-stored data blocks (Column Families), and vector index pages. For the current query, Indicates the first The summation is performed on the set of data objects accessed by subsequent queries of similar historical queries. From 1 to conduct.
[0039] Step S5, Prefetch Priority Sort Step: Estimate the IO load cost of each data object. (5); The meanings of the symbols in equation (5) are as explained above; the prefetch priority score is calculated based on the ratio of access probability to IO loading cost. (6); according to Generate a prefetch task queue in descending order, denoted as .
[0040] Step S6, cross-modal prefetching execution step: Based on the storage modality type of the data object in the prefetching task queue, modality determination is performed, and the corresponding prefetching executor is called to asynchronously load the data object from the persistent storage layer to the multi-level cache layer; the storage modality types include row storage modality, column storage modality and vector index modality, each modality corresponds to a different prefetching strategy, and multiple prefetching executors work in parallel.
[0041] Step S7, Vectorized Pipeline Injection Step: The batch data prefetched in the multi-level cache layer is directly injected into the input of the Scan Operator of the vectorized execution engine through the zero-copy pointer passing method, so that the batch data serves as the input batch of the vectorized execution engine's batch processing pipeline.
[0042] Furthermore, the method also includes step S8, the execution feedback and adaptive adjustment step: collecting execution feedback information from the vectorized execution engine, including the prefetched data hit ratio, query latency, and throughput; dynamically adjusting the depth, width, and prefetch trigger threshold of the prefetch task queue based on the execution feedback information; and incrementally updating the query intent graph online according to the execution result of the current query. Here, depth refers to the number of data pages or data blocks prefetched in a single prefetch task; width refers to the number of data objects scheduled in parallel within the prefetch task queue per unit period, exemplified by the upper limit of the number of columns or neighboring batches prefetched simultaneously; and the prefetch trigger threshold refers to the threshold for initiating the prefetch process, exemplified by the similarity threshold or access probability between the current query and historical queries. A start threshold is set, and data objects are only added to the prefetch task queue when the predicted return is higher than the threshold, in order to avoid low-return prefetching occupying IO bandwidth.
[0043] like Figure 2 As shown, the above steps constitute three interconnected processes: the first is the current query processing flow, which is the SQL query input being parsed by the syntax tree to generate a feature vector. To obtain the current query feature vector Secondly, LSH matching and prefetching stream, i.e. Top-ranked queries were obtained from the historical query intent map through LSH fast matching and accurate similarity calculation. The query is completed through a process involving similar query patterns, prefetching decision-making and execution, and a vectorized execution engine. The third part involves a closed loop for updating historical queries, where the execution results, carrying query characteristics and accessed data objects, are fed back to add the current query to the historical query sequence. For query intent graph Perform incremental updates and synchronously update the LSH index. The updated historical query intent graph is used for the next query matching.
[0044] The technical features of this embodiment can be combined with the technical features of any of the other embodiments.
[0045] Example 2 This embodiment, based on Embodiment 1, further explains the optional implementation methods of each step.
[0046] Regarding step S1, The database table OID is encoded using an ordered set, that is, the tables in the set are sorted in ascending order by the object identifier; Column ID bitmap encoding is used, with the bits in the bitmap indicating whether the corresponding column is involved in the query; Encode the selectivity and logical relationships of each predicate in the WHERE clause; Encoding the join algorithm and join key; the join algorithm includes NestLoop, HashJoin, and MergeJoin. This encodes the columns involved in the ORDER BY clause and the sorting direction. As... One specific calculation method: Extract the predicate conditions of the WHERE clause, calculate the selectivity of each predicate condition, and use the selectivity vector and the predicate logical relation encoding as... The predicate logical relation encoding adopts a bitmap method. For example, the AND relation is encoded as 10 (binary encoding), the OR relation is encoded as 01, the NOT relation is encoded as 11, and the no-connection relation is encoded as 00. This encoding method can distinguish between logically completely different query intentions such as WHERE a=1 AND b=2 and WHERE a=1 OR b=2.
[0047] Regarding step S2, the historical query sequence is further divided into sliding window segments, with a window size of [missing value]. With a step size of 1, the query sequence within each window is constructed as a local subgraph; local subgraphs are connected through shared nodes, i.e., queries in overlapping window regions, to form a global query intent graph; the global query intent graph is periodically pruned, removing edges with weights below a threshold. Edges and isolated nodes are used to control the size of the graph and preserve high-confidence query transition patterns. For example, , The periodic interval is every 1000 new queries or every hour. The above values are for illustrative purposes only and do not constitute a limitation. An example of edge weight is the product of the cosine similarity of the feature vectors of two nodes and the transition frequency. For example, when the cosine similarity is about 0.85 and the transition frequency is 0.3, the edge weight is about 0.255.
[0048] Regarding step S3, a multiple hash table strategy is employed to construct... Each hash table uses a separate hash table, and each hash table uses... A hash function, exemplarily , In other embodiments Options range from 5 to 20. Options 2 to 8; the fast matching process includes: mapping the current query feature vector to the corresponding buckets in each hash table, taking the union of candidate nodes in each bucket as the candidate set, and then performing precise similarity calculation in the candidate set to filter out Top- The most similar historical query pattern is denoted as _____. Similarity Greater than the threshold Historical search The set, and take the one with the highest similarity. One, exemplarily or Precise similarity calculation can use cosine similarity or Jaccard similarity. This two-stage retrieval strategy, while ensuring recall, reduces the time complexity of similar query retrieval from... Reduce to ,in To query the total number of nodes in the intent graph, This represents the number of nodes in the candidate set.
[0049] Regarding step S4, For the first The set of data objects accessed by subsequent queries of similar historical queries can optionally be the set of data objects accessed by the next query that is immediately adjacent in time. This formula uses a weighted voting mechanism to combine the subsequent behaviors of multiple similar historical queries to predict the data objects that the current query may access.
[0050] Regarding step S5, for data objects in column-stored mode... This refers to the size of the compressed column data; for data objects in the vector index modality, This includes the random I / O overhead of neighborhood traversal. For example, SSDs... Approximately 500MB / s for HDD and approximately 150MB / s for SSD. Approximately 0.1ms for LZ4 compression and approximately 10ms for HDD compression. Approximately 0.5 μs / KB; compression algorithms such as ZSTD or Snappy can also be used. The above values are for illustrative purposes only and do not constitute a limitation.
[0051] Regarding step S6, the differentiated prefetch strategy specifically includes: For row storage mode, the row storage prefetch executor adopts an asynchronous sequential prefetch strategy, submitting asynchronous IO requests to the operating system, such as Linux's io_submit or io_uring system calls, and continuously reading data pages into the Buffer Pool according to page numbers. The prefetch depth is dynamically adjusted according to the current query's scan range, with a depth of 64 pages for a full table scan and 16 pages for a range scan. In other embodiments, the depth can be selected as 16 pages, 32 pages, 64 pages, 80 pages, or 128 pages. For column storage mode, the column storage prefetch executor adopts a batch column vector prefetch strategy, reading consecutive compressed data blocks of the target column into the column storage cache at once. The cache, after decompression, is organized in vector batches, for example, 1000 tuples per batch, and supports multi-column parallel prefetching. It leverages the data locality of column storage to load contiguous blocks of data in the same column in batches. For vector index mode, the vector index prefetch executor adopts a neighborhood prefetch strategy, based on the access locality of approximate nearest neighbor search, preloading data that is less than a threshold distance from the currently accessed node. The neighborhood vector page, exemplarily or For HNSW indexes, the hierarchical navigable small-world graph feature is used to prefetch neighboring nodes of the current and next layers; for IVF indexes, the nearest neighbor to the current query vector is prefetched. The inverted list page corresponding to each cluster center.
[0052] Regarding step S7, the prefetch buffer is aligned with the batch size of the vectorized execution engine, such as 1000, 8192, or 10000 rows per batch. After the prefetched data arrives, the physical address pointer of the memory page is directly registered to the input descriptor of the scan operator, without requiring additional memory copying. After the scan operator completes processing, the memory page is safely released using a reference counting mechanism. Specifically, this includes: pre-allocating memory pages aligned with the batch size of the vectorized execution engine in a multi-level cache layer, using posix_memalign for 64-byte alignment; after the prefetch executor loads data into the memory page, it directly registers the physical address pointer of the memory page to the input descriptor of the scan operator, allowing the scan operator to directly access the data without copying it to the execution engine's private memory space; after the scan operator completes batch processing, it checks whether the memory page is referenced by other operators using a reference counting mechanism, releasing the memory page back to the cache pool if the reference count is zero; the input descriptor includes a base address pointer, batch capacity, number of valid rows, and a reference count field. This mechanism eliminates the memory copy overhead between prefetched data and the execution engine, reducing CPU overhead by approximately 15% in TPC-H SF100 dataset tests.
[0053] Regarding step S8, dynamically adjusting the depth of the prefetch task queue includes: reducing the prefetch depth to avoid cache pollution when the prefetch hit rate is lower than a first threshold and the query latency is higher than a second threshold; increasing the prefetch depth to improve pipeline parallelism when the prefetch hit rate is higher than a third threshold and the storage IO utilization is lower than a fourth threshold. If both the increase and decrease conditions are met simultaneously, the decrease operation is performed first. For example, the first threshold is 60%, the second threshold is 120% of the baseline latency, the third threshold is 80%, the fourth threshold is 50%, and the adjustment step size of the prefetch depth is... Page, Adjustment Cycle The above values are for example only and do not constitute a limitation. Online incremental updates to the query intent graph include: adding the current query as a new node to the graph, and establishing connections with the most recent queries. Connect the edges of each historical query, update the edge weights, and trigger pruning if the graph size exceeds the upper limit.
[0054] The technical features of this embodiment can be combined with the technical features of any of the other embodiments.
[0055] Example 3 This embodiment provides an intelligent prefetching system for hybrid workload databases. Please refer to [link / reference]. Figure 1 The system includes a query intent extraction module, a query intent graph storage module, a similar query matching module, a prefetch decision engine module, a cross-modal prefetch executor module, a vectorized execution engine module, an execution feedback acquisition module, and an adaptive adjustment module. These modules work together to form a closed-loop system of perception, decision-making, execution, and feedback. Each module can be implemented in hardware, software, firmware, or any combination thereof; each module can be deployed integratedly or separately, and coupled via bus, network, or inter-process communication; the prefetch executor can be implemented using threads, processes, or asynchronous task queues.
[0056] The query intent extraction module receives SQL query statements, performs syntax tree parsing, and extracts query feature vectors. The specific implementation refers to step S1 of Embodiment 1 or Embodiment 2.
[0057] The query intent graph storage module is used to store query intent graphs constructed based on historical query sequences. It provides an index retrieval interface based on the locality-sensitive hashing algorithm; optionally, this module is implemented using an in-memory graph database or an in-memory hash table; the LSH index adopts a multi-level hash table structure, with each level of the hash table corresponding to a different bucket width parameter. exemplarily Coarse-grained matching is used for rapid candidate set generation, while fine-grained matching is used for precise filtering. This module also supports periodic graph compression and snapshot persistence, such as using CSR format to compress sparse edges and writing to disk every 10 minutes to ensure rapid recovery after system restart.
[0058] The similarity query matching module is used to quickly match the feature vector of the current query using the LSH index and retrieve Top-... A similar historical query pattern.
[0059] The prefetch decision engine module analyzes subsequent access objects with similar historical query patterns, calculates access probability and IO loading cost, and generates scores based on prefetch priority. A sorted prefetch task queue.
[0060] The cross-modal prefetch executor module includes a row-store prefetch executor, a column-store prefetch executor, and a vector index prefetch executor. It is used to call the corresponding prefetch executor according to the storage modality type of the data object and asynchronously load the data into the multi-level cache layer. When a cache miss occurs in the multi-level cache layer, the corresponding executor initiates data loading to the persistent storage layer. The persistent storage layer includes row-store data files, column-store data files, and vector index files.
[0061] The vectorized execution engine module is used to receive prefetched batch data from a multi-level cache layer in a zero-copy manner and execute the batch processing pipeline.
[0062] The execution feedback acquisition module is used to collect execution feedback information from the vectorized execution engine and transmit it to the adaptive adjustment module.
[0063] The adaptive adjustment module is used to dynamically adjust the prefetch strategy parameters based on execution feedback information and to incrementally update the query intent graph online.
[0064] The multi-level cache layer includes: a Buffer Pool cache for row-oriented storage, a column-oriented cache for column-oriented storage, and a Vector Page Cache for vector indexing. Each cache level employs an independent replacement strategy, with the Buffer Pool cache using an improved LRU-K strategy that comprehensively considers the most recently used cache. For each access interval, the column-oriented cache uses the CF-LRU strategy (Column Frequency LRU) based on column access frequency, prioritizing the retention of frequently accessed columns. The vector page cache uses the NH-LRU strategy (Neighborhood Heat LRU) based on neighborhood heat, which increases the heat value of its neighboring vector pages when a vector page is accessed. The independent replacement strategy enables each cache layer to be optimized for the characteristics of the storage mode, avoiding cache contention between different modes.
[0065] like Figure 1 As shown, the system forms a forward prediction chain and a backward correction chain in the data flow direction, as well as a horizontal data injection path and a parameter distribution path connecting the two. Figure 1 The meanings of the arrows in the image are as follows: (1) Forward prediction chain: The query intent extraction module will extract the current query feature vector The results are output to the similar query matching module and the query intent graph storage module for adding nodes and online incremental updates. The query intent graph storage module provides candidate nodes to the similar query matching module through an index retrieval interface based on the locality-sensitive hashing algorithm. The similar query matching module outputs the retrieved K similar historical query patterns to the prefetch decision engine module. The prefetch decision engine module then assigns the results to the prefetch priority score. The prefetch task queue, arranged in descending order, is sent to the cross-modal prefetch executor module. The cross-modal prefetch executor module initiates asynchronous I / O requests to the persistent storage layer, reads the row storage data file, column storage data file, and vector index file, and writes the loaded data objects into the corresponding BufferPool cache area, column storage cache area, or vector page cache area in the multi-level cache layer.
[0066] (2) Horizontal data injection path: Batch data in the multi-level cache layer is injected through the zero-copy injection layer and supplied to the scanning operator input of the vectorized execution engine module in a pointer-passing manner, so that the prefetch path and the execution path are asynchronous and parallel.
[0067] (3) Reverse correction chain: The vectorized execution engine module outputs execution feedback information such as prefetch hit rate, query latency and throughput to the execution feedback acquisition module; the execution feedback acquisition module transmits the execution feedback information to the adaptive adjustment module.
[0068] (4) Parameter distribution path: On the one hand, the adaptive adjustment module injects the online incrementally updated query intent graph back into the query intent graph storage module and updates the LSH index synchronously; on the other hand, it distributes the adjusted depth, width and prefetching trigger threshold of the prefetching task queue to the prefetching decision engine module, and distributes the adjusted modality-differentiated prefetching strategy parameters (e.g., prefetching depth of row storage modality, prefetching compression unit range of column storage modality, neighborhood distance threshold of vector index modality) to the prefetching decision engine module. The adjusted cache capacity parameters (e.g., vector page cache capacity) are then distributed to the multi-level cache layer, forming a closed loop of perception, decision-making, execution, and feedback. As can be seen above, Figure 1 The arrow pointed to by the adaptive adjustment module does not point to the one-way back-injection query intent graph storage module, but simultaneously to the prefetch decision engine module, the cross-modal prefetch executor module, and the multi-level cache layer. Its function is to distribute the prefetch strategy parameters after execution feedback to the decision and execution stages. The arrow pointed to by the query intent extraction module leads one way to the similar query matching module for real-time matching of the current query, and the other way to the query intent graph storage module for updating historical query sequences and LSH indexes.
[0069] This embodiment also provides a computer-readable storage medium storing a computer program thereon. When the computer program is executed by a processor, it implements the method as described in Embodiment 1 or Embodiment 2. The computer-readable storage medium includes non-volatile memory such as NAND Flash, SSD, HDD, and volatile memory such as DRAM. This embodiment also provides an electronic device including a processor and a memory. The memory stores a computer program, and when the processor executes the computer program, it implements the method as described in Embodiment 1 or Embodiment 2. The processor is, for example, a CPU based on x86, ARM, or Kunpeng architecture.
[0070] The technical features of this embodiment can be combined with the technical features of any of the other embodiments.
[0071] Example 4 This embodiment combines Figure 4 This section details the deep integration mechanism between prefetched data and the vectorized execution engine. The vectorized execution engine internally includes Scan, Filter, Join, Aggregate, Sort, and Project operators. Data is transferred between these operators in batches, i.e., Batch1, Batch2, and Batch3, with each batch containing 1,000 to 10,000 rows of data.
[0072] The prefetched data stream enters the prefetch ring buffer asynchronously in batches. The prefetch ring buffer is aligned with the batch size of the vectorized execution engine, serving as a decoupling structure between producers and consumers, allowing I / O loading and SIMD computation to overlap in time, achieving pipeline-level parallelism. The prefetch ring buffer can be implemented using shared memory and a lock-free queue. Data in the prefetch ring buffer is supplied to the scan operator via a zero-copy injection layer using pointer passing, with no memory copying throughout the process. This injection point is... Figure 4 The prefetch data injection point is shown.
[0073] The zero-copy injection layer assembles the pointers of each column vector batch into a column batch descriptor. The column batch descriptor includes a base address pointer for each column, a batch capacity, and a valid tuple count field. Each vector batch contains a pointer to a contiguous memory region and a valid tuple count, and maintains a reference count to release the data after processing.
[0074] After the vectorized execution engine executes, the execution feedback acquisition module collects hit rate, latency, and throughput, and transmits them to the adaptive adjustment module. The adaptive adjustment module adjusts the prefetch depth and width and drives the query intent graph storage module to perform online incremental updates. The updated prefetch strategy is then applied to the prefetch data stream to form... Figure 4 The feedback loop shown.
[0075] The integration mechanism of this embodiment has three key technical points: First, prefetched data is directly injected into the vectorized scan operator through zero-copy pointers to avoid memory copying overhead; second, the prefetch circular buffer is aligned with the batch execution engine to achieve pipeline-level parallelism; and third, execution feedback adjusts the prefetch strategy in real time to form adaptive closed-loop optimization.
[0076] The technical features of this embodiment can be combined with the technical features of any of the other embodiments.
[0077] Example 5 This embodiment uses Query 5 (multi-table join query) in the TPC-H benchmark test as an example to illustrate the intelligent prefetching process in complex OLAP query scenarios, and specifically demonstrates... Figure 3 The cross-modal prefetching decision and execution flow is shown. This query is a multi-table join query on six tables: customer, orders, lineitem, supplier, nation, and region. The filtering conditions are that r_name is ASIA and o_orderdate is within 1994, grouped by n_name and sorted in descending order of revenue.
[0078] Step S1: The query intent extraction module traverses the syntax tree and extracts the query feature vector. ,in Sort by OID in ascending order; It uses 16-bit bitmap encoding; Where 0.2 is the selectivity of r_name taking the value ASIA, 0.142 is the selectivity of o_orderdate range, the first 10 indicates an AND connection relationship, and the second 10 indicates no NOT condition; ; .
[0079] Step S2: Assume there are a large number of similar TPC-H Q5 queries in the historical query sequence; the query intent graph storage module uses the feature vectors of these historical queries as nodes to construct a query intent graph. ;node This indicates a query for Q5-ASIA-1994, node This indicates a query Q5-EUROPE-1995, where a directed edge exists between the two. edge weight The cosine similarity of the feature vectors of the two nodes is approximately 0.85, multiplied by the transition frequency of 0.3, resulting in... .
[0080] Step S3: The LSH index module uses a random projection hash function. Encode the query intent graph nodes; current query feature vector Mapped to The hash tables are divided into corresponding buckets. Assuming 5 candidate nodes are found in bucket 7 of the 3rd hash table, and 3 candidate nodes are found in bucket 12 of the 7th hash table, the union of these 5 and 3 results in 6 unique candidate nodes. The exact cosine similarity is calculated on these 6 candidate nodes to select the Top-ranked nodes. The most similar historical queries are: Q5-ASIA-1993 (0.92 similarity), Q5-EUROPE-1994 (0.88 similarity), and Q5-ASIA-1995 (0.90 similarity).
[0081] Step S4: Corresponding Figure 3 This involves extracting subsequent access objects and calculating access probabilities. It also analyzes subsequent queries from these three similar historical queries. The accessed data objects; historical statistics show that after executing Q5, there is a 78% probability that Q7 will be executed, and a 62% probability that Q10 will be executed; calculate the access probability of each data object according to formula (4): ; ; ; All the values above are normalized results. This refers to the 1994 data block in the lineitem table. This refers to the 1994 data block in the orders table. This is the entire data block of the customer table.
[0082] Step S5: Corresponding Figure 3 The IO loading cost estimation and score sorting are performed. Assume the lineitem table has a 2.4GB data size in 1994 (after compression), the orders table has a 0.8GB data size in 1994 (after compression), and the customer table has a 0.3GB total size (after compression); the storage device is an SSD. , , According to LZ4, approximately 0.5 μs / KB; according to formula (5): ; ; ; The above cost unit is seconds; then calculate the pre-fetch priority score according to formula (6): ; ; ; Therefore, the prefetch task queue is ordered by priority as follows: customer table, orders table (1994 data), and lineitem table (1994 data). It can be seen that even though the lineitem table has the highest access probability, it is ranked last due to its highest loading cost, reflecting the decision-making principle of maximizing the cost-benefit per unit of IO.
[0083] Step S6: Corresponding Figure 3The prefetching process is modally determined and assigned to each executor. Assuming the `customer` and `orders` tables use a row-based storage modality, and the `lineitem` table uses a column-based storage modality, the cross-modality prefetching executor modules initiate prefetching tasks in parallel: the row-based prefetching executor initiates an asynchronous sequential prefetch of the `customer` table with a prefetch depth of 64 pages (8KB per page, totaling 512KB), submitting asynchronous I / O requests using the `io_submit` system call to load data pages into the Buffer Pool cache, and initiates a range prefetch of the 1994 data range of the `orders` table with a prefetch depth of 16 pages; the column-based prefetching executor initiates a batch column vector prefetch of the `l_extendedprice`, `l_discount`, `l_orderkey`, and `l_suppkey` columns of the `lineitem` table, reading consecutive compressed data blocks of each column at once. Assuming each column of 1994 data is 200MB after compression, the data is decompressed in the column-based storage cache and organized into vector batches of 1000 tuples per batch; the vector index prefetching executor does not operate because this query does not involve vector indexes.
[0084] Step S7: After the row-store prefetch executor loads the data pages of the customer table into the Buffer Pool, the zero-copy injection layer directly registers the memory address pointers corresponding to these pages to the Build Side input descriptor of the vectorized execution engine's HashJoin operator; after the column-store prefetch executor organizes the column vector batches of the lineitem table, the zero-copy injection layer registers the pointers of each column vector batch to the input of the scan operator; the vectorized execution engine processes data at a granularity of 1000 rows / batch, and the prefetched data is strictly aligned with the execution batch.
[0085] Step S8: The execution feedback collection module records: the prefetch hit rate is 82%, the query latency is 12.3 seconds, the baseline latency is 15.8 seconds, an improvement of 22.2%, and the storage IO utilization rate is 45%. The adaptive adjustment module determines that the prefetch hit rate of 82% is higher than the third threshold of 80% and the IO utilization rate of 45% is lower than the fourth threshold of 50%. It increases the prefetch depth of the next similar query in Q5 from 64 pages of row storage and 16 pages to 80 pages and 20 pages, and incrementally updates the query result to the query intent graph online.
[0086] Implementation Results: On the GBase 8c database, based on the TPC-H SF100 dataset (100GB), the query latency in Q5 decreased from 15.8 seconds to 12.3 seconds, an improvement of 22.2%; the query latency in Q7 decreased from 18.5 seconds to 14.1 seconds, an improvement of 23.8%; and the query latency in Q10 decreased from 14.2 seconds to 11.5 seconds, an improvement of 19.0%. In a mixed load scenario where TPC-C and TPC-H are running simultaneously, the overall system throughput increased by approximately 15%, without significantly negatively impacting the transaction latency of TPC-C, with an increase of less than 3%.
[0087] The technical features of this embodiment can be combined with the technical features of any of the other embodiments.
[0088] Example 6 This embodiment uses a batch scan scenario of the GBase 8c column-oriented storage engine CStore as an example to illustrate the working process of the column-oriented prefetch executor. Assume there is a column-oriented table `sales` containing columns `sale_id` (INT type), `sale_date` (DATE type), `product_id` (INT type), `quantity` (INT type), `amount` (DECIMAL type), and `region_id` (INT type). The query filtering condition is that `sale_date` is between January 1, 2024 and March 31, 2024, and `region_id` values belong to the set consisting of 1, 2, and 3. The sum of `amount` is then aggregated by grouping by `product_id`. Steps S1 to S5 are similar to those in Embodiment 5; the focus here is on describing the differentiated strategies of the column-oriented prefetch executor.
[0089] Step S6: The column store prefetch executor identifies that the query involves a column store modality and requires access to the columns product_id, amount, sale_date, and region_id. It then performs the following operations: Column selection optimization: Based on historical patterns in the query intent graph, it is found that similar queries, after accessing sale_date and region_id, have a 78% probability of accessing amount and product_id for aggregation and a 65% probability of accessing quantity for subsequent analysis. Therefore, in addition to prefetching the columns required by the current query, the quantity column is also prefetched as a speculative prefetch; Batch column vector prefetching: Prefetching tasks are organized by column. For the sale_date column, since the WHERE clause includes a range condition, the CU (Compression) for sale_date within the range of January 1, 2024 to March 31, 2024 is calculated. The list of compression units is used to read these CUs in a single asynchronous I / O request. Assuming this range contains 120 CUs, each compressed to 64KB, the total read size is 7.5MB. For the `region_id` column, due to the discrete values involved in the IN condition, all CUs in the `region_id` column are read, assuming a total of 500 CUs (32MB). Decompression and vector batch alignment are performed by pre-allocating memory space in the columnar storage cache aligned with the batch size of the vectorized execution engine. For example, if each batch contains 1000 tuples, and the `sale_date` column (INT type) occupies 4 bytes, each batch requires 4KB. When the compressed data arrives, the LZ4 decompression algorithm is called to decompress the data into aligned memory and organize it into vector batches of 1000 tuples per batch. Each vector batch contains a pointer to a contiguous memory region and a count of valid tuples. Multi-column parallel prefetching is performed by starting four parallel prefetch threads responsible for prefetching and decompressing the `product_id`, `amount`, `sale_date`, and `region_id` columns respectively. Each thread works independently, using a lock-free queue. The Queue submits the prepared vector batches to the zero-copy injection layer.
[0090] Step S7: The zero-copy injection layer obtains vector batches from the lock-free queue of each column, assembles the pointers of each column vector batch into a column batch descriptor, and directly passes it to the CStore Scan operator; the CStoreScan operator accesses the data of each column through the pointers in the column batch descriptor, performs vectorized filtering and aggregation operations, without the need for row-to-column format conversion, and directly calls SIMD instructions such as AVX2 to perform batch calculations.
[0091] Step S8: The execution feedback collection module records: the prefetch hit rate of the sale_date column is 95%, the prefetch hit rate of the region_id column is 100%, and the speculative prefetch hit rate of the quantity column is 45%. The adaptive adjustment module reduces the prefetch weight of the quantity column and weakens the related edge in the query intent graph because the hit rate of the quantity column is lower than the threshold of 50%. At the same time, because the hit rates of the sale_date and region_id columns are extremely high, the prefetch depth of these two columns is increased, expanding from the current CU granularity to the CU of the next time window, such as prefetching the sale_date data for April 2024.
[0092] Implementation Results: On the GBase 8c CStore engine, based on a 100GB sales data table, the above-mentioned aggregation query latency was reduced from 8.5 seconds to 5.2 seconds, an improvement of 38.8%. The column cache hit rate increased from 62% to 89%, and the number of storage IO requests decreased from 1200 to 380, a reduction of 68.3%. The speculative prefetching mechanism further improved the hit rate by about 12% in highly correlated query sequences, and avoided cache pollution in weakly correlated sequences through adaptive adjustment.
[0093] The technical features of this embodiment can be combined with the technical features of any of the other embodiments.
[0094] Example 7 This embodiment uses an approximate nearest neighbor query scenario based on HNSW (Hierarchical Navigable Small World) vector index to illustrate the working process of the vector index prefetch executor. Assume there exists a face feature table `face_vectors` containing 100 million 128-dimensional floating-point vectors, indexed using HNSW.
[0095] Steps S1 to S5: The query intent extraction module extracts feature vectors. ,in , , That is, a distance threshold of 0.3 and no complex logic. , The query intent graph storage module discovered a large number of similar face search queries in the historical queries and constructed a query intent graph. The similar query matching module retrieved the Top-K=5 similar historical queries through the LSH index, and their subsequent access patterns showed that there was a high probability of accessing the HNSW index after executing the HNSW search. A layer is the neighborhood node at the bottom layer and the corresponding vector data page.
[0096] Step S6: The vector index prefetch executor identifies that the query involves a vector index modality, namely the HNSW index, and executes the following neighborhood prefetch strategy: HNSW hierarchical neighborhood prefetch, HNSW index top-level... sparse nodes, bottom layer With dense nodes, the retrieval algorithm descends layer by layer from the top to the bottom, and the vector index prefetch executor performs this process as the query enters the system. During layer traversal, all neighboring nodes of the currently accessed node (i.e., those with a distance less than 1) are prefetched. The edges connect the vector pages corresponding to the nodes. Assume the currently visited node has... Each neighborhood connection submits 16 asynchronous I / O requests. Each page contains 32 128-dimensional vectors, each vector is 512 bytes, and each page is 16KB. Candidate set prefetching and the HNSW retrieval algorithm are used. The layer maintains a candidate set (Candidate Set). The prefetcher prefetches the vector pages corresponding to all candidate nodes in the candidate set, as well as the neighboring node pages of each candidate node. Assume the size of the candidate set is... The neighborhood union of the 200 candidate nodes is calculated to obtain approximately 800 unique neighborhood nodes, and 800 asynchronous IO requests are submitted. Since these IO requests are highly random, an IO merging strategy is adopted to merge multiple node requests within the same vector page into a single page read. Distance calculation is accelerated by prefetching the corresponding vector ID and metadata such as face_id while prefetching vector data, so that the vectorized execution engine can immediately perform vector distance calculations such as L2 distance or cosine distance and sorting operations after receiving the prefetched data.
[0097] Step S7: The vector index prefetch executor organizes the prefetched vector page data into vector batches, such as 100 128-dimensional vectors per batch, and passes the batch pointer to the VectorIndexScan operator through the zero-copy injection layer; the VectorIndexScan operator uses SIMD instructions such as the VFMADD instruction of Intel AVX-512 to calculate the distance between query_vector and each vector in the batch in batch, and performs efficient approximate nearest neighbor filtering.
[0098] Step S8: The execution feedback acquisition module recorded: HNSW retrieval latency decreased from 120ms to 65ms, an improvement of 45.8%, prefetch hit rate was 78%, and vector page cache hit rate was 85%; the adaptive adjustment module analysis found that the missed prefetch nodes were mostly located at the edge of the candidate set, therefore the neighborhood prefetch threshold was adjusted. The value was reduced from 0.2 to 0.15, prefetching only the nearest neighboring nodes, while increasing the vector page cache size from 256MB to 512MB.
[0099] Implementation Results: On the GBase 8c vector index extension, based on 100 million 128-dimensional face vector data, the query latency for Top-100 near nearest neighbors decreased from 120ms to 65ms, an improvement of 45.8%, and the QPS (queries per second) increased from 320 to 580, an improvement of 81.3%. In a scenario with 64 threads concurrent queries, the overall system throughput improved by approximately 65%, and no significant cache jitter was observed. The neighborhood prefetching strategy reduced the number of random I / O operations for the HNSW index from an average of 450 times / query to 120 times / query, a reduction of 73.3%.
[0100] The technical features of this embodiment can be combined with the technical features of any of the other embodiments.
[0101] Beneficial effects In combination with the above embodiments, the present invention has at least the following beneficial effects, and each beneficial effect corresponds one-to-one with the technical feature that produces it: Firstly, the feature vectors and query intent graphs corresponding to equations (1) to (2) capture the temporal correlation and semantic similarity of historical queries, transform the query semantics into computable graph structure knowledge, and transform prefetching from a passive post-event response to an active pre-event prediction, thus alleviating the problem of decreased cache hit rate when first access or access pattern changes.
[0102] Secondly, corresponding to the two-stage matching of local sensitive hashing in equation (3): similar nodes are retrieved in the high-dimensional feature space with sublinear time complexity, reducing the time complexity from Reduce to This meets the real-time requirements of database query processing.
[0103] Third, the probability-cost model corresponding to equations (4) to (6) uniformly characterizes the prefetch value of three types of data objects: row storage, column storage, and vector index. Under limited IO bandwidth and cache capacity, it prioritizes the prefetching of data objects with the highest unit cost benefit, and achieves unified intelligent prefetching across modes by matching the physical characteristics of each storage mode through differentiated prefetching strategies.
[0104] Fourth, corresponding to prefetch circular buffer and batch alignment, zero-copy pointer registration and reference count release: eliminates the memory copy overhead of prefetched data entering the batch processing pipeline, reduces CPU overhead by about 15%, and enables prefetching and execution to be parallel at the pipeline level.
[0105] Fifth, corresponding to the execution feedback and adaptive adjustment closed loop in step S8: dynamically adjust the prefetch depth, width and trigger threshold, and incrementally update the query intent graph online, so that the system can continuously optimize itself as the workload changes, avoid cache pollution and improve the prefetch hit rate.
[0106] Real-world test data shows that in the TPC-H SF100 scenario, query latency for Q5, Q7, and Q10 decreased by 22.2%, 23.8%, and 19.0%, respectively, with an overall throughput increase of approximately 15% under mixed loads; in the columnar storage batch scan scenario, aggregate query latency decreased by 38.8%, and the number of IO requests decreased by 68.3%; in the vector index scenario, Top-100 query latency decreased by 45.8%, and the number of random IO requests decreased by 73.3%.
[0107] The above are merely preferred embodiments of the present invention and are not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. An intelligent prefetching method for hybrid workload databases, characterized in that, Includes the following steps: S1. Query Intent Extraction Steps: Receive the SQL query statement, perform syntax tree parsing, and extract the query feature vector. ,in To query the set of tables involved, To query the set of columns involved, This is a feature of predicate selectivity. For table join type characteristics, Features for sorting keys; S2. Query Intent Graph Construction Steps: Using the feature vector of each query in the historical query sequence as a node, construct directed edges according to the time order of query execution, and use the weighted value of the similarity and transition frequency of adjacent queries as the edge weights to construct the query intent graph. ,in , , These are the node set, the edge set, and the edge weight set, respectively. S3. Similarity Query Matching Steps: Based on the Locality Sensitive Hash (LSH) algorithm, the feature vectors of nodes in the query intent graph are hashed and encoded to construct an LSH index; the feature vector of the current query is quickly matched using the LSH index to retrieve a preset number of similar queries. A number of similar historical query patterns; S4. Prefetch Object Prediction Steps: Analysis Given a set of data objects accessed in subsequent queries based on similar historical query patterns, calculate the access probability of each data object. The data objects include row-stored data blocks, column-stored data blocks, and vector index pages; S5. Prefetch priority sorting step: Estimate the I / O load cost of each data object. Prefetch priority score is calculated based on the ratio of access probability to IO loading cost. Generate a prefetch task queue in descending order of prefetch priority score; S6. Cross-modal prefetching execution steps: Based on the storage modality type of the data objects in the prefetching task queue, the corresponding prefetching executor is called to asynchronously load the data objects from the persistent storage layer to the multi-level cache layer; the storage modality types include row storage modality, column storage modality and vector index modality, each modality corresponds to a different prefetching strategy, and multiple prefetching executors work in parallel; S7. Vectorized pipeline injection step: The batch data prefetched from the multi-level cache layer is injected into the input of the scan operator of the vectorized execution engine through zero-copy pointer passing.
2. The intelligent prefetching method for hybrid workload databases according to claim 1, characterized in that, Predicate selectivity features in step S1 The calculation method includes: extracting the predicate conditions of the WHERE clause in the SQL query statement, calculating the selectivity of each predicate condition, and using the selectivity vector and the predicate logical relation encoding as the predicate selectivity features. Predicate logical relation encoding includes bitmap encoding of AND, OR, and NOT relations; In step S2, query the intent graph. The construction method also includes: dividing the historical query sequence into sliding window segments, with a window size of [missing information]. The step size is 1. The number of queries contained in each sliding window, and the query sequence within each window, are constructed into a local subgraph; local subgraphs are connected through shared nodes to form a global query intent graph; the global query intent graph is periodically pruned, removing edges with weights below a threshold. Edges and isolated nodes.
3. The intelligent prefetching method for hybrid workload databases according to claim 1, characterized in that, The hash function of the locality-sensitive hashing algorithm in step S3 is: ,in For random projection vectors, For random offsets, For the barrel width parameter, To query the feature vector of the i-th node in the intent graph G, for The result of rounding down; using multiple hash table strategies to construct... Each hash table uses a separate hash table, and each hash table uses... Several hash functions; fast matching includes: mapping the current query feature vector to the corresponding buckets in each hash table, taking the union of candidate nodes in each bucket as the candidate set, and then performing precise similarity calculation in the candidate set to filter out... A number of similar historical query patterns; precise similarity calculation uses cosine similarity or Jaccard similarity.
4. The intelligent prefetching method for hybrid workload databases according to claim 1, characterized in that, Access probability in step S4 The calculation formula is: ; in For the first The similarity weight of each similar historical query. For indicator functions, For the current query, Indicates the first The summation is performed on the set of data objects accessed by subsequent queries of similar historical queries. From 1 to conduct; IO loading cost in step S5 The calculation formula is: ; in For the size of the data object, For storage device bandwidth, This is an estimate of the head seek time. This is an estimate of the data decompression time.
5. The intelligent prefetching method for hybrid workload databases according to claim 1, characterized in that, The differentiated prefetch strategies in step S6 include: For row storage mode, an asynchronous sequential prefetch strategy is adopted, continuously reading data pages into the buffer pool according to page number. The prefetch depth is dynamically adjusted according to the scan range of the current query, with a depth of 64 pages for a full table scan and 16 pages for a range scan; For column storage mode, a batch column vector prefetch strategy is adopted, reading consecutive compressed data blocks of the target column into the column storage cache at once, decompressing and organizing them according to vector batch alignment, and supporting parallel prefetching of multiple columns; For vector index mode, a neighborhood prefetch strategy is adopted, preloading data blocks whose distance from the currently accessed node is less than a threshold. For the neighborhood vector page, the HNSW index prefetches the neighborhood nodes of the current layer and the next layer; for the IVF index, it prefetches the nearest neighbor node to the current query vector. The inverted list page corresponding to each cluster center.
6. The intelligent prefetching method for hybrid workload databases according to claim 1, characterized in that, The zero-copy pointer passing method in step S7 includes: pre-allocating memory pages aligned with the batch size of the vectorized execution engine in the multi-level cache layer, with the memory pages allocated using posix_memalign for 64-byte alignment; after the prefetch executor loads data into the memory pages, it directly registers the physical address pointer of the memory pages into the input descriptor of the vectorized execution engine scan operator; the prefetched batch data is buffered by a prefetch circular buffer aligned with the batch size and then supplied to the scan operator via pointer passing; after the scan operator completes batch processing, it releases the memory pages through a reference counting mechanism.
7. The intelligent prefetching method for hybrid workload databases according to claim 1, characterized in that, It also includes step S8, the execution feedback and adaptive adjustment step: collecting execution feedback information from the vectorized execution engine, including prefetch hit rate, query latency and throughput; and dynamically adjusting the depth, width and prefetch trigger threshold of the prefetch task queue based on the execution feedback information. Based on the current query execution results, the query intent graph is updated incrementally online. The dynamic adjustment of the prefetch task queue depth includes: decreasing the prefetch depth when the prefetch hit rate is below a first threshold and the query latency is above a second threshold; increasing the prefetch depth when the prefetch hit rate is above a third threshold and the storage I / O utilization is below a fourth threshold; if both increase and decrease conditions are met simultaneously, the decrease operation is prioritized; the adjustment step size for the prefetch depth is... The adjustment cycle is Individual query batches; online incremental updates to the query intent graph include: adding the current query as a new node to the graph, establishing connections with the most recent queries. Connect the edges of each historical query, update the edge weights, and trigger pruning if the graph size exceeds the upper limit.
8. An intelligent prefetching system for hybrid workload databases, used to execute the intelligent prefetching method for hybrid workload databases as described in any one of claims 1-7, characterized in that, include: The query intent extraction module receives SQL query statements, performs syntax tree parsing, and extracts query feature vectors. ; The query intent graph storage module is used to store query intent graphs constructed based on historical query sequences. It also provides an index retrieval interface based on the locality-sensitive hashing algorithm; The similarity query matching module is used to quickly match the feature vector of the current query using the LSH index and retrieve a preset number of results. A number of similar historical query patterns; The prefetch decision engine module is used to analyze subsequent access objects with similar historical query patterns, calculate access probability and IO loading cost, and generate a prefetch task queue sorted by prefetch priority score. The cross-modal prefetch executor module includes a row-store prefetch executor, a column-store prefetch executor, and a vector index prefetch executor. It is used to call the corresponding prefetch executor according to the storage modality type of the data object, and asynchronously load the data from the persistent storage layer to the multi-level cache layer. The multi-level cache layer includes a Buffer Pool cache area for row storage modality, a column-store cache area for column storage modality, and a vector page cache area for vector index modality. The vectorized execution engine module is used to receive prefetched batch data from multi-level cache layers in a zero-copy manner and execute the batch processing pipeline. The execution feedback acquisition module is used to collect execution feedback information from the vectorized execution engine and transmit it to the adaptive adjustment module. The adaptive adjustment module is used to dynamically adjust the prefetch strategy parameters based on execution feedback information and to incrementally update the query intent graph online.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the intelligent prefetching method for hybrid workload databases as described in any one of claims 1 to 7.
10. An electronic device comprising a processor and a memory, wherein a computer program is stored in the memory, characterized in that, When the processor executes a computer program, it implements the intelligent prefetching method for a hybrid workload database as described in any one of claims 1 to 7.
