Data query method, cardinal number estimation method, data query model training method, information processing method based on data query model and model training platform

By performing structural analysis and feature extraction on database query statements, and using data query model training, the problem of high resource overhead for different database query tasks is solved, and efficient data query across databases is achieved.

CN118760700APending Publication Date: 2024-10-11ALIBABA (CHINA) CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202410668489.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-27
Publication Date
2024-10-11

AI Technical Summary

Technical Problem

In the existing technology, different machine learning models need to be trained for data query tasks in different databases, resulting in large resource overhead and a lack of data query solutions with smaller resource overhead.

Method used

By obtaining the query statement of the target database, perform structural analysis and feature extraction, and use the data query model to train based on multiple sample query features and sample query features, realize data query across different databases and reduce resource overhead.

Benefits of technology

It improves the generalization ability of the data query model, reduces the resource overhead of the data query process, and realizes data query across different databases.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118760700A_ABST
    Figure CN118760700A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a data query method, a cardinal number estimation method, a data query model training method, an information processing method based on a data query model and a model training platform. The data query method comprises the steps of obtaining a query statement for a target database; performing structure analysis on the query statement, and determining query elements in the query statement and element types of the query elements; performing feature extraction on the query elements according to the element types to obtain query features; and inputting the query features into a data query model to obtain a data query result corresponding to the query statement. Since the query elements and the element types are obtained by analyzing the general structures of the query statements, the generation mode of the query features can be suitable for the query statements of different databases, so that data query across different databases can be realized by using the data query model, the generalization ability of the data query model is improved, and the data query efficiency is improved. And the resource overhead in the data query process is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of this specification relate to the field of computer technology, and in particular to a data query method, a cardinality estimation method, a data query model training method, an information processing method based on a data query model, and a model training platform. Background Art

[0002] Data query is an important task in the fields of database management systems, data mining, and big data analysis. Taking the cardinality estimation (CardEst) task in data query as an example, the goal of the cardinality estimation task is to efficiently and approximately estimate the number of different elements in a data set, that is, the cardinality of the set.

[0003] At present, a separate machine learning model is usually trained for each database, and the machine learning model is used to process the data query tasks of the corresponding database. However, in the above scheme, the machine learning model can only process the tasks of the corresponding database. Different models need to be trained for data query tasks of different databases, resulting in a huge resource overhead in the data query process. Therefore, a data query solution with less resource overhead is urgently needed. Summary of the invention

[0004] In view of this, an embodiment of the present specification provides a data query method. One or more embodiments of the present specification also relate to a cardinality estimation method, a data query model training method, an information processing method based on a data query model, a model training platform, a data query device, a cardinality estimation device, a data query model training device, an information processing device based on a data query model, a computing device, a computer-readable storage medium, and a computer program product to solve the technical defects existing in the prior art.

[0005] According to a first aspect of an embodiment of the present specification, a data query method is provided, comprising: obtaining a query statement for a target database; performing a structural analysis on the query statement to determine query elements in the query statement and element types of the query elements; performing feature extraction on the query elements according to the element types to obtain query features; inputting the query features into a data query model to obtain a data query result corresponding to the query statement, wherein the data query model is trained based on a plurality of sample query features and sample query results corresponding to the sample query features, and the sample query features are obtained by extracting features of sample query elements in the sample query statement based on the sample element types.

[0006] According to a second aspect of an embodiment of the present specification, a cardinality estimation method is provided, comprising: receiving a cardinality estimation request for a target database, wherein the cardinality estimation request carries a query statement; performing structural analysis on the query statement to determine query elements in the query statement and element types of the query elements; performing feature extraction on the query elements according to the element type to obtain query features; inputting the query features into a data query model to obtain cardinality estimation results, wherein the data query model is trained based on multiple sample query features and sample query results corresponding to the sample query features, and the sample query features are obtained by performing feature extraction on sample query elements in the sample query statement based on the sample element type.

[0007] According to a third aspect of the embodiments of the present specification, a data query model training method is provided, comprising: obtaining a plurality of sample query statements, wherein the sample query statements carry sample query results; performing structural analysis on the plurality of sample query statements to determine sample query elements respectively included in the plurality of sample query statements and sample element types of the sample query elements; performing feature extraction on the sample query elements according to the sample element types to obtain sample query features respectively corresponding to the plurality of sample query statements;

[0008] Multiple sample query features are input into the data query model to obtain predicted query results; according to the predicted query results and the sample query results, the parameters of the data query model are adjusted to obtain a trained data query model.

[0009] According to a fourth aspect of the embodiments of the present specification, there is provided an information processing method based on a data query model, comprising: receiving a task generation request, wherein the task generation request includes request information; based on the request information, obtaining a data query model, wherein the data query model is trained based on a plurality of sample query features and sample query results corresponding to the sample query features, and the sample query features are obtained by extracting features of sample query elements in a sample query statement based on sample element types;

[0010] Based on the data query model, task information is generated, wherein the task information is used to execute the data query task.

[0011] According to a fifth aspect of an embodiment of the present specification, a model training platform is provided, including a request interface unit and a model unit; the request interface unit is used to receive a model training request, wherein the model training request includes request information; the model unit is used to obtain a data query model and multiple sample query statements based on the request information, wherein the sample query statements carry sample query results; structural analysis is performed on the multiple sample query statements to determine sample query elements respectively included in the multiple sample query statements and sample element types of the sample query elements; according to the sample element types, feature extraction is performed on the sample query elements to obtain sample query features corresponding to the multiple sample query statements; the multiple sample query features are input into the data query model to obtain predicted query results; according to the predicted query results and the sample query results, parameters of the data query model are adjusted to obtain a trained data query model.

[0012] According to a sixth aspect of an embodiment of the present specification, a data query device is provided, comprising: a first acquisition module, configured to acquire a query statement for a target database; a first determination module, configured to perform a structural analysis on the query statement, and determine the query elements in the query statement and the element types of the query elements; a first extraction module, configured to perform feature extraction on the query elements according to the element types, and obtain query features; and a first input module, configured to input the query features into a data query model, and obtain a data query result corresponding to the query statement, wherein the data query model is trained based on a plurality of sample query features and sample query results corresponding to the sample query features, and the sample query features are obtained by extracting features of sample query elements in the sample query statement based on the sample element types.

[0013] According to a seventh aspect of an embodiment of the present specification, a cardinality estimation device is provided, comprising: a first receiving module, configured to receive a cardinality estimation request for a target database, wherein the cardinality estimation request carries a query statement; a second determining module, configured to perform a structural analysis on the query statement, and determine the query elements in the query statement and the element types of the query elements; a second extraction module, configured to perform feature extraction on the query elements according to the element types, and obtain query features; and a second input module, configured to input the query features into a data query model, and obtain a cardinality estimation result, wherein the data query model is trained based on a plurality of sample query features and sample query results corresponding to the sample query features, and the sample query features are obtained by extracting features from sample query elements in the sample query statement based on the sample element types.

[0014] According to an eighth aspect of an embodiment of the present specification, a data query model training device is provided, comprising: a second acquisition module, configured to acquire multiple sample query statements, wherein the sample query statements carry sample query results; a third determination module, configured to perform structural analysis on the multiple sample query statements, and determine sample query elements respectively included in the multiple sample query statements and sample element types of the sample query elements; a third extraction module, configured to perform feature extraction on the sample query elements according to the sample element types, and obtain sample query features respectively corresponding to the multiple sample query statements; a third input module, configured to input the multiple sample query features into the data query model, and obtain predicted query results; an adjustment module, configured to perform parameter adjustment on the data query model according to the predicted query results and the sample query results, and obtain a trained data query model.

[0015] According to the ninth aspect of the embodiments of this specification, there is provided an information processing device based on a data query model, comprising: a second receiving module, configured to receive a task generation request, wherein the task generation request comprises request information; a third acquisition module, configured to acquire the data query model based on the request information, wherein the data query model is trained based on a plurality of sample query features and sample query results corresponding to the sample query features, and the sample query features are obtained by extracting features of sample query elements in a sample query statement based on the sample element type; and a generation module, configured to generate task information based on the data query model, wherein the task information is used to execute the data query task.

[0016] According to the tenth aspect of the embodiments of this specification, a computing device is provided, including: a memory and a processor; the memory is used to store computer programs / instructions, and the processor is used to execute the computer programs / instructions, and the computer program / instructions, when executed by the processor, implement the steps of the method provided in the first aspect, the second aspect, the third aspect, or the fourth aspect above.

[0017] According to the eleventh aspect of the embodiments of this specification, a computer-readable storage medium is provided, which stores a computer program / instruction, and when the computer program / instruction is executed by a processor, the steps of the method provided in the first aspect, the second aspect, the third aspect, or the fourth aspect are implemented.

[0018] According to the twelfth aspect of the embodiments of this specification, a computer program product is provided, including a computer program / instruction, which, when executed by a processor, implements the steps of the method provided in the first aspect, the second aspect, the third aspect, or the fourth aspect.

[0019] A data query method provided by an embodiment of the present specification includes: obtaining a query statement for a target database; performing structural analysis on the query statement to determine the query elements and element types of the query elements in the query statement; performing feature extraction on the query elements according to the element types to obtain query features; inputting the query features into a data query model to obtain a data query result corresponding to the query statement, wherein the data query model is trained based on a plurality of sample query features and sample query results corresponding to the sample query features, and the sample query features are obtained by extracting features of sample query elements in the sample query statement based on the sample element types. Since the query elements and element types are obtained by analyzing the general structure of the query statement, the generation method of the query features can be applied to query statements of different databases, so that the data query model can be used to implement data query across different databases, thereby improving the generalization ability of the data query model and reducing the resource overhead of the data query process. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] Figure 1 This is an architecture diagram of a data query system provided by an embodiment of this specification;

[0021] Figure 2 is an architecture diagram of another data query system provided by an embodiment of this specification;

[0022] Figure 3 is a flow chart of a data query method provided by an embodiment of this specification;

[0023] Figure 4 is a flow chart of a cardinality estimation method provided by one embodiment of this specification;

[0024] Figure 5 is a processing flow chart of a cardinality estimation method provided by an embodiment of this specification;

[0025] Figure 6 is a flow chart of a data query model training method provided by an embodiment of this specification;

[0026] Figure 7 is a flow chart of an information processing method based on a data query model provided by an embodiment of this specification;

[0027] Figure 8 It is a structural diagram of a model training platform provided by an embodiment of this specification;

[0028] Fig. 9 It is a structural schematic diagram of a data query device provided by an embodiment of this specification;

[0029] Fig.10is a structural schematic diagram of a cardinality estimation device provided by an embodiment of this specification;

[0030] Fig.11 It is a structural diagram of a data query model training device provided by an embodiment of this specification;

[0031] Fig.12 It is a structural schematic diagram of an information processing device based on a data query model provided by an embodiment of this specification;

[0032] Fig.13 It is a structural block diagram of a computing device provided by an embodiment of this specification. DETAILED DESCRIPTION

[0033] Many specific details are described in the following description to facilitate a full understanding of this specification. However, this specification can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of this specification, so this specification is not limited to the specific implementation disclosed below.

[0034] The terms used in one or more embodiments of this specification are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of this specification. The singular forms of "a", "said" and "the" used in one or more embodiments of this specification and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in one or more embodiments of this specification refers to and includes any or all possible combinations of one or more associated listed items.

[0035] It should be understood that although the terms first, second, etc. may be used to describe various information in one or more embodiments of this specification, this information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first may also be referred to as the second, and similarly, the second may also be referred to as the first. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".

[0036] In addition, it should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in one or more embodiments of this specification are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0037] In one or more embodiments of this specification, a large model refers to a deep learning model with large-scale model parameters, which usually contains hundreds of millions, tens of billions, hundreds of billions, trillions, or even more than 10 trillion model parameters. A large model can also be called a foundation model / foundation model (Foundation Model 1). The large model is pre-trained with large-scale unlabeled corpus to produce a pre-trained model with more than 100 million parameters. This model can adapt to a wide range of downstream tasks, and the model has good generalization ability, such as a large-scale language model (LLM, Large Language Model 1), a multi-modal pre-training model (multi-modal pre-training model 1), etc.

[0038] When the big model is used in practice, only a small number of samples are needed to fine-tune the pre-trained model and it can be applied to different tasks. The big model can be widely used in natural language processing (NLP), computer vision and other fields. Specifically, it can be applied to computer vision tasks such as visual question answering (VQA), image description (IC), image generation, as well as natural language processing tasks such as text-based sentiment classification, text summary generation, and machine translation. The main application scenarios of the big model include digital assistants, intelligent robots, search, online education, office software, e-commerce, intelligent design, etc.

[0039] First, the terms involved in one or more embodiments of this specification are explained.

[0040] Model: An abstract concept used to simulate and predict things in the real world. In the field of machine learning and artificial intelligence, models are used to handle various tasks such as classification, regression, and clustering.

[0041] Database: A system for storing and managing data. A database can support simultaneous access by multiple users and provide data security and consistency.

[0042] Attention mechanism: A technique used in natural language processing tasks that improves the performance and accuracy of the model by learning and analyzing key information in the input text.

[0043] Multi-table query: refers to the data query operation involving multiple tables in one query.

[0044] Cardinality estimation task: It refers to the problem of estimating the number of tuples returned after a given query is executed. This problem plays an important role in database design and optimization.

[0045] Generalization ability: refers to the performance of the model on data that has not been seen before. Generalization ability is an important indicator for evaluating model performance.

[0046] Query optimization: refers to optimizing the performance and efficiency of database queries. Query optimization can improve query response time and reduce resource consumption.

[0047] Query processing framework: A framework for processing queries and data. The query processing framework can improve query response time and performance and reduce resource consumption.

[0048] Feature representation: refers to the process of converting data into feature vectors that can be processed by machine learning algorithms. Feature representation can improve the performance and accuracy of the model.

[0049] Baseline estimation accuracy: refers to the model's baseline estimation accuracy, that is, the model's performance on unseen data. Baseline estimation accuracy is an important indicator for evaluating model performance.

[0050] Vector representation: refers to the process of converting data into vectors. Vector representation can be used in fields such as machine learning and data mining.

[0051] Database-specific encoding: refers to the encoding method used to process data in the database. Database-specific encoding can improve query response time and performance and reduce resource consumption.

[0052] Tuple: refers to a row of data in a relation (i.e., table). Each tuple represents a specific data instance or record in the table and contains a series of attribute values. In the representation of a two-dimensional table, a tuple corresponds to a row of the table, and each column represents an attribute. The value at each position in the tuple is the value of the attribute in the specific record.

[0053] SpaceSaving Summary: It is an efficient data stream algorithm, mainly used to estimate the frequency or probability distribution of elements in online data streams. The core idea is to maintain a small top heap of fixed size (usually a few to hundreds of elements), each heap element represents a candidate high-frequency item and its estimated number of times. When a new element arrives, if the element is already in the heap, its count is increased by one; if the heap is not full or the new element is not in the heap, and there is an element with the smallest count in the heap, then the count value of the element with the smallest count is assigned to the new element, and the original element is removed from the heap. In this way, the algorithm can dynamically track and update frequently occurring elements while retaining a certain estimation capability for non-frequent elements.

[0054] In this specification, a data query method is provided. This specification also involves a cardinality estimation method, a data query model training method, an information processing method based on a data query model, a model training platform, a data query device, a cardinality estimation device, a data query model training device, an information processing device based on a data query model, a computing device, a computer-readable storage medium and a computer program product, which are described in detail one by one in the following embodiments.

[0055] See also Figure 1 , Figure 1 The following is an architecture diagram of a data query system provided by an embodiment of the present specification. The data query system may include a client 100 and a server 200;

[0056] The client 100 is used to send a query statement for a target database to the server 200;

[0057] The server 200 is used to perform structural analysis on the query statement, determine the query elements in the query statement and the element types of the query elements; extract features of the query elements according to the element types to obtain query features; input the query features into a data query model to obtain a data query result corresponding to the query statement, wherein the data query model is trained based on a plurality of sample query features and sample query results corresponding to the sample query features, and the sample query features are obtained by extracting features of sample query elements in the sample query statement based on the sample element types; and send the data query result corresponding to the query statement to the client 100;

[0058] The client 100 is also used to receive the data query result corresponding to the query statement sent by the server 200.

[0059] By applying the scheme of the embodiments of this specification, since the query elements and element types are obtained by analyzing the general structure of the query statements, the method of generating query features can be applicable to query statements of different databases, and database-specific encoding can be implemented, so that data query across different databases can be implemented using the data query model, thereby improving the generalization ability of the data query model and reducing the resource overhead of the data query process.

[0060] See also Figure 2 , Figure 2 The architecture diagram of another data query system provided by an embodiment of the present specification is shown, and the data query system may include multiple clients 100 and a server 200. Multiple clients 100 may establish a communication connection through the server 200. In the data query scenario, the server 200 is used to provide data query services between multiple clients 100. Multiple clients 100 may respectively serve as a sender or a receiver, and realize communication through the server 200.

[0061] The user can interact with the server 200 through the client 100 to receive data sent by other clients 100, or send data to other clients 100, etc. In the data query scenario, the user can publish a data stream to the server 200 through the client 100, and the server 200 generates a data query result based on the data stream, and pushes the data query result to other clients that have established communication. Among them, the client 100 and the server 200 are connected through a network. The network provides a medium for the communication link between the client 100 and the server 200. The network can include various connection types, such as wired, wireless communication links or optical fiber cables, etc. The data transmitted by the client 100 may need to be encoded, transcoded, compressed, etc. before being published to the server 200.

[0062] The client 100 can be a browser, an APP (Application), or a web application such as an H5 (HyperText Markup Language 5, Hypertext Markup Language Version 5) application, or a light application (also known as a mini-program, a lightweight application) or a cloud application, etc. The client 100 can be based on the software development kit (SDK, Software Development Kit) of the corresponding service provided by the server 200, such as based on the real-time communication (RTC, Real Time Communication) SDK development and acquisition. The client 100 can be deployed in an electronic device, and needs to rely on the device to run or some APPs in the device to run. For example, the electronic device can have a display screen and support information browsing, such as a personal mobile terminal such as a mobile phone, a tablet computer, a personal computer, etc. Various other types of applications can also be configured in the electronic device, such as human-computer dialogue applications, model training applications, text processing applications, web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.

[0063] The server 200 may include servers that provide various services, such as servers that provide communication services to multiple clients, servers for background training that provide support for models used on clients, and servers that process data sent by clients. It should be noted that the server 200 can be implemented as a distributed server cluster consisting of multiple servers, or as a single server. The server can also be a server of a distributed system, or a server combined with a blockchain. The server can also be a cloud server for basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content distribution networks (CDN, Content De l ivery Network), and big data and artificial intelligence platforms, or an intelligent cloud computing server or intelligent cloud host with artificial intelligence technology.

[0064] It is worth noting that the data query method provided in the embodiments of this specification is generally executed by the server, but in other embodiments of this specification, the client may also have similar functions to the server, thereby executing the data query method provided in the embodiments of this specification. In other embodiments, the data query method provided in the embodiments of this specification may also be executed jointly by the client and the server.

[0065] See also Figure 3 , Figure 3 A flowchart of a data query method provided by an embodiment of the present specification is shown, which specifically includes the following steps:

[0066] Step 302: Obtain a query statement for the target database.

[0067] In one or more embodiments of the present specification, the server responds to a query statement sent by the client for a target database, queries the target database based on the query statement, and obtains a data query result corresponding to the query statement.

[0068] Specifically, the target database can be a database of different types, such as a relational database and a non-relational database. The target database may include multiple data sets, which are also called data tables. In this case, the query statement for the target database can be called a multi-table query statement. The query statement is a statement constructed based on the Structured Query Language (SQL). The query statement expresses the database query intention and corresponds to different database query tasks, such as data query tasks and cardinality estimation tasks. The query statement includes query elements of different element types, and the element types include but are not limited to value element types and connection element types. The value element type includes query elements including but not limited to attributes of the value element type, connection conditions of the connection element type, and filtering conditions of the filter element type, wherein the attributes can be understood as query predicates, and the filtering conditions can be understood as filtering predicates. The connection conditions are responsible for the association logic between data tables, and the predicates and filtering conditions are used to further limit the rows included in the output results.

[0069] Exemplarily, the query statement for the target database is a multi-table query statement for the cardinality estimation task, specifically "SELECT COUNT(*)FROM A,B,C WHERE A.id=B.pid and B.pid=Cu id and A.age<=22and B.gender='fema le'and C.gpa>3.5". The database query intention expressed by this query statement is "jointly filter records from the three tables A, B and C of the target database, and calculate the total number of records that meet the specific condition [girls who are not older than 22 years old and have a score greater than 3.5]". The attributes in the query statement are "A.id, B.pid, Cu id, A.age, B.gender, C.gpa", the connection condition is "A.id=B.pid, B.pid=Cu id", and the filtering condition is "A.age<=22, B.gender='fema le', C.gpa>3.5".

[0070] In practical applications, there are many ways to obtain query statements for the target database, which are selected according to actual conditions, and the embodiments of this specification do not limit this. In one possible implementation of this specification, a query statement for the target database sent by a user through a client can be received. In another possible implementation of this specification, a query statement for the target database can be read from other data acquisition devices.

[0071] Step 304: Perform structural analysis on the query statement to determine the query elements and element types of the query elements in the query statement.

[0072] In one or more embodiments of the present specification, after obtaining a query statement for a target database, further structural analysis may be performed on the query statement to determine query elements in the query statement and element types of the query elements.

[0073] Specifically, a query element is a component of a query statement, and multiple query elements together constitute a query statement.

[0074] In actual applications, there are many ways to perform structural analysis on query statements and determine the query elements and element types of query elements in the query statements. The specific selection is based on the actual situation, and the embodiments of this specification do not impose any restrictions on this. In one possible implementation of this specification, the keywords in the query statement can be identified, and the query elements and element types of the query elements can be determined based on the keyword identification results. For example, the content after the keyword "WHERE" is usually an attribute. In another possible implementation of this specification, the query statement can be sent to the client, and the query elements and element types of the query elements manually determined by the user through structural analysis of the query statement are received.

[0075] Step 306: Extract features of the query element according to the element type to obtain query features.

[0076] In one or more embodiments of the present specification, a query statement for a target database is obtained; after performing a structural analysis on the query statement to determine the query elements in the query statement and the element types of the query elements, further, feature extraction can be performed on the query elements according to the element types to obtain query features.

[0077] Specifically, feature extraction refers to learning feature representations or vector representations that can capture semantic information from query elements through neural networks, matrix decomposition, or other machine learning methods.

[0078] In an optional embodiment of the present specification, the query element includes an attribute, and the query feature includes an attribute distribution feature; the above-mentioned feature extraction of the query element according to the element type to obtain the query feature may include the following steps:

[0079] In the case where the query element is determined to be an attribute according to the element type, determining the value type of the attribute;

[0080] According to the value type, determine the value information of the attribute;

[0081] Perform feature extraction on value information to obtain attribute distribution characteristics.

[0082] Specifically, when the element type is a value element type, the query element is determined to be an attribute. The value type can be divided into a numerical type and a classification type. The numerical type refers to a value type whose corresponding attribute is a numerical value, such as "A.age, C.gpa", and the classification type refers to a value type whose corresponding attribute is a classification, such as "B.gender".

[0083] In practical applications, when determining the value information of an attribute according to the value type, in one possible implementation of this specification, the histogram information of the attribute can be determined as the value information of the attribute of each value type. In another possible implementation of this specification, since the histogram of the attribute of the classification type cannot reflect the characteristics of the attribute well, the SpaceSaving Summary method can be used to determine the value information of the attribute. It should be noted that when performing feature extraction on the value information, the value information can be input into the embedding layer (Embedding Layer) of the data query model to obtain the attribute distribution characteristics output by the embedding layer.

[0084] By applying the solution of the embodiments of this specification, the attribute distribution characteristics of the attribute are determined through value information, thereby realizing feature extraction based on data characteristics and ensuring the accuracy of the attribute distribution characteristics.

[0085] In an optional embodiment of the present specification, the value type includes a numerical type and a classification type; and the above-mentioned determining the value information of the attribute according to the value type may include the following steps:

[0086] In the case where the value type is a numerical type, determining the first value information according to a histogram of the attribute;

[0087] In the case where the value type is a classification type, the second value information is determined according to the frequency of the attribute.

[0088] Specifically, the histogram is used to estimate the value distribution of the attributes (columns) involved in the query in order to generate a more efficient query execution plan. When an attribute (column) participates in a join condition or attribute, the histogram established on the attribute can be used to optimize the query.

[0089] It should be noted that the first value information determined according to the histogram of the attribute is the histogram distribution information of the attribute, and the first value information is further subjected to feature extraction, and the attribute distribution feature obtained is the histogram distribution feature. The first value information determined according to the frequency of the attribute is the frequency distribution information of the attribute, and the first value information is further subjected to feature extraction, and the attribute distribution feature obtained is the frequency distribution feature. By applying the scheme of the embodiment of this specification, feature extraction is performed according to the characteristics of attributes of different value types, thereby ensuring the accuracy of the attribute distribution feature. It is worth noting that after feature extraction is performed on the value information to obtain the attribute distribution feature, the attribute distribution feature can be normalized to the range of [0,1].

[0090] In an optional embodiment of the present specification, the query element includes a connection condition, and the query feature includes a connection distribution feature; the above-mentioned feature extraction of the query element according to the element type to obtain the query feature may include the following steps:

[0091] In the case where the query element is determined as a connection condition according to the element type, determining the multiple data sets connected by the connection condition and the number of connection data respectively included in the multiple data sets, wherein the connection data is the data in the data sets that meets the connection condition;

[0092] Determine the data association relationship between multiple data sets according to the number of connected data;

[0093] Extract features from data associations to obtain connection distribution features.

[0094] It should be noted that when the element type is a connection element type, the query element is determined as a connection condition. The data set is a data table in a database. The scaling factor distribution between data sets can be determined based on the data association relationship, and the scaling factor distribution can be encoded as a histogram feature. Therefore, when extracting features from the data association relationship, the scaling factor distribution can be extracted, and the obtained connection distribution feature can be called a scaling factor distribution feature.

[0095] For example, assuming that the connection condition is "A.id=B.pid", it can be determined that the data sets connected by the connection condition are data table A and data table B. Assuming that the number of connection data included in data table A is 1 and the number of connection data included in data table B is 5, the number 5 can be determined as the scaling factor distribution between data table A and data table B.

[0096] By applying the solution of the embodiments of this specification, the data association relationship between multiple data sets is determined according to the number of connected data; features of the data association relationship are extracted to obtain connection distribution features, thereby capturing the association relationship between the data sets and helping the data query model to perform data query based on the association relationship between the data sets.

[0097] In an optional embodiment of the present specification, the query element includes a filtering condition, and the query feature includes a filtering distribution feature; the above-mentioned feature extraction of the query element according to the element type to obtain the query feature may include the following steps:

[0098] When the query element is determined as a filtering condition according to the element type, a filtering range of the filtering condition is determined, and a proportion of data in the target database that meets the filtering condition is determined;

[0099] Feature extraction is performed on the filter range and data ratio to obtain the filter distribution characteristics.

[0100] Specifically, the numerical range can be determined based on the upper and lower limits of the numerical values ​​in the filtering condition, and the numerical range can be determined as the filtering range, for example, the filtering range of the filtering condition "A.age<=22" is "0,22". The proportion of data that meets the filtering condition refers to the proportion of data that meets the filtering condition to all data in the data set.

[0101] It should be noted that when extracting features of the filtering range and data ratio, the filtering range and data ratio can be input into the Embedding Layer to obtain the filtering distribution features output by the Embedding Layer.

[0102] By applying the solution of the embodiments of this specification, feature extraction is performed on the filter range and data ratio to obtain filter distribution features, thereby realizing feature extraction based on the value characteristics and selection characteristics of the filter conditions, and improving the accuracy of the filter distribution features.

[0103] In an optional embodiment of the present specification, the filtering condition includes a numerical filtering condition and a classification filtering condition; the above-mentioned determination of the filtering range of the filtering condition may include the following steps:

[0104] When the filtering condition is a numerical filtering condition, determining a first filtering range of the filtering condition according to a numerical range of the numerical filtering condition;

[0105] When the filtering condition is a classification filtering condition, the second filtering range of the filtering condition is determined according to the classification identifier of the classification filtering condition.

[0106] Specifically, a numerical filtering condition refers to a condition for filtering based on numerical values, such as “A.age<=22, C.gpa>3.5”. A categorical filtering condition refers to a condition for filtering based on categories, such as “B.gender='female'”.

[0107] In practice, the filter range of a numeric filter condition is represented by its lower and upper bounds. For categorical filter conditions, the bin index (category ID) corresponding to the categorical filter condition is used as the filter range. In the case of an equivalent query, where the predicate is an equality, the lower and upper bounds are set to the same value. Optionally, the filter range can be normalized to the range [0,1] in order to standardize across the scales of different attributes.

[0108] By applying the scheme of the embodiments of this specification, when the filtering condition is a numerical filtering condition, the first filtering range of the filtering condition is determined according to the numerical interval of the numerical filtering condition; when the filtering condition is a classification filtering condition, the second filtering range of the filtering condition is determined according to the classification identifier of the classification filtering condition, thereby improving the accuracy of the filtering range.

[0109] In an optional embodiment of the present specification, the query element includes a data set, and the query feature includes a data set feature; the above-mentioned feature extraction of the query element according to the element type to obtain the query feature may include the following steps:

[0110] In the case where it is determined according to the element type that the query element is a data set, determining set information of the data set;

[0111] Perform feature extraction on the collection information to obtain data collection features.

[0112] It should be noted that when the element type is a set element type, the query element is determined to be a data set, which is a data table in a database.

[0113] For example, assuming that the query statement is "SELECT COUNT(*) FROM A, B, C WHERE A.id=B.pidand B.pid=Cu id and A.age<=22and B.gender='female'and C.gpa>3.5", the query set is data table A, data table B and data table C.

[0114] By applying the scheme of the embodiments of this specification, when the query element is determined to be a data set according to the element type, the collection information of the data set is determined; feature extraction is performed on the collection information to obtain data set features, thereby capturing the query features at the table level (table-level), making the query features more comprehensive and accurate.

[0115] Step 308: Input the query features into the data query model to obtain the data query results corresponding to the query statement, wherein the data query model is trained based on multiple sample query features and the sample query results corresponding to the sample query features, and the sample query features are obtained by extracting features of sample query elements in the sample query statement based on the sample element type.

[0116] In one or more embodiments of the present specification, a query statement for a target database is obtained; a structural analysis is performed on the query statement to determine the query elements in the query statement and the element types of the query elements; and based on the element types, features are extracted from the query elements. After the query features are obtained, the query features can be further input into a data query model to obtain data query results corresponding to the query statement.

[0117] Specifically, the data query model is a neural network model based on the attention mechanism, which can be applied to any database and implement data query, such as cardinality estimation query. The data query model can be trained using only part of the collectible database data and expanded on unseen databases. The data query model can also be further tuned on a specific database to achieve personalized customization of the interaction mode based on the specific database and improve the baseline estimation accuracy of the model.

[0118] By applying the scheme of the embodiments of this specification, since the query elements and element types are obtained by analyzing the general structure of the query statements, the method of generating query features can be applicable to query statements of different databases, so that data query across different databases can be realized by using the data query model, thereby improving the generalization ability of the data query model and reducing the resource overhead of the data query process.

[0119] In an optional embodiment of the present specification, the query feature includes a first query feature and a second query feature, and the data query model includes a first attention unit, a second attention unit, and a processing unit; the above-mentioned inputting the query feature into the data query model to obtain the data query result corresponding to the query statement may include the following steps:

[0120] Inputting the initial integrated feature and the first query feature into the first attention unit, obtaining an intermediate integrated feature and an updated first query feature, wherein the first query feature is obtained based on the attribute distribution feature and the connection distribution feature, and the intermediate integrated feature is used to characterize the correlation relationship between the connection distribution features;

[0121] Inputting the intermediate integrated feature, the updated first query feature and the second query feature into the second attention unit to obtain the target integrated feature, wherein the second query feature is obtained based on the attribute distribution feature, the filter distribution feature and the data set feature, and the target integrated feature is used to characterize the correlation relationship between the connection distribution feature and the filter distribution feature;

[0122] The query information and target integration features of the query statement are input into the processing unit to obtain the data query result.

[0123] Specifically, the initial integrated feature refers to the embedding vector obtained by converting the query token obtained by random initialization through the embedding layer. The query token is similar to the CLS token in natural language processing or the virtual node in the graph neural network (GNN). The query token is used to integrate the comprehensive representation of the features in the learning process as a key component of synthesizing query-level insights. The first attention unit and the second attention unit are self-attention models. The self-attention model includes a normalization layer, a multi-attention layer and a feedforward network layer. The processing unit is a multi-layer perceptron (MLP), which belongs to a feedforward neural network. It consists of an input layer, one or more hidden layers and an output layer, and the neurons in each layer are fully connected. It should be noted that the attribute distribution feature and the connection distribution feature can be combined to obtain the first query feature. The attribute distribution feature and the filter distribution feature are combined to obtain the fusion feature, and the fusion feature and the data set feature are combined to obtain the second query feature.

[0124] By applying the solution of the embodiments of this specification, since the data query model is a neural network model based on the attention mechanism, it can be applied to any database and implement data query. Therefore, the query processing framework based on the data query model can be used to implement data query across different databases to achieve query optimization.

[0125] In an optional embodiment of the present specification, before inputting the query information and target integration features of the query statement into the processing unit and obtaining the data query result, the following steps may also be included:

[0126] Perform structural analysis on the query statement to determine the number of filter conditions and connection conditions in the query statement;

[0127] The query information of the query statement is determined according to the initial query information and the number of conditions.

[0128] It should be noted that query information refers to query-level information of a query statement, including but not limited to the number of conditions of filter conditions and join conditions and initial query information. Initial query information refers to the query cardinality estimated based on traditional methods (such as histogram-based methods). By applying the solution of the embodiments of this specification, more guidance can be provided to the model through query information to distinguish different queries and produce better results.

[0129] In an optional embodiment of the present specification, after inputting the query feature into the data query model and obtaining the data query result corresponding to the query statement, the following steps may also be included:

[0130] Send data query results to the client;

[0131] Receive result feedback information sent by the client, wherein the result feedback information is information providing feedback on the data query result;

[0132] Based on the feedback information from the results, build a model to optimize the data;

[0133] Use the model to optimize data and adjust parameters of the data query model.

[0134] Specifically, the result feedback information can be information that provides feedback on the content, quality, and completeness of the data query results, reflecting the user's true feelings and expectations about the data query results. The result feedback information includes but is not limited to result quality evaluation information, corrected and accurate data query results, and model optimization areas. Model optimization data refers to accurate optimized sample query statements used to optimize the data query model.

[0135] In practical applications, there are many ways to construct model optimization data based on the result feedback information, which are selected according to the actual situation. The embodiments of this specification do not limit this. In one possible implementation of this specification, the model optimization data can be automatically constructed directly based on the result feedback information. In another possible implementation of this specification, optimization prompt information can be generated based on the result feedback information, and the model optimization data sent by the client based on the optimization prompt information can be received.

[0136] It should be noted that, taking the construction of model optimization data directly based on the result feedback information as an example, if the result feedback information is a corrected and accurate data query result, the model optimization data can be constructed based on the query statement of the data query task and the corrected and accurate data query result. If the result feedback information is the optimization field of the model, such as the XXX field, a sample query statement in the XXX field can be obtained, and the sample query statement in the XXX field can be determined as the model optimization data. Among them, the process of adjusting the parameters of the data query model using the model optimization data can be supervised fine-tuning (SFT, Supervised Fine-Tun ing), and the specific reference can be made to the training process of the data query model, and the embodiments of this specification will not be repeated.

[0137] By applying the solution of the embodiments of this specification, the performance of the data query model is continuously optimized by collecting and utilizing result feedback information to more accurately meet the actual needs of users and improve the quality and accuracy of the final data query results.

[0138] In an optional embodiment of the present specification, the above-mentioned construction of model optimization data according to the result feedback information may include the following steps:

[0139] Generate optimization prompt information according to the result feedback information, wherein the optimization prompt information is used to guide the client to send model optimization data for optimizing the data query model;

[0140] The optimization prompt information is sent to the client, and the model optimization data sent by the client based on the optimization prompt information is received.

[0141] It should be noted that there are multiple ways to generate optimization prompt information based on the result feedback information, and the specific selection is based on the actual situation. The embodiments of this specification do not impose any restrictions on this. In one possible implementation method of this specification, the preset prompt information can be directly obtained, and the result feedback information can be added to the preset prompt information to obtain the optimization prompt information, such as the preset prompt information is "I am very sorry for giving you inaccurate information. Please point out the specific inaccuracy or provide the correct results of the relevant questions. I will correct and optimize my answers as soon as possible to better serve you." If the result feedback information is "the result is inaccurate", the optimization prompt information is "For the problem of inaccurate results you reported, I am very sorry for giving you inaccurate information. Please point out the specific inaccuracy or provide the correct results of the relevant questions. I will correct and optimize my answers as soon as possible to better serve you." In another possible implementation method of this specification, the result feedback information can be type identified to determine the information type of the result feedback information, and the information type can be further matched with the prompt type of each prompt information in the prompt information library, and the prompt information with the same prompt type as the information type is determined as the optimization prompt information.

[0142] By applying the solution of the embodiments of this specification, model optimization data is obtained through an interactive guidance method, which improves the interactivity with users and further improves user satisfaction.

[0143] In an optional embodiment of the present specification, a training method of a data query model is described. That is, before inputting the query features into the data query model and obtaining the data query results corresponding to the query statement, the following steps may be further included:

[0144] Obtaining multiple sample query statements, wherein the sample query statements carry sample query results;

[0145] Performing structural analysis on the multiple sample query statements to determine sample query elements and sample element types of the sample query elements respectively included in the multiple sample query statements;

[0146] According to the sample element type, feature extraction is performed on the sample query element to obtain sample query features corresponding to the multiple sample query statements respectively;

[0147] Input multiple sample query features into the data query model to obtain predicted query results;

[0148] According to the predicted query results and sample query results, the parameters of the data query model are adjusted to obtain a trained data query model.

[0149] Specifically, the sample query statement can be a query statement for the same database or a query statement for different databases. The sample query result refers to the actual query result corresponding to the sample query statement. The sample query result is the prediction target of the data query model and is used to evaluate the accuracy of the data query model. By comparing the predicted query result and the sample query result, it can be determined whether the current data query model has been trained.

[0150] It should be noted that there are multiple ways to obtain multiple sample query statements. In one possible implementation of this specification, sample query statements carrying sample query results can be read from other data acquisition devices or databases. In another possible implementation of this specification, multiple sample query statements carrying sample query results sent by users can be received. The implementation method of "structurally analyzing multiple sample query statements to determine the sample query elements and sample element types of the sample query elements respectively included in the multiple sample query statements; extracting features of the sample query elements according to the sample element types to obtain sample query features corresponding to the multiple sample query statements; inputting the multiple sample query features into the data query model to obtain predicted query results" is the same as the implementation method of "structurally analyzing the query statements to determine the query elements and element types of the query elements in the query statements; extracting features of the query elements according to the element types to obtain query features; inputting the query features into the data query model to obtain data query results corresponding to the query statements", and this specification will not repeat them.

[0151] In practical applications, when adjusting the parameters of the data query model according to the predicted query results and the sample query results, the loss value can be calculated according to the predicted query results and the sample query results, and the model parameters of the data query model can be adjusted according to the loss value until the training process meets the preset stop conditions, and the trained data query model is obtained. Among them, there are many functions for calculating the loss value, such as the cross entropy loss function, the L1 norm loss function, the maximum loss function, the mean square error loss function, the logarithmic loss function, etc., which are selected according to the actual situation, and the embodiments of this specification do not make any restrictions on this. The preset stop conditions include but are not limited to the loss value being less than or equal to the preset threshold and the number of iterations reaching the preset number of iterations, wherein the preset threshold and the preset number of iterations are selected according to the actual situation, and the embodiments of this specification do not make any restrictions on this.

[0152] In a possible implementation of the present specification, after calculating the loss value, the loss value is compared with a preset threshold. Specifically, if the loss value is greater than the preset threshold, it means that the difference between the predicted query result and the sample query result is large, and the prediction ability of the data query model is poor. At this time, the model parameters of the data query model can be adjusted, and the step of inputting multiple sample query features into the data query model to obtain the predicted query result is returned to continue training the data query model until the loss value is less than or equal to the preset threshold, indicating that the difference between the predicted query result and the sample query result is small, and the preset stop condition is met, and the trained data query model is obtained.

[0153] In another possible implementation of the present specification, in addition to comparing the size relationship between the loss value and the preset threshold, the number of iterations can also be combined to determine whether the current data query model has been trained. Specifically, if the loss value is greater than the preset threshold, the model parameters of the data query model are adjusted, and the step of inputting multiple sample query features into the data query model to obtain the predicted query result is returned, and the data query model is continued to be trained until the preset number of iterations is reached, and the iteration is stopped to obtain a trained data query model.

[0154] By applying the solution of the embodiments of the present specification, the model parameters of the data query model are continuously adjusted, so that the final data query model can be made more accurate. In addition, since the sample query elements and sample element types are obtained by analyzing the general structure of the sample query statements, the method of generating sample query features can be applicable to sample query statements of different databases, thereby improving the generalization ability of the data query model.

[0155] The following combination Figure 4 , taking the application of the data query method provided in this specification in the cardinality estimation task scenario as an example, the data query method is further explained. Figure 4 A flowchart of a cardinality estimation method provided by an embodiment of this specification is shown, which specifically includes the following steps:

[0156] Step 402: Receive a cardinality estimation request for a target database, wherein the cardinality estimation request carries a query statement.

[0157] Step 404: Perform structural analysis on the query statement to determine the query elements and element types of the query elements in the query statement.

[0158] Step 406: Extract features of the query element according to the element type to obtain query features.

[0159] Step 408: Input the query features into the data query model to obtain a cardinality estimation result, wherein the data query model is trained based on multiple sample query features and sample query results corresponding to the sample query features, and the sample query features are obtained by extracting features of sample query elements in the sample query statement based on the sample element type.

[0160] Specifically, cardinality estimation tasks are common in various application scenarios, such as analyzing the number of unique visitors to a web page, evaluating the number of records involved in a database query, or counting the number of unique Internet Protocol (IP) addresses in network traffic. Through cardinality estimation, query execution plans can be planned more effectively, storage can be optimized, and the efficiency of data analysis can be improved.

[0161] It should be noted that the implementation of steps 402 to 408 may refer to the implementation of steps 302 to 308 described above, and will not be described in detail in this embodiment of the specification.

[0162] By applying the solution of the embodiments of this specification, a universal cardinality estimation method based on the attention mechanism is proposed, which realizes cardinality estimation across different databases by utilizing a data query model with high generalization ability, thereby reducing the resource overhead of the cardinality estimation process.

[0163] See also Figure 5 , Figure 5 A processing flow chart of a cardinality estimation method provided by an embodiment of the present specification is shown. During the cardinality estimation process, a data query model can be used for processing. The data query model includes a feature extraction unit, a first attention unit, a second attention unit and a processing unit. The first attention unit includes M attention sub-units consisting of a first multi-head self-attention layer, a first feedforward network layer and two first normalization layers. The second attention unit includes N attention sub-units consisting of a second multi-head self-attention layer, a second feedforward network layer and two second normalization layers. The data query model can apply multiple low-dimensional space features to each query element in the query statement, and then learn to simulate the cardinality estimation process and compress the features of the low-dimensional space as learning parameters, specifically including:

[0164] Feature extraction unit: For the SQL query statement Q sent by the user for the target database D, Q is input into the feature extraction unit. The feature extraction unit can perform structural analysis on the query statement to determine the query elements and element types in the query statement; according to the element type, the query elements (filter conditions, connection conditions, attributes and data tables) are feature extracted to obtain query features. Among them, query features include attribute distribution features, connection distribution features, filter distribution features and data table features. About attribute distribution features: For the value distribution Pr(A i,j), that is, the attribute distribution features (histogram vectors) that appear in the join conditions or predicates of Q, where A represents the attribute set of all data tables, i represents the i-th data table, and j represents the j-th attribute of the data table, also generally referred to as the j-th column. These histogram vectors are regarded as basic tokens for model processing. They are similar to word embeddings in NLP models and can be combined with learned parameters to recover the high-level joint density function (PDF, Probability Density Function) Pr(T Q ), where T Q Represents the table obtained by connecting all data tables in Q through the connection conditions. For categorical attributes, SpaceSaving Summary is used to maintain the distribution, ensure the estimation of error bounds and support real-time updates. In order to eliminate the difference in the range between attributes, each histogram vector is normalized to the range of [0,1]. About the connection distribution characteristics: Each connection condition T in Q i .A i,x =T j .A j,y The scaling factor distribution of i Indicates data table i, T j represents data table j. Let s be table T i The scaling factor of s refers to the table T j The number of tuples t that can be connected to s, that is, s[A i,x ]=t[A j,y ]. The scaling factor distributions are also encoded as histogram vectors. Because they capture the correlation information between tables, they can help the model learn how to transform Pr(T i ) combination is scaled to Pr(T Q ). About the filter distribution feature: The feature of each filter condition in Q encodes the following two information to obtain the filter distribution feature of the filter condition: The first, for numerical filter conditions, is represented by the lower and upper limits of the filter value. For categorical filter conditions, the bin index corresponding to the value is used as the range. The second, selectivity, is calculated as i,j The number of tuples that meet the filter condition is related to T i The ratio of all tuples in Q. This helps to calculate Pr(Q) from the joint PDF. About table features: The feature extraction unit can also generate table features (table-level features) for all tables in Q. For each table T in Q i, can encode simplified single-table selectivity estimates generated by heuristic estimation algorithms, including but not limited to Approximate Value Independence (AVI), Minimum Selectivity (MinSe l), and Extended Bayesian Optimization (EBO). At the same time, it is also possible to encode each table T i Size |T i | is encoded to represent the size of the table. It is worth noting that the total cost of obtaining all the above features is O(∑ i |T i |), therefore, the data query model is as convenient and cheap as the efficient traditional histogram-based method in feature construction.

[0165] It is worth noting that the data query model may also include a linear layer for generating the first query feature and the second query feature. Specifically, if A i,j Appearing in the join condition, it combines its value distribution and scaling factor distribution vector into an embedding vector, that is, combining the attribute distribution feature and the connection distribution feature to obtain the first query feature L i,j ; if A i,j Appears in the filter condition of Q, the linear model combines its value distribution, filter range and selectivity with the data table information to output an embedding vector, that is, combining the attribute distribution feature and the filter distribution feature to obtain the fusion feature P i,j , the fusion feature P i,j and data table feature K i The second query feature is obtained by combining. It is worth noting that the linear parameters of the same type of features are shared. In addition, a query token is randomly initialized, and the query token is converted into the initial integrated feature R in the feature extraction unit. Among them, the dimensions of L, P, R and K are uniformly fixed to ensure the uniformity of different types of embeddings.

[0166] First attention unit: The process of the first attention unit using the attention mechanism to process features can be regarded as the scaling stage. Specifically, in the scaling stage, R and L i,j Enter the first attention unit. The first attention unit converts R and L i,j Converted into intermediate integrated features R' and updated first query features L' i,j Each L' i,j YesL i,j and all other vectors L i',j' The input vector L is a weighted sum of i',j' To the output vector L' i,jEach pair of weights, i.e., the attention coefficients, is determined by the learned parameters. Similarly, R' is the sum of all L i,j The first attention unit can dynamically adjust the focus of the attention mechanism according to the query structure, so as to skillfully handle queries with various numbers of connected attributes. With this attention, the output vector R' can capture the correlation between the distributions of scaling factors for different connections in Q, which reflects how scaling factors are combined when multiple tables are connected. With this knowledge, the model can know how to combine the low-level joint PDF Pr(T i ) scaled to the advanced joint PDF Pr(T on the connection table Q ). In addition, each L' i,j They are all engineered to take into account the impact of other attribute distributions during the concatenation process. This process helps to obtain a new representation for each attribute, which is then refined into Pr(T Q ).

[0167] Second attention unit: The process of feature processing by the second attention unit using the attention mechanism can be regarded as the filtering stage. Specifically, in the filtering stage, the focus turns to obtaining Pr(T Q ) and calculate the probability Pr(Q). Each P i,j Both attributes A are compressed i,j The value distribution and filtering information on it. Let U = {P i,j}∪{L' i',j'}∪{R'}∪{K i} for all P i,j , L' i,j , K i and R'. Apply an attention mechanism between all vectors in U. Similarly, for each pair of vectors u,v in U, use the same learning parameters to calculate an attention coefficient as a weight. Then for each u in U, use the weighted sum of all vectors to obtain the embedding vector u'. This operation not only combines the weights encoded in L' in multiple tables, but also i,j The scaling information in Q also integrates the value distribution of all attributes in Q, such as P i,j This comprehensive fusion effectively captures the Pr(T Q ) details. In addition, the vector u' will filter the predicate information and Pr(T Q ) integration, providing a new filtered representation. The target integrated feature R" formed in this stage encapsulates all relevant connection conditions and filtering condition information, thereby providing a newer and richer representation for queries. Therefore, the data query model integrates detailed attribute interaction information and filtering information, achieving Q ) is calculated to obtain Pr(Q).

[0168] Processing unit: Finally, the query information and target integration feature R" of the query statement are input into the processing unit to obtain the cardinality estimation result.

[0169] The solution of the embodiments of this specification is applied to realize data query across different databases by providing features such as a general framework, a common model, a general data representation and a high degree of portability. The specific steps to realize these features include database query parsing, feature extraction, model training and use, etc., which improves the generalization ability of the data query model and reduces the resource overhead of the data query process.

[0170] See also Figure 6 , Figure 6 A flowchart of a data query model training method provided by an embodiment of the present specification is shown, which specifically includes the following steps:

[0171] Step 602: Acquire multiple sample query statements, where the sample query statements carry sample query results.

[0172] Step 604: Perform structural analysis on the multiple sample query statements to determine sample query elements and sample element types of the sample query elements respectively included in the multiple sample query statements.

[0173] Step 606: extract features of the sample query elements according to the sample element types, and obtain sample query features corresponding to the multiple sample query statements.

[0174] Step 608: Input multiple sample query features into the data query model to obtain predicted query results.

[0175] Step 610: According to the predicted query results and the sample query results, the parameters of the data query model are adjusted to obtain a trained data query model.

[0176] It should be noted that the implementation method of step 602 to step 610 can refer to the training method of the above-mentioned data query model, and will not be described in detail in the embodiment of this specification.

[0177] In actual applications, after obtaining the trained data query model, the model parameters of the trained data query model can be sent to the client. The client can build the data query model locally based on the model parameters and use the data query model to perform task processing.

[0178] By applying the solution of the embodiments of the present specification, the model parameters of the data query model are continuously adjusted, so that the final data query model can be made more accurate. In addition, since the sample query elements and sample element types are obtained by analyzing the general structure of the sample query statements, the method of generating sample query features can be applicable to sample query statements of different databases, thereby improving the generalization ability of the data query model.

[0179] See also Figure 7 , Figure 7 A flowchart of an information processing method based on a data query model provided by an embodiment of the present specification is shown, which specifically includes the following steps:

[0180] Step 702: Receive a task generation request, wherein the task generation request includes request information.

[0181] Specifically, the information processing method based on the data query model can be applied to a terminal device or to a model training platform. The task generation request is used to request the task information for generating a data query task. The task generation request usually includes the task type, the expected output format, and the request information. For example, when a user selects the "cardinality estimation" function on the front-end interface of the model training platform and uploads a query statement, a task generation request can be constructed, which includes the query statement, the task type (i.e., cardinality estimation), related information of the query statement, and the like. The request information refers to the parameters or descriptive information related to the data query task carried in the task generation request. The request information includes, but is not limited to, the task scenario identifier of the data query task, the task model identifier, or the model training data of the data query task (multiple sample query statements carrying sample query results).

[0182] Step 704: Based on the request information, a data query model is obtained, wherein the data query model is trained based on multiple sample query features and sample query results corresponding to the sample query features, and the sample query features are obtained by extracting features of sample query elements in the sample query statement based on the sample element type.

[0183] In actual applications, there are multiple ways to obtain a data query model based on request information, and the specific method is selected according to the actual situation. The embodiments of this specification do not impose any limitation on this.

[0184] In an optional embodiment of the present specification, the obtaining of the data query model based on the request information may include the following steps:

[0185] Based on the task scenario identifier, determine a target scenario template from a plurality of preset scenario templates, and based on the target scenario template, search for a data query model from a model library, wherein the model library stores a plurality of deep learning models, and the request information includes a task scenario identifier of the data query task; or,

[0186] Based on the task model identifier, the data query model is searched from the model library, wherein the request information includes the task model identifier of the data query task.

[0187] Specifically, the task scenario identifier refers to a unique or specific label used to distinguish different task application scenarios. In the embodiment of this specification, the task scenario identifier is part of the request information. Through the task scenario identifier, a target scene template that matches the request information can be selected from a series of preset scene templates to generate task information. For example, the task scenario identifier is "cardinality estimation", which means that the client wants to use the query statement to perform a cardinality estimation task, then the cardinality estimation scene template can be selected from multiple preset scene templates according to the task scenario identifier.

[0188] The preset scenario templates are predefined standard configuration scenario templates for different task application scenarios. Each template contains model information and task processing flow that match the task application scenario. Through a series of preset scenario templates, task generation requests for different scenarios can be quickly responded to. Different preset scenario templates correspond to different task types, model information, and processing flows. For example, there may be a cardinality estimation scenario template specifically for cardinality estimation tasks in the preset scenario templates, which contains the model information and processing flow of the trained cardinality estimation model.

[0189] The target scenario template refers to the scenario template that matches the task scenario identifier. When parsing the task generation request, the corresponding target scenario template can be located based on the task scenario identifier, and the corresponding data query model and other related configuration information can be selected from the model library based on the model information included in the target scenario template. For example, when the task scenario identifier is "cardinality estimation", the target scenario template is a template that contains the model information and related configuration parameters of the cardinality estimation model.

[0190] The model library is a resource library that centrally stores deep learning models that have been trained and optimized to solve different tasks. The deep learning models stored in the model library include, but are not limited to, data query models and intelligent question-answering models. In addition, the deep learning models in the model library can be divided into different versions according to different applicable scenarios. For example, the model library may store multiple versions of data query models, such as cardinality estimation models for cardinality estimation tasks. The task model identifier refers to a unique or specific label used to distinguish models applicable to different tasks. For example, the task model identifier can be "cardinality estimation". Based on the task model identifier, the cardinality estimation model applicable to the cardinality estimation task can be found from the model library.

[0191] By applying the solution of the embodiments of this specification, through pre-defined task scenario templates, task model identifiers and model library resources, the process of obtaining the data query model is made more flexible, efficient and standardized.

[0192] In another optional embodiment of the present specification, in addition to selecting a pre-trained data query model from a model library, a data query model can be obtained by targeted training based on model training data in the request information, that is, the request information includes multiple sample query statements, and the sample query statements carry sample query results; the above-mentioned acquisition of the data query model based on the request information may include the following steps:

[0193] Based on multiple sample query statements, parameters of the data query model corresponding to the data query task are adjusted to obtain a trained data query model.

[0194] It should be noted that the implementation method of "adjusting parameters of the data query model corresponding to the data query task based on multiple sample query statements to obtain a trained data query model" is the same as the training method of the above-mentioned data query model, and will not be repeated in this specification embodiment.

[0195] By applying the solution of the embodiment of this specification, based on multiple sample query statements, the parameters of the data query model corresponding to the data query task are adjusted to obtain a trained data query model, thereby ensuring the accuracy of the data query model and making the data query model more in line with user needs.

[0196] Step 706: Generate task information based on the data query model, where the task information is used to execute the data query task.

[0197] Specifically, the task information includes the model configuration and processing flow required to execute the data query task. The terminal device or other server components can correctly use the data query model to process the data query task based on the task information.

[0198] It should be noted that when generating task information based on the data query model, the model parameters of the data query model can be directly packaged to generate the task information. Other model information of the data query model can also be obtained to construct the task information based on the other model information, where the other model information includes the processing method of the model input data, the specifications of the expected output results, and the intermediate steps and other auxiliary information that may be involved.

[0199] By applying the solution of the embodiments of this specification, by generating task information of data query tasks, it is possible to reduce system deployment and operation and maintenance costs while ensuring the quality and efficiency of data query task processing, and provide users with convenient and efficient task processing services.

[0200] See also Figure 8 , Figure 8 A schematic diagram of the structure of a model training platform provided by an embodiment of the present specification is shown, the model training platform includes a request interface unit 802 and a model unit 804;

[0201] The request interface unit 802 is used to receive a model training request, wherein the model training request includes request information;

[0202] The model unit 804 is used to obtain a data query model and multiple sample query statements based on the request information, wherein the sample query statements carry sample query results; perform structural analysis on the multiple sample query statements to determine the sample query elements respectively included in the multiple sample query statements and the sample element types of the sample query elements; perform feature extraction on the sample query elements according to the sample element types to obtain sample query features corresponding to the multiple sample query statements; input the multiple sample query features into the data query model to obtain predicted query results; adjust the parameters of the data query model according to the predicted query results and the sample query results to obtain a trained data query model.

[0203] It should be noted that the request information includes but is not limited to the task scenario identifier, task model identifier, and model training data (multiple sample query statements carrying sample query results) of the data query task. The processing method of the model unit is the same as the training method of the above-mentioned data query model, and will not be described in detail in this specification embodiment.

[0204] In an optional embodiment of this specification, the model training platform further includes a model library;

[0205] The model unit is also used to store the trained data query model in the model library.

[0206] It should be noted that after the model unit obtains the trained data query model, the trained data query model can be stored in the model library, so that the trained data query model can be directly obtained from the model library later without repeated training. Among them, the method of obtaining the trained data query model from the model library can refer to the above-mentioned "based on the task scene identification, determine the target scene template from multiple preset scene templates, and based on the target scene template, search for the data query model from the model library; or, based on the task model identification, search for the data query model from the model library". The embodiments of this specification will not be repeated.

[0207] Corresponding to the above data query method embodiment, this specification also provides a data query device embodiment, Fig. 9 FIG. 1 shows a schematic diagram of a data query device provided by an embodiment of the present specification. Fig. 9 As shown, the device comprises:

[0208] A first acquisition module 902 is configured to acquire a query statement for a target database;

[0209] A first determination module 904 is configured to perform structural analysis on the query statement to determine query elements and element types of the query elements in the query statement;

[0210] The first extraction module 906 is configured to extract features from the query element according to the element type to obtain query features;

[0211] The first input module 908 is configured to input the query features into the data query model to obtain the data query results corresponding to the query statement, wherein the data query model is trained based on multiple sample query features and the sample query results corresponding to the sample query features, and the sample query features are obtained by extracting features of sample query elements in the sample query statement based on the sample element type.

[0212] Optionally, the query feature includes a first query feature and a second query feature, and the data query model includes a first attention unit, a second attention unit and a processing unit; the first input module 908 is further configured to input the initial integrated feature and the first query feature into the first attention unit to obtain an intermediate integrated feature and an updated first query feature, wherein the first query feature is obtained based on the attribute distribution feature and the connection distribution feature, and the intermediate integrated feature is used to characterize the association relationship between the connection distribution features; the intermediate integrated feature, the updated first query feature and the second query feature are input into the second attention unit to obtain a target integrated feature, wherein the second query feature is obtained based on the attribute distribution feature, the filter distribution feature and the data set feature, and the target integrated feature is used to characterize the association relationship between the connection distribution feature and the filter distribution feature; the query information of the query statement and the target integrated feature are input into the processing unit to obtain the data query result.

[0213] Optionally, the device further includes: a fourth determination module configured to perform structural analysis on the query statement to determine the number of filter conditions and connection conditions in the query statement; and determine query information of the query statement based on the initial query information and the number of conditions.

[0214] Optionally, the query element includes attributes, and the query features include attribute distribution features; the first extraction module 906 is further configured to determine the value type of the attribute when the query element is determined to be an attribute according to the element type; determine the value information of the attribute according to the value type; and perform feature extraction on the value information to obtain the attribute distribution features.

[0215] Optionally, the value type includes a numerical type and a classification type; the first extraction module 906 is further configured to determine the first value information according to the histogram of the attribute when the value type is a numerical type; and determine the second value information according to the frequency of the attribute when the value type is a classification type.

[0216] Optionally, the query element includes a connection condition, and the query feature includes a connection distribution feature; the first extraction module 906 is further configured to determine, when the query element is determined to be a connection condition according to the element type, the number of connection data respectively included in the multiple data sets connected by the connection condition and the multiple data sets, wherein the connection data is the data in the data set that meets the connection condition; determine the data association relationship between the multiple data sets according to the number of connection data; perform feature extraction on the data association relationship to obtain the connection distribution feature.

[0217] Optionally, the query element includes a filter condition, and the query feature includes a filter distribution feature; the first extraction module 906 is further configured to determine the filter range of the filter condition and determine the proportion of data in the target database that meets the filter condition when the query element is determined as the filter condition according to the element type; perform feature extraction on the filter range and data proportion to obtain the filter distribution feature.

[0218] Optionally, the filtering conditions include numerical filtering conditions and classification filtering conditions; the first extraction module 906 is further configured to determine the first filtering range of the filtering conditions according to the numerical interval of the numerical filtering conditions when the filtering conditions are numerical filtering conditions; and to determine the second filtering range of the filtering conditions according to the classification identifier of the classification filtering conditions when the filtering conditions are classification filtering conditions.

[0219] Optionally, the query element includes a data set, and the query feature includes a data set feature; the first extraction module 906 is further configured to determine the collection information of the data set when the query element is determined to be a data set according to the element type; perform feature extraction on the collection information to obtain the data set feature.

[0220] Optionally, the device also includes: a sending module, configured to send the data query results to the client; receiving result feedback information sent by the client, wherein the result feedback information is information for feedback on the data query results; constructing a model to optimize data based on the result feedback information; and using the model to optimize the data to adjust parameters of the data query model.

[0221] Optionally, the sending module is further configured to generate optimization prompt information based on the result feedback information, wherein the optimization prompt information is used to guide the client to send model optimization data for optimizing the data query model; send the optimization prompt information to the client, and receive the model optimization data sent by the client based on the optimization prompt information.

[0222] Optionally, the device also includes: a training module, configured to obtain multiple sample query statements, wherein the sample query statements carry sample query results; perform structural analysis on the multiple sample query statements to determine the sample query elements and sample element types of the sample query elements respectively included in the multiple sample query statements; perform feature extraction on the sample query elements according to the sample element types to obtain sample query features corresponding to the multiple sample query statements respectively; input the multiple sample query features into the data query model to obtain predicted query results; and adjust parameters of the data query model according to the predicted query results and the sample query results to obtain a trained data query model.

[0223] By applying the scheme of the embodiments of this specification, since the query elements and element types are obtained by analyzing the general structure of the query statements, the method of generating query features can be applicable to query statements of different databases, so that data query across different databases can be realized by using the data query model, thereby improving the generalization ability of the data query model and reducing the resource overhead of the data query process.

[0224] The above is a schematic scheme of a data query device of this embodiment. It should be noted that the technical scheme of the data query device and the technical scheme of the above data query method belong to the same concept, and the details not described in detail in the technical scheme of the data query device can be referred to the description of the technical scheme of the above data query method.

[0225] Corresponding to the above-mentioned cardinality estimation method embodiment, this specification also provides a cardinality estimation device embodiment, Fig.10 FIG. 1 is a schematic diagram showing the structure of a cardinality estimation device provided by an embodiment of the present specification. Fig.10 As shown, the device comprises:

[0226] A first receiving module 1002 is configured to receive a cardinality estimation request for a target database, wherein the cardinality estimation request carries a query statement;

[0227] The second determination module 1004 is configured to perform structural analysis on the query statement to determine the query elements and element types of the query elements in the query statement;

[0228] The second extraction module 1006 is configured to extract features from the query element according to the element type to obtain query features;

[0229] The second input module 1008 is configured to input the query features into the data query model to obtain a cardinality estimation result, wherein the data query model is trained based on multiple sample query features and sample query results corresponding to the sample query features, and the sample query features are obtained by extracting features of sample query elements in the sample query statement based on the sample element type.

[0230] By applying the solution of the embodiments of this specification, a universal cardinality estimation method based on the attention mechanism is proposed, which realizes cardinality estimation across different databases by utilizing a data query model with high generalization ability, thereby reducing the resource overhead of the cardinality estimation process.

[0231] The above is a schematic scheme of a cardinality estimation device of this embodiment. It should be noted that the technical scheme of the cardinality estimation device and the technical scheme of the cardinality estimation method described above are of the same concept, and the details of the technical scheme of the cardinality estimation device that are not described in detail can be found in the description of the technical scheme of the cardinality estimation method described above.

[0232] Corresponding to the above data query model training method embodiment, this specification also provides a data query model training device embodiment, Fig.11 FIG. 1 is a schematic diagram showing the structure of a data query model training device provided by an embodiment of the present specification. Fig.11 As shown, the device comprises:

[0233] The second acquisition module 1102 is configured to acquire multiple sample query statements, wherein the sample query statements carry sample query results;

[0234] The third determining module 1104 is configured to perform structural analysis on the multiple sample query statements to determine the sample query elements and sample element types of the sample query elements respectively included in the multiple sample query statements;

[0235] The third extraction module 1106 is configured to extract features of the sample query element according to the sample element type, and obtain sample query features corresponding to the multiple sample query statements respectively;

[0236] The third input module 1108 is configured to input a plurality of sample query features into the data query model to obtain a predicted query result;

[0237] The adjustment module 1110 is configured to adjust parameters of the data query model according to the predicted query results and the sample query results to obtain a trained data query model.

[0238] By applying the solution of the embodiments of the present specification, the model parameters of the data query model are continuously adjusted, so that the final data query model can be made more accurate. In addition, since the sample query elements and sample element types are obtained by analyzing the general structure of the sample query statements, the method of generating sample query features can be applicable to sample query statements of different databases, thereby improving the generalization ability of the data query model.

[0239] The above is a schematic scheme of a data query model training device of this embodiment. It should be noted that the technical scheme of the data query model training device and the technical scheme of the above-mentioned data query model training method belong to the same concept, and the details not described in detail in the technical scheme of the data query model training device can be found in the description of the technical scheme of the above-mentioned data query model training method.

[0240] Corresponding to the above-mentioned information processing method embodiment based on the data query model, this specification also provides an information processing device embodiment based on the data query model. Fig.12 FIG. 1 shows a schematic diagram of the structure of an information processing device based on a data query model provided by an embodiment of the present specification. Fig.12 As shown, the device comprises:

[0241] The second receiving module 1202 is configured to receive a task generation request, wherein the task generation request includes request information;

[0242] The third acquisition module 1204 is configured to acquire a data query model based on the request information, wherein the data query model is trained based on a plurality of sample query features and sample query results corresponding to the sample query features, and the sample query features are obtained by extracting features of sample query elements in the sample query statement based on sample element types;

[0243] The generating module 1206 is configured to generate task information based on the data query model, wherein the task information is used to execute the data query task.

[0244] Optionally, the third acquisition module 1204 is further configured to determine a target scene template from multiple preset scene templates based on the task scenario identifier, and search for a data query model from a model library based on the target scene template, wherein the model library stores multiple deep learning models, and the request information includes the task scenario identifier of the data query task; or, search for a data query model from the model library based on the task model identifier, wherein the request information includes the task model identifier of the data query task.

[0245] Optionally, the request information includes multiple sample query statements, and the sample query statements carry sample query results; the third acquisition module 1204 is further configured to adjust parameters of the data query model corresponding to the data query task based on the multiple sample query statements to obtain a trained data query model.

[0246] By applying the solution of the embodiments of this specification, by generating task information of data query tasks, it is possible to reduce system deployment and operation and maintenance costs while ensuring the quality and efficiency of data query task processing, and provide users with convenient and efficient task processing services.

[0247] The above is a schematic scheme of an information processing device based on a data query model of this embodiment. It should be noted that the technical scheme of the information processing device based on the data query model and the technical scheme of the information processing method based on the data query model belong to the same concept, and the details not described in detail in the technical scheme of the information processing device based on the data query model can be found in the description of the technical scheme of the information processing method based on the data query model.

[0248] Fig.13 13 shows a block diagram of a computing device provided by an embodiment of the present specification. The components of the computing device 1300 include but are not limited to a memory 1310 and a processor 1320. The processor 1320 is connected to the memory 1310 via a bus 1330, and the database 1350 is used to store data.

[0249] The computing device 1300 also includes an access device 1340 that enables the computing device 1300 to communicate via one or more networks 1360. Examples of these networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet. The access device 1340 may include one or more of any type of network interface, wired or wireless (e.g., a network interface card (NIC)), such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a World Wide Interoperability for Microwave Access (Wi-MAX) interface, an Ethernet interface, a universal serial bus (USB) interface, a cellular network interface, a Bluetooth interface, a near field communication (NFC) interface, and the like.

[0250] In one embodiment of the present specification, the above components of the computing device 1300 and Fig.13 Other components not shown in the figure may also be connected to each other, for example, via a bus. It should be understood that Fig.13 The computing device structure block diagram shown is only for the purpose of illustration, and is not intended to limit the scope of this specification. Those skilled in the art can add or replace other components as needed.

[0251] The computing device 1300 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, a personal digital assistant, a laptop computer, a notebook computer, a netbook, etc.), a mobile phone (e.g., a smart phone), a wearable computing device (e.g., a smart watch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or a personal computer (PC). The computing device 1300 may also be a mobile or stationary server.

[0252] Among them, the processor 1320 is used to execute computer programs / instructions, which, when executed by the processor, implement the steps of the above-mentioned data query method or cardinality estimation method or data query model training method or information processing method based on the data query model.

[0253] The above is a schematic scheme of a computing device of this embodiment. It should be noted that the technical scheme of the computing device and the technical schemes of the above-mentioned data query method, cardinality estimation method, data query model training method, and information processing method based on data query model belong to the same concept. For details not described in detail in the technical scheme of the computing device, please refer to the description of the technical scheme of the above-mentioned data query method or cardinality estimation method or data query model training method or information processing method based on data query model.

[0254] An embodiment of the present specification also provides a computer-readable storage medium storing a computer program / instruction, which, when executed by a processor, implements the steps of the above-mentioned data query method or cardinality estimation method or data query model training method or information processing method based on a data query model.

[0255] The above is a schematic scheme of a computer-readable storage medium of this embodiment. It should be noted that the technical scheme of the storage medium and the technical scheme of the above-mentioned data query method, cardinality estimation method, data query model training method and information processing method based on the data query model belong to the same concept, and the details not described in detail in the technical scheme of the storage medium can be referred to the description of the technical scheme of the above-mentioned data query method or cardinality estimation method or data query model training method or information processing method based on the data query model.

[0256] An embodiment of the present specification also provides a computer program product, including a computer program / instruction, which, when executed by a processor, implements the steps of the above-mentioned data query method or cardinality estimation method or data query model training method or information processing method based on a data query model.

[0257] The above is a schematic scheme of a computer program product of this embodiment. It should be noted that the technical scheme of the computer program product and the technical scheme of the data query method, cardinality estimation method, data query model training method and information processing method based on the data query model belong to the same concept, and the details not described in detail in the technical scheme of the computer program product can be found in the description of the technical scheme of the data query method or cardinality estimation method or data query model training method or information processing method based on the data query model.

[0258] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0259] The computer instructions include computer program codes, which may be in source code form, object code form, executable files or some intermediate forms, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable medium may be appropriately increased or decreased according to the requirements of patent practice. For example, in some regions, according to patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.

[0260] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the embodiments of this specification are not limited by the order of the actions described, because according to the embodiments of this specification, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the embodiments of this specification.

[0261] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0262] The preferred embodiments of this specification disclosed above are only used to help explain this specification. The optional embodiments do not describe all the details in detail, nor do they limit the invention to only the specific implementation methods described. Obviously, many modifications and changes can be made according to the content of the embodiments of this specification. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the embodiments of this specification, so that technicians in the relevant technical field can well understand and use this specification. This specification is only limited by the claims and their full scope and equivalents.

Claims

1. A data query method, comprising: Get the query statement for the target database; Performing structural analysis on the query statement to determine query elements in the query statement and element types of the query elements; Extracting features of the query element according to the element type to obtain query features; The query feature is input into a data query model to obtain a data query result corresponding to the query statement, wherein the data query model is trained based on multiple sample query features and sample query results corresponding to the sample query features, and the sample query features are obtained by extracting features of sample query elements in a sample query statement based on sample element types.

2. The method according to claim 1, wherein the query feature comprises a first query feature and a second query feature, and the data query model comprises a first attention unit, a second attention unit, and a processing unit; The step of inputting the query feature into a data query model to obtain a data query result corresponding to the query statement includes: Inputting the initial integrated feature and the first query feature into the first attention unit to obtain an intermediate integrated feature and an updated first query feature, wherein the first query feature is obtained based on the attribute distribution feature and the connection distribution feature, and the intermediate integrated feature is used to characterize the association relationship between the connection distribution features; Inputting the intermediate integrated feature, the updated first query feature and the second query feature into the second attention unit to obtain a target integrated feature, wherein the second query feature is obtained based on the attribute distribution feature, the filter distribution feature and the data set feature, and the target integrated feature is used to characterize the association relationship between the connection distribution feature and the filter distribution feature; The query information of the query statement and the target integration feature are input into the processing unit to obtain the data query result.

3. The method according to claim 2, before inputting the query information of the query statement and the target integration feature into the processing unit to obtain the data query result, further comprises: Performing structural analysis on the query statement to determine the number of filter conditions and connection conditions in the query statement; The query information of the query statement is determined according to the initial query information and the number of conditions.

4. The method according to claim 1, wherein the query element comprises an attribute, and the query feature comprises an attribute distribution feature; The step of extracting features from the query element according to the element type to obtain query features includes: In the case where the query element is determined to be the attribute according to the element type, determining the value type of the attribute; Determining value information of the attribute according to the value type; Feature extraction is performed on the value information to obtain attribute distribution features.

5. The method according to claim 4, wherein the value type comprises a numerical type and a categorical type; The determining, according to the value type, the value information of the attribute includes: In a case where the value type is the numerical type, determining first value information according to a histogram of the attribute; In the case where the value type is the classification type, the second value information is determined according to the frequency of the attribute.

6. The method according to claim 1, wherein the query element comprises a connection condition, and the query feature comprises a connection distribution feature; The step of extracting features from the query element according to the element type to obtain query features includes: In the case where the query element is determined to be the connection condition according to the element type, determining a plurality of data sets connected by the connection condition and the number of connection data respectively included in the plurality of data sets, wherein the connection data is data in the data sets that meets the connection condition; Determining, according to the quantity of the connected data, a data association relationship between the multiple data sets; Feature extraction is performed on the data association relationship to obtain the connection distribution feature.

7. The method according to claim 1, wherein the query element comprises a filter condition, and the query feature comprises a filter distribution feature; The step of extracting features from the query element according to the element type to obtain query features includes: In the case where the query element is determined as the filtering condition according to the element type, determining a filtering range of the filtering condition, and determining a proportion of data in the target database that meets the filtering condition; Feature extraction is performed on the filtering range and the data ratio to obtain the filtering distribution feature.

8. The method according to claim 7, wherein the filtering condition comprises a numerical filtering condition and a classification filtering condition; Determining the filtering range of the filtering condition includes: In the case where the filtering condition is the numerical filtering condition, determining a first filtering range of the filtering condition according to a numerical interval of the numerical filtering condition; In the case that the filtering condition is the classification filtering condition, the second filtering range of the filtering condition is determined according to the classification identifier of the classification filtering condition.

9. The method of claim 1, wherein the query element comprises a data set, and the query feature comprises a data set feature; The step of extracting features from the query element according to the element type to obtain query features includes: In the case where it is determined according to the element type that the query element is the data set, determining set information of the data set; Feature extraction is performed on the set information to obtain the data set features.

10. The method according to any one of claims 1 to 9, after inputting the query feature into a data query model and obtaining a data query result corresponding to the query statement, further comprising: Sending the data query result to the client; Receiving result feedback information sent by the client, wherein the result feedback information is information providing feedback on the data query result; According to the result feedback information, a model is constructed to optimize the data; The model is used to optimize data and parameters of the data query model are adjusted.

11. The method according to claim 10, wherein constructing model optimization data according to the result feedback information comprises: Generate optimization prompt information according to the result feedback information, wherein the optimization prompt information is used to guide the client to send model optimization data for optimizing the data query model; The optimization prompt information is sent to the client, and the model optimization data sent by the client based on the optimization prompt information is received.

12. The method according to claim 1, before inputting the query feature into a data query model to obtain a data query result corresponding to the query statement, further comprising: Acquire multiple sample query statements, wherein the sample query statements carry sample query results; Performing structural analysis on the multiple sample query statements to determine sample query elements respectively included in the multiple sample query statements and sample element types of the sample query elements; Extracting features of the sample query elements according to the sample element types to obtain sample query features corresponding to the multiple sample query statements; Input multiple sample query features into the data query model to obtain predicted query results; According to the predicted query result and the sample query result, the parameters of the data query model are adjusted to obtain a trained data query model.

13. A cardinality estimation method, comprising: receiving a cardinality estimation request for a target database, wherein the cardinality estimation request carries a query statement; Performing structural analysis on the query statement to determine query elements in the query statement and element types of the query elements; Extracting features of the query element according to the element type to obtain query features; The query feature is input into a data query model to obtain a cardinality estimation result, wherein the data query model is trained based on multiple sample query features and sample query results corresponding to the sample query features, and the sample query features are obtained by extracting features of sample query elements in a sample query statement based on sample element types.

14. A data query model training method, comprising: Acquire multiple sample query statements, wherein the sample query statements carry sample query results; Performing structural analysis on the multiple sample query statements to determine sample query elements respectively included in the multiple sample query statements and sample element types of the sample query elements; Extracting features of the sample query elements according to the sample element types to obtain sample query features corresponding to the multiple sample query statements; Input multiple sample query features into the data query model to obtain predicted query results; According to the predicted query result and the sample query result, the parameters of the data query model are adjusted to obtain a trained data query model.

15. An information processing method based on a data query model, comprising: receiving a task generation request, wherein the task generation request includes request information; Based on the request information, a data query model is obtained, wherein the data query model is trained based on a plurality of sample query features and sample query results corresponding to the sample query features, and the sample query features are obtained by extracting features of sample query elements in a sample query statement based on sample element types; Based on the data query model, task information is generated, wherein the task information is used to execute the data query task.

16. The method according to claim 15, wherein obtaining a data query model based on the request information comprises: Based on the task scenario identifier, determine a target scenario template from a plurality of preset scenario templates, and based on the target scenario template, search for a data query model from a model library, wherein the model library stores a plurality of deep learning models, and the request information includes the task scenario identifier of the data query task; or Based on the task model identifier, a data query model is searched from the model library, wherein the request information includes the task model identifier of the data query task.

17. The method according to claim 15, wherein the request information includes a plurality of sample query statements, and the sample query statements carry sample query results; The acquiring of a data query model based on the request information includes: Based on the multiple sample query statements, parameters of the data query model corresponding to the data query task are adjusted to obtain a trained data query model.

18. A model training platform, comprising a request interface unit and a model unit; The request interface unit is used to receive a model training request, wherein: The model training request includes request information; The model unit is used to obtain a data query model and multiple sample query statements based on the request information, wherein the sample query statements carry sample query results; perform structural analysis on the multiple sample query statements to determine sample query elements respectively included in the multiple sample query statements and sample element types of the sample query elements; perform feature extraction on the sample query elements according to the sample element types to obtain sample query features respectively corresponding to the multiple sample query statements; input the multiple sample query features into the data query model to obtain predicted query results; and adjust parameters of the data query model according to the predicted query results and the sample query results to obtain a trained data query model.

19. The model training platform according to claim 18, further comprising a model library; The model unit is also used to store the trained data query model in the model library.

20. A computing device comprising: Memory and processor; The memory is used to store computer programs / instructions, and the processor is used to execute the computer programs / instructions. When the computer program / instructions are executed by the processor, the steps of the method described in any one of claims 1 to 12 or claim 13 or claim 14 or any one of claims 15 to 17 are implemented.

21. A computer-readable storage medium storing a computer program / instruction, which, when executed by a processor, implements the steps of the method described in any one of claims 1 to 12 or claim 13 or claim 14 or any one of claims 15 to 17.

22. A computer program product comprising a computer program / instruction, which, when executed by a processor, implements the steps of the method described in any one of claims 1 to 12 or claim 13 or claim 14 or any one of claims 15 to 17.

Citation Information

Patent Citations

  • Code searching method based on two-stage attention mechanism

    CN112800172A

  • Cardinality estimation method and device for database query optimization

    CN115587111A

  • Data query method and query prediction model training method

    CN116108072A

  • Method for acquiring structured question-answering model, question-answering method and corresponding apparatus

    US20230018489A1