Cross-database cost estimation method based on enhanced general knowledge

By introducing enhanced general knowledge and a meta-learning framework into a cross-database environment, combined with a deep learning model based on the Transformer architecture, the problem of cost estimation in complex queries and cross-database environments is solved, achieving high accuracy and rapid adaptability.

CN120929490APending Publication Date: 2025-11-11YANGTZE DELTA REGION INST (QUZHOU) UNIV OF ELECTRONIC SCI & TECH OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510881913.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-27
Publication Date
2025-11-11

AI Technical Summary

Technical Problem

Existing technologies are insufficient in terms of the accuracy and applicability of cost estimation when facing complex query scenarios and cross-database environments, especially when data distribution changes and between diverse database systems, making effective migration difficult.

Method used

We adopt a cross-database cost estimation method based on enhanced general knowledge. By integrating the common features of multiple database systems and hardware environments, we use a meta-learning framework and Transformer architecture, combined with a deep learning model, to estimate costs, capture the complex dependencies between operation nodes, and dynamically adjust the strategy to adapt to different environments.

Benefits of technology

The cost estimation that maintains high accuracy under different database systems and hardware configurations improves the accuracy and adaptability of complex queries and reduces the adaptation cost and cycle of the model in new environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120929490A_ABST
    Figure CN120929490A_ABST
Patent Text Reader

Abstract

The invention discloses a cross-database cost estimation method based on enhanced general knowledge, and relates to the technical field of database query optimization, and the method comprises the steps: obtaining a query execution plan of a to-be-estimated cost, and obtaining hardware environment information corresponding to the operation environment of the query execution plan; inputting the query execution plan and the hardware environment information into a pre-trained cost estimation model to generate a cost estimation value of the query execution plan; wherein the cost estimation model is obtained through training of a meta-learning framework, the model fuses enhanced general knowledge, and the knowledge is knowledge embedding obtained by learning common characteristics of a plurality of different database systems and hardware environments and performing structured representation; the meta-learning framework performs inner loop and outer loop training processes to improve model cross-scene adaptability. By introducing general knowledge and meta learning, accurate cost estimation can be realized under various software and hardware configurations, and good migration capability and stability are achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of database query optimization technology, and more specifically, to a cross-database cost estimation method based on enhanced general knowledge. Background Technology

[0002] With the widespread application of database systems and the continuous growth of data volume, database query optimization plays an increasingly prominent role in improving system performance. Cost estimation, as a core component of the query optimizer, guides the optimizer to make optimal decisions through accurate evaluation of different execution plans. The goal of cost estimation is to estimate the cost of various operations in query execution and, by comparing these costs, help the query optimizer select the optimal execution plan.

[0003] In recent years, deep learning technology has made significant progress in fields such as image recognition and natural language processing, and has gradually been introduced into the database field. Deep learning-based cost estimation methods, by automatically extracting features from a large number of historical queries and utilizing neural networks to model complex nonlinear relationships, have demonstrated higher prediction accuracy than traditional methods in multiple experiments. In particular, the application of structures such as Transformer and Graph Embedding enables the model to better capture the operational dependencies in the query plan, thereby improving the accuracy of cost estimation.

[0004] However, current cost estimation methods still have some significant limitations, especially when faced with complex query scenarios and diverse database systems, where the applicability and accuracy of these methods are greatly challenged:

[0005] First, traditional cost estimation methods mostly rely on internal database statistics (such as table cardinality, data distribution, and index selectivity). These static statistics cannot reflect real-time changes in the data within the database, leading to a significant drop in cost estimation accuracy when data distribution or query patterns change. Furthermore, traditional methods are weak in handling complex queries (such as multi-table joins and large-scale data queries), often failing to effectively address complex query scenarios.

[0006] Secondly, the applicability of traditional cost estimation methods faces significant challenges in cross-database environments. Different database systems differ significantly in their architecture, query processing strategies, and execution plan generation, making it difficult to effectively migrate cost estimation models based on a single database to other systems. This is especially true when handling cross-database queries, where differences in statistical information collection methods and query optimization strategies among database systems often result in lower accuracy of cost estimations, impacting query optimization effectiveness.

[0007] Therefore, how to ensure high accuracy while adapting to cross-database environments and reducing the negative impact of complex queries has become an important problem that urgently needs to be solved in the field of cost estimation. Summary of the Invention

[0008] The present invention provides a cross-database cost estimation method based on enhanced general knowledge, which can solve the above-mentioned problems.

[0009] To solve the above problems, the technical solution adopted by the present invention is as follows:

[0010] A cross-database cost estimation method based on enhanced general knowledge includes:

[0011] Obtain the query execution plan for the cost to be estimated, and simultaneously obtain the hardware environment information corresponding to the runtime environment of the query execution plan;

[0012] The query execution plan and hardware environment information are input into a pre-trained cost estimation model to generate a cost estimate for the query execution plan.

[0013] The cost estimation model is a model that incorporates enhanced general knowledge, which is obtained by learning and structurally representing the common features of multiple different database systems and hardware environments. Furthermore, the cost estimation model is trained using a meta-learning framework that performs inner and outer loop training processes to improve the model's cross-scenario adaptability.

[0014] Furthermore, the process of constructing the enhanced general knowledge includes: systematically collecting and integrating data to form a comprehensive knowledge base, the content of which includes the database architecture features, statistical information, and data distribution patterns of multiple database systems, as well as the hardware resource information of multiple hardware environments. The database architecture features include storage structure, index type, and execution plan composition, and the statistical information and data distribution patterns include the cardinality, selectivity estimation, and histogram information of the tables. The knowledge in the comprehensive knowledge base is then represented in a structured manner using a deep learning model to generate knowledge embeddings that can be shared across scenarios.

[0015] Furthermore, before inputting the query execution plan into the cost estimation model, a feature extraction step is included for the query execution plan. This step uses a depth-first search algorithm to traverse the query plan tree to obtain a determined sequence of operation nodes. For each operation node in the sequence, its node type, cardinality estimate provided by the database management system, and cost estimate are extracted as the initial features of that node. The node type is converted into a numerical vector using one-hot encoding, while the cardinality estimate and cost estimate are normalized to form a node feature vector of a uniform dimension, thus constituting the operation node feature sequence.

[0016] Furthermore, this method also includes a step of height encoding enhancement for the feature vector of each operation node; this step first calculates the height of each node in the query plan tree, which is defined as the length of the longest path from the node to its farthest leaf node; then, the height value is input into a learnable height embedding layer to generate a height embedding vector; finally, this height embedding vector is added element-wise to the original feature vector of the node to obtain the enhanced node feature vector.

[0017] Furthermore, the cost estimation model includes a self-attention mechanism-based module that receives the operation node feature sequence as input. The self-attention mechanism adjusts the representation of each node by calculating the similarity between nodes in the sequence, thereby capturing the relationship between nodes. After processing the input operation node sequence, the self-attention mechanism-based module outputs an updated operation node feature sequence.

[0018] Furthermore, the module based on the self-attention mechanism is a Transformer architecture that only contains encoders; this architecture receives the feature sequence of the operation node and encodes the input sequence through its internal self-attention mechanism and parallel processing structure; this architecture consists of multiple stacked encoder layers, which gradually extract key information in the query plan through multi-layer information processing, and finally outputs a super node vector representing the entire query plan.

[0019] Furthermore, the processing steps for hardware environment information include: first, constructing a two-dimensional vector h from the hardware environment information obtained from the current environment, which includes CPU frequency and memory bandwidth. device Then, the two-dimensional vector h device The input is fed into a linear transformation layer, which includes a weight matrix W. meta and bias vector b meta Its transformation formula is

[0020] h transformered =W meta h device +bmeta

[0021] This maps the original two-dimensional hardware information into a 64-dimensional hardware feature embedding vector h. transformered .

[0022] Furthermore, before generating the final cost estimate, a feature fusion and prediction step is performed: First, the supernode vector output by the Transformer architecture and the hardware feature embedding vector generated by the linear transformation layer are concatenated in terms of dimension to form a fused vector; then, the fused vector is input into a three-layer multilayer perceptron for processing, where the dimensions of each hidden layer of the multilayer perceptron are 192, 64 and 32, respectively, and finally a scalar value is output as the cost estimate result.

[0023] Furthermore, the parameters of the multilayer perceptron and the Transformer architecture are both optimized as model parameters of the cost estimation model during training; and the weight matrix W in the linear transformation layer used to generate the hardware feature embedding vector... meta and bias vector b meta These serve as meta-parameters in the meta-learning framework; during training, model parameters are updated in both the inner and outer loops, while meta-parameters are only updated in the outer loop based on the overall performance of all tasks.

[0024] Furthermore, the meta-learning framework is trained using a model-independent meta-learning algorithm, and its training process includes:

[0025] In the inner loop phase, for a specific task, the current parameters θ of the model are... i Update the formula as follows:

[0026]

[0027] Where, θ i These are the model parameters for task i. Let α be the loss function for task i, and α be the learning rate. This represents the training process of the model on task i;

[0028] In the outer loop phase, the model's meta-parameters are updated by optimizing the performance of multiple tasks. The optimization formula for the outer loop is as follows:

[0029]

[0030] Where θ is a meta-parameter, β is the learning rate of the outer loop, and θ i ' is the parameter after the inner loop is updated. This represents the state of the model after the inner loop updates it on task i.

[0031] Compared with the prior art, the beneficial effects of the present invention are:

[0032] (1) This invention innovatively introduces the concept of “enhanced general knowledge”. By systematically learning common knowledge from various database systems and hardware environments and training it in combination with a meta-learning framework, the model of this invention is no longer limited to a specific environment. It can maintain high accuracy in cost estimation under different database systems and diverse hardware configurations, thus solving the core pain points of poor transferability and weak generalization ability of existing technology models.

[0033] (2) For the first time, this invention uses hardware environment information as the dynamic input of the model and represents it through a learnable embedding layer. The model can actively perceive changes in computing resources and dynamically adjust its cost estimation strategy, so that this invention can still provide accurate evaluation in real production scenarios such as hardware upgrades or resource constraints, and has a practicality that cannot be matched by existing technologies.

[0034] (3) The present invention adopts the Transformer architecture as the core model. By utilizing its powerful self-attention mechanism, it can effectively capture the long-distance, non-linear dependency relationship between any two operation nodes in the query execution plan. Compared with traditional methods and some shallow learning models, the present invention can more deeply understand the internal logic when dealing with queries containing multiple nesting and complex connections, thereby significantly improving the accuracy of cost estimation for complex queries.

[0035] (4) By introducing the meta-learning framework, the model of this invention learns the ability to "learn how to learn". When faced with a brand new and unseen database or hardware environment, the model only needs a small amount of new sample data for rapid fine-tuning (inner loop) to quickly adapt to the new scenario, showing extremely high data efficiency and transfer capability, which greatly reduces the application cost and cycle of the model in actual deployment.

[0036] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, embodiments of the present invention are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0037] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0038] Figure 1 This is a system overview diagram of the cross-database cost estimation method based on enhanced general knowledge described in this invention;

[0039] Figure 2 This is a system architecture diagram of the cross-database cost estimation method based on enhanced general knowledge described in this invention. Detailed Implementation

[0040] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are some embodiments of the present invention, but not all embodiments.

[0041] For clarity, several English abbreviations and technical terms appearing in the embodiments and accompanying drawings of this invention will be explained first:

[0042] DFS (Depth-First Search) refers to the depth-first search algorithm.

[0043] MLP (Multi-Layer Perceptron) is a type of feedforward artificial neural network.

[0044] MAML (Model-Agnostic Meta-Learning) refers to a model-agnostic meta-learning algorithm, a meta-learning method designed to learn the ability of a model to generalize quickly.

[0045] CPU (Central Processing Unit) refers to the central processing unit.

[0046] DBMS (Database Management System) refers to a database management system.

[0047] ML4DB (Machine Learning for Databases) refers to machine learning techniques or systems applied to the field of databases.

[0048] Transformer refers to a deep learning model architecture based on a self-attention mechanism.

[0049] vector or vectors, pointers to vectors.

[0050] Query plan operation types: MERGE JOIN refers to merge join, HASH JOIN refers to hash join, SEQ SCAN refers to sequential scan, and INDEX SCAN refers to index scan. These are all basic operations when the database executes a query.

[0051] Attn refers to the attention mechanism.

[0052] FFN stands for Feed-Forward Network.

[0053] like Figure 1 and Figure 2 As shown, this embodiment of the invention provides a framework for a cross-database cost estimation method based on enhanced general knowledge. Its core process involves obtaining the query execution plan whose cost is to be estimated, and simultaneously obtaining the hardware environment information corresponding to the runtime environment of the query execution plan. The query execution plan and the hardware environment information are then input into a pre-trained cost estimation model to generate a cost estimate for the query execution plan. This ensures that the optimizer can still provide accurate and efficient query execution plan selection in diverse database systems.

[0054] The following describes in detail the three core modules of this method framework and their technical methods:

[0055] 1. Feature Extraction Module

[0056] The goal of feature extraction is to extract relevant features for each node by traversing the query plan tree. These features include, but are not limited to, node type, cardinality of the input data, selectivity of the query operation, and cost estimation of the execution plan. In the feature extraction stage, this invention extracts the feature vector x of the query plan. query and the embedding vector h of hardware devices device The combined vector z is formed by concatenating the vectors and serves as the final input feature vector. Feature extraction is a crucial first step in the cost estimation model, aiming to transform the node information in the query plan into features that can be effectively processed by the deep learning model.

[0057] (1) DFS traversal of the query plan tree: In this embodiment, the depth-first search algorithm is used to traverse the query plan tree to obtain the sequence of nodes in the query plan. Starting from the root node of the tree, each child node is traversed in turn until all nodes are traversed.

[0058] (2) Feature extraction for each node: Once a definite sequence of operation nodes is obtained through DFS traversal, it is necessary to extract the node type, cardinality estimate provided by the database management system, and cost estimate for each operation node in the sequence as initial features for that node. To facilitate model processing, categorical features such as node type are converted into numerical vectors using one-hot encoding, and numerical features such as cardinality and cost are normalized. These processed feature vectors are arranged in order and together constitute the operation node feature sequence.

[0059] Node type refers to the type of each operation in the query plan, such as sequential scan, index scan, hash join, etc.

[0060] The cardinality estimated by the DBMS (an estimate obtained through heuristic methods): Cardinality refers to the amount of data that needs to be processed when each operation is executed. Traditional cost estimation methods usually rely on cardinality values ​​calculated by the database system based on statistical information. To ensure that the model can adapt to different database systems, this invention normalizes these cardinality values ​​to maintain consistency across different databases and query scenarios.

[0061] DBMS estimated cost (cost calculated heuristically based on cardinality): Cost typically refers to the amount of resources consumed by a database system to perform a certain operation. The accuracy of cost estimation is crucial to the effectiveness of query optimization; therefore, heuristic methods are used to calculate the cost of each operation and normalize it.

[0062] (3) Height Encoding: To capture the information flow between parent and child nodes, this invention integrates node height information into the node embedding. Specifically, this step first calculates the height of each node in the query plan tree, defined as the length of the longest path from the node to its farthest leaf node. Then, this height value is input into a learnable height embedding layer to generate a height embedding vector. Finally, this height embedding vector is added element-wise to the node's original feature vector to obtain the enhanced node feature vector, whose mathematical expression is:

[0063] x i ′=x i +E h

[0064] Where, x i It is the embedding of nodes, E h It is an embedding learned from the node height. In this way, the present invention can effectively integrate into the information flow of a tree structure.

[0065] 2. Model building module

[0066] The structural design of the cost estimation model is a crucial step in ensuring efficient learning and accurate prediction. This invention employs a Transformer-based deep learning architecture. The Transformer-based deep learning architecture fully leverages its self-attention mechanism and parallel processing capabilities to effectively address the complex dependencies between nodes in the query plan and enables effective transfer learning across multiple tasks.

[0067] (1) Establish a cost estimation model based on Transformer: The model contains a module based on self-attention mechanism, which receives the operation node feature sequence generated in the previous stage as input.

[0068] The specific processing procedure is as follows:

[0069] 1) Input layer: The input layer transforms the node features of the query plan into numerical vectors, which are then fed into the Transformer model for processing;

[0070] 2) Self-attention mechanism: The self-attention mechanism adjusts the representation of nodes by calculating the similarity between nodes, thereby capturing the relationship between nodes;

[0071] 3) Output layer: The query plan representation after processing by the self-attention mechanism is passed to the output layer, which finally generates the cost estimate of the query plan.

[0072] (2) The encoder-only structure in Transformer is adopted. In the Transformer architecture, there are usually two parts: encoder and decoder. In the cost estimation task, this invention only uses the encoder-only structure in Transformer. This structure can effectively encode the input query plan and gradually extract the key information in the query plan through multiple stacked encoder layers, and finally output a super node vector representing the entire query plan.

[0073] (3) Multilayer Perceptron: The output of the Transformer, after processing, is passed to the MLP for further cost estimation. The MLP further processes features and generates cost estimates through a three-layer linear neural network. Specifically:

[0074] 1) Three-layer linear neural network: Through a three-layer neural network, MLP can capture the complex nonlinear relationships between nodes in the query plan and generate the final cost estimate;

[0075] 2) Accepts the output of the Transformer as input: The input of the MLP is the output of the Transformer, which will further process the node features in the query plan;

[0076] 3) Output the estimated cost of the query plan: After processing by the MLP, the model finally outputs the estimated cost of the query plan, which is used by the query optimizer to select the optimal execution plan.

[0077] 3. Optimize the meta-learning framework

[0078] (1) In the meta-learning framework, this invention treats different database configurations and hardware configurations as independent tasks. This task definition approach enables the model to learn for each specific environment during training and improves its adaptability to new environments. Specifically, the task is defined as follows:

[0079] 1) Each task corresponds to a database or hardware configuration (e.g., different CPU frequencies and memory sizes);

[0080] 2) The input for each task is a representation of a query plan, including the order of query operations, join conditions, predicates, and other features;

[0081] 3) The output of each task is a cost estimate, including the execution time or cost of the query.

[0082] (2) The inner and outer loop training process of the MAML algorithm: The core idea of ​​meta-learning is to optimize the model's learning ability through the cooperation of the "inner loop" and the "outer loop" during the training process. The inner loop and the outer loop correspond to different levels of the learning process:

[0083] 1) Inner Loop: This focuses primarily on the learning process for each specific task. In the inner loop, the invention updates the model parameters using the standard gradient descent algorithm to minimize the cost estimation error for each task. Specifically, the inner loop calculates the loss of the query plan on a specific task and updates the model parameters using the backpropagation algorithm. The parameter update formula for the inner loop is as follows:

[0084]

[0085] Where, θ i These are the model parameters for task i. Let α be the loss function for task i, and α be the learning rate. This represents the training process of the model on task i.

[0086] The inner loop is used for rapid optimization on each specific task. In cross-scenario cost estimation tasks, the goal of the inner loop is to tune the model's parameters using a small amount of query data (e.g., query execution results on specific hardware). The inner loop enables the model to learn effectively even with limited data, especially by adjusting the cost estimation strategy promptly when the hardware environment changes.

[0087] 2) Outer Loop: This focuses on combining the learning results from multiple tasks. It utilizes the model's parameter sharing mechanism and updates the shared parameters across all tasks using gradient descent, enabling the model to learn shared features and patterns across multiple tasks. The outer loop updates the model's meta-parameters by optimizing the performance of multiple tasks. The optimization formula for the outer loop is as follows:

[0088]

[0089] Where θ is a meta-parameter, β is the learning rate of the outer loop, and θ i ' is the parameter after the inner loop is updated. Let α be the loss function for task i, and α be the learning rate. This represents the model's state after the inner loop update on task i. In the cross-scenario cost estimation task, the goal of the outer loop is to optimize the model's cost estimation capability across multiple hardware devices, enabling the model to acquire knowledge from multiple hardware environments and quickly perform cost estimation in new hardware environments.

[0090] Through this training process of inner and outer loops, the model can not only optimize on a single task, but also accumulate experience from multiple tasks. The inner loop enables the model to adapt to the characteristics of each hardware device by making efficient and rapid adjustments on small datasets; while the outer loop helps the model to transfer knowledge in multiple hardware environments, enabling the model to quickly adjust and provide accurate cost estimates when facing new hardware devices.

[0091] (3) A meta-learning framework is built on the cost estimation model, aiming to improve the model's generalization ability under different computing environments by introducing hardware resource information. The specific process is as follows:

[0092] 1) Transfer the feature vector h of the hardware device device ∈R 2 As input, it is mapped to a 64-dimensional space through a linear transformation layer:

[0093] h transformered =W meta h device +b meta ,h transformered ∈R 64

[0094] Among them, W meta ∈R 64×2 and b meta ∈R 64 These are meta-parameters in meta-learning, specifically designed to capture hardware environment features;

[0095] 2) Embed the obtained 64-dimensional hardware into h transformered With the supernode vector h in the query plan encoding supernode The vectors are concatenated to form a fused vector:

[0096] h concat =[h supernode h transformered ]∈R d

[0097] Among them, h supernode This represents the query plan, and the concatenated vector has a dimension of d.

[0098] Finally, the fused vector is input into a three-layer multilayer perceptron (MLP) for processing. The hidden layer dimensions of the three MLP layers are 192, 64, and 32, respectively, and the output is a predicted value for the query execution time.

[0099]

[0100] The above linear layer parameters W meta and b meta These are meta-parameters, trained and optimized by the meta-learning framework; while the parameters of the three-layer MLP are all cost estimation model parameters, which participate in the training together.

[0101] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. A cross-database cost estimation method based on enhanced general knowledge, characterized in that, include: Obtain the query execution plan for the cost to be estimated, and simultaneously obtain the hardware environment information corresponding to the runtime environment of the query execution plan; The query execution plan and hardware environment information are input into a pre-trained cost estimation model to generate a cost estimate for the query execution plan. The cost estimation model is a model that incorporates enhanced general knowledge, which is obtained by learning and structurally representing the common features of multiple different database systems and hardware environments. Furthermore, the cost estimation model is trained using a meta-learning framework that performs inner and outer loop training processes to improve the model's cross-scenario adaptability.

2. The cross-database cost estimation method based on enhanced general knowledge according to claim 1, characterized in that, The process of constructing the enhanced general knowledge includes: systematically collecting and integrating data to form a comprehensive knowledge base, the content of which includes the database architecture features, statistical information, and data distribution patterns of multiple database systems, as well as the hardware resource information of multiple hardware environments. The database architecture features include storage structure, index type, and execution plan composition, and the statistical information and data distribution patterns include the cardinality, selectivity estimation, and histogram information of the tables. The knowledge in the comprehensive knowledge base is then represented in a structured manner using a deep learning model to generate knowledge embeddings that can be shared across scenarios.

3. The cross-database cost estimation method based on enhanced general knowledge according to claim 1, characterized in that, Before inputting the query execution plan into the cost estimation model, a feature extraction step is included. This step uses a depth-first search algorithm to traverse the query plan tree to obtain a determined sequence of operation nodes. For each operation node in the sequence, its node type, cardinality estimate provided by the database management system, and cost estimate are extracted as the initial features of that node. The node type is converted into a numerical vector using one-hot encoding, while the cardinality estimate and cost estimate are normalized to form a node feature vector of uniform dimension, thus constituting the operation node feature sequence.

4. The cross-database cost estimation method based on enhanced general knowledge according to claim 3, characterized in that, It also includes a step of height encoding enhancement for the feature vector of each operation node; this step first calculates the height of each node in the query plan tree, which is defined as the length of the longest path from the node to its farthest leaf node; then, the height value is input into a learnable height embedding layer to generate a height embedding vector; finally, this height embedding vector is added element-wise to the original feature vector of the node to obtain the enhanced node feature vector.

5. The cross-database cost estimation method based on enhanced general knowledge according to claim 3, characterized in that, The cost estimation model contains a self-attention mechanism-based module that receives the operation node feature sequence as input. The self-attention mechanism adjusts the representation of each node by calculating the similarity between nodes in the sequence, thereby capturing the relationship between nodes; after processing the input operation node sequence, the module based on the self-attention mechanism outputs the updated operation node feature sequence.

6. The cross-database cost estimation method based on enhanced general knowledge according to claim 5, characterized in that, The module based on the self-attention mechanism is a Transformer architecture that only contains encoders. This architecture receives the feature sequence of the operation nodes and encodes the input sequence through its internal self-attention mechanism and parallel processing structure. The architecture consists of multiple stacked encoder layers. Through multi-layer information processing, it gradually extracts key information in the query plan and finally outputs a super node vector representing the entire query plan.

7. The cross-database cost estimation method based on enhanced general knowledge according to claim 6, characterized in that, The processing steps for hardware environment information include: First, constructing a two-dimensional vector h from the hardware environment information obtained from the current environment, which includes CPU frequency and memory bandwidth. device Then, the two-dimensional vector h device The input is fed into a linear transformation layer, which includes a weight matrix W. meta and bias vector b meta Its transformation formula is h transformered =W meta h device +b meta This maps the original two-dimensional hardware information into a 64-dimensional hardware feature embedding vector h. transformered .

8. The cross-database cost estimation method based on enhanced general knowledge according to claim 7, characterized in that, Before generating the final cost estimate, a feature fusion and prediction step is performed: First, the supernode vector output by the Transformer architecture and the hardware feature embedding vector generated by the linear transformation layer are concatenated in terms of dimension to form a fused vector; then, the fused vector is input into a three-layer multilayer perceptron for processing, with each hidden layer of the multilayer perceptron having dimensions of 192, 64 and 32, respectively, and finally outputting a scalar value as the cost estimate result.

9. The cross-database cost estimation method based on enhanced general knowledge according to claim 8, characterized in that, The parameters of the multilayer perceptron and the Transformer architecture are optimized as model parameters of the cost estimation model during training; while the weight matrix W in the linear transformation layer used to generate the hardware feature embedding vector... meta and bias vector b meta These serve as meta-parameters in the meta-learning framework; during training, model parameters are updated in both the inner and outer loops, while meta-parameters are only updated in the outer loop based on the overall performance of all tasks.

10. The cross-database cost estimation method based on enhanced general knowledge according to claim 1, characterized in that, The meta-learning framework is trained using a model-independent meta-learning algorithm, and its training process includes: In the inner loop phase, for a specific task, the current parameters θ of the model are... i Update the formula as follows: Where, θ i These are the model parameters for task i. Let α be the loss function for task i, and α be the learning rate. This represents the training process of the model on task i; In the outer loop phase, the model's meta-parameters are updated by optimizing the performance of multiple tasks. The optimization formula for the outer loop is as follows: Where θ is a meta-parameter, β is the learning rate of the outer loop, and θ i ' is the parameter after the inner loop is updated. This represents the state of the model after the inner loop updates it on task i.