Generation method of materialized view, electronic equipment and computer readable storage medium
By predicting the structure and variable values of the target query request, the materialized view is solved, and the query performance and efficiency are improved.
Patent Information
- Application Number
- CN202411238758.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-04
- Publication Date
- 2024-12-24
AI Technical Summary
When materialized views are generated based on user history queries, they cannot accurately cover the current query requirements, resulting in a degradation of query performance.
By obtaining the initial query request, predicting the structure and variable values of the target query request, generating the target materialized view, representing the query request and results in the preset time period after the current time, and improving the hit rate of the materialized view.
It improves the hit rate and query performance of materialized views, reduces complex queries to the database, and improves query efficiency.
Smart Images

Figure CN119179790A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of data query and large model, and in particular to a method for generating a materialized view, an electronic device and a computer-readable storage medium. Background Art
[0002] Materialized views save the query results of some queries in the database in advance, so that users can directly access these pre-calculated results when querying, without having to re-execute the original query. Materialized views can improve query performance when processing complex queries or large amounts of data.
[0003] Materialized views in related technologies rely on historical query generation, but queries are usually dynamic and constantly changing. If materialized views are generated based on past query behaviors, they may not accurately cover the user's current query needs. Therefore, the effectiveness of generating materialized views based on user historical queries is poor, resulting in reduced query performance.
[0004] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention
[0005] The embodiments of the present application provide a materialized view generation method, an electronic device, and a computer-readable storage medium to at least solve the technical problem of poor effectiveness of materialized views.
[0006] According to one aspect of an embodiment of the present application, a method for generating a materialized view is provided, comprising: obtaining an initial query request; predicting a target query request based on the initial query request to obtain a target query template of the target query request, wherein the target query request is used to characterize query requests within a preset time period after a current moment, and the target query template is used to characterize the structure of the target query request; predicting a target query request containing a target variable value based on the target query template, wherein the target query template is used to characterize the variable value corresponding to the target query template; and displaying a target materialized view on the operation interface in response to a generation instruction acting on an operation interface, wherein the target materialized view is used to characterize a mapping relationship between the target query request and the target query result corresponding to the target query request, thereby generating the target materialized view.
[0007] According to another aspect of an embodiment of the present application, a data query method is also provided, including: receiving a current query request sent by a client; matching the current query request with a pre-generated target materialized view, wherein the target materialized view is a materialized view generated using the above-mentioned materialized view generation method; when the current query request successfully matches the target query request in the target materialized view, obtaining a query result corresponding to the target query request from the target materialized view to obtain a target query result corresponding to the current query request; and sending the target query result to the client.
[0008] According to another aspect of an embodiment of the present application, a product query method is also provided, including: receiving a current query request sent by a client, wherein the current query request is used to query a target product; matching the current query request with a pre-generated target materialized view, wherein the target materialized view is a materialized view generated using the above-mentioned materialized view generation method, and the target materialized view is used to characterize the mapping relationship between the query request and the product to be queried; when the current query request successfully matches the target query request in the target materialized view, obtaining the target product to be queried corresponding to the target query request from the target materialized view, and obtaining a query result for the target product; and sending the query result for the target product to the client.
[0009] According to another aspect of an embodiment of the present application, a method for generating a materialized view is also provided, including: obtaining an initial query request by calling a first interface, wherein the first interface includes a first parameter, and the parameter value of the first parameter includes the initial query request; using a first prediction model to predict a query request based on the initial query request to obtain a target query template of a target query request, wherein the target query template is used to characterize the structure of the target query request, and the target query request is used to characterize query requests within a preset time period after a current moment; using a second prediction model to predict a query request based on the target query template to obtain a target query request, wherein the target query request includes variable values corresponding to the target query template; generating a target materialized view based on the target query request and a mapping relationship between the target query result corresponding to the target query request; and outputting the target materialized view by calling a second interface, wherein the second interface includes a second parameter, and the parameter value of the second parameter includes the target materialized view.
[0010] According to another aspect of the embodiments of the present application, an electronic device is further provided, including: a memory storing an executable program; and a processor for running the program, wherein the method of each embodiment of the present application is executed when the program is running.
[0011] According to another aspect of an embodiment of the present application, a computer-readable storage medium is also provided, the computer-readable storage medium including a stored executable program, wherein when the executable program is running, the device where the computer-readable storage medium is located is controlled to execute the methods in each embodiment of the present application.
[0012] According to another aspect of the embodiments of the present application, a computer program product is also provided, including a computer program, and when the computer program is executed by a processor, the method in each embodiment of the present application is implemented.
[0013] According to another aspect of an embodiment of the present application, a computer program product is also provided, including a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method in each embodiment of the present application is implemented.
[0014] According to another aspect of the embodiments of the present application, a computer program is also provided, and when the computer program is executed by a processor, the methods in the various embodiments of the present application are implemented.
[0015] In an embodiment of the present application, in response to an initial query request acting on an operation interface, a target query template of a target query request is displayed on the operation interface; in response to a confirmation instruction acting on the operation interface, a target query request including a target variable value is displayed on the operation interface; in response to a generation instruction acting on the operation interface, a target materialized view is displayed on the operation interface. It is easy to notice that a target query template representing the structure of a target query request is predicted based on an initial query request, and a target variable of a target query request is predicted based on a target query template, thereby predicting target query requests that will be frequently used by users in the future, and constructing a target materialized view based on target query requests and target query results that will be frequently used by users in the future, thereby increasing the probability that the target materialized view hits a query request issued by a user, thereby achieving the purpose of improving the effectiveness of the materialized view, and thus solving the technical problem of poor effectiveness of the materialized view.
[0016] It is easy to notice that the above general description and the following detailed description are only for the purpose of exemplifying and explaining the present application, and do not constitute a limitation of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0018] Figure 1 is a schematic diagram of an application scenario of a method for generating a materialized view according to an embodiment of the present application;
[0019] Figure 2is a flow chart of a method for generating a materialized view according to an embodiment of the present application;
[0020] Figure 3 is a schematic diagram of training a deep learning model according to an embodiment of the present application;
[0021] Figure 4 is a schematic diagram of training a deep learning model according to an embodiment of the present application;
[0022] Figure 5 is a schematic diagram of using a second prediction model to predict a target query request according to an embodiment of the present application;
[0023] Figure 6 is a schematic diagram of training a statistical model according to an embodiment of the present application;
[0024] Figure 7 is a schematic diagram of generating a target materialized view according to an embodiment of the present application;
[0025] Figure 8 is a flow chart of a data query method according to an embodiment of the present application;
[0026] Fig. 9 is a flow chart of a product data query method according to an embodiment of the present application;
[0027] Fig.10 is a flow chart of a method for generating a materialized view according to an embodiment of the present application;
[0028] Fig.11 is a schematic diagram of a device for generating a materialized view according to an embodiment of the present application;
[0029] Fig.12 is a schematic diagram of a data query device according to an embodiment of the present application;
[0030] Fig.13 is a schematic diagram of a product data query device according to an embodiment of the present application;
[0031] Fig.14 is a flow chart of a device for generating a materialized view according to an embodiment of the present application;
[0032] Fig.15 It is a structural block diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0033] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0034] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0035] The technical solution provided in this application is mainly implemented by large-scale model technology. The large model here refers to a deep learning model with large-scale model parameters, which can usually contain hundreds of millions, tens of billions, hundreds of billions, trillions or even more than 10 trillion model parameters. The large model can also be called a cornerstone model / foundation model (Foundation Model). The large model is pre-trained through 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 large-scale language model (Large Language Model, LLM), multi-modal pre-training model (multi-modal pre-training model), etc.
[0036] It should be noted that when the large model is actually applied, the pre-trained model can be fine-tuned through a small number of samples, so that the large model can be applied to different tasks. For example, the large model can be widely used in natural language processing (NLP), computer vision, speech processing and other fields. Specifically, it can be applied to computer vision tasks such as visual question answering (VQA), image caption (IC), image generation, etc. It can also be widely used in natural language processing tasks such as text-based sentiment classification, text summary generation, machine translation, etc. Therefore, the main application scenarios of the large model include but are not limited to digital assistants, intelligent robots, search, online education, office software, e-commerce, intelligent design, etc. In the embodiment of the present application, the example of predicting the user's future query behavior through a large-scale language model and a Bayesian model in an e-commerce scenario and constructing a target materialized view is used for explanation.
[0037] First, some nouns or terms that appear in the description of the embodiments of the present application are subject to the following explanations:
[0038] Materialized View (MV): Materialized View saves the query results of some queries in the database in advance, so that users can directly access these pre-calculated results when querying, without having to re-execute the original query. Materialized View can improve query performance when processing complex queries or large amounts of data.
[0039] Large Language Model (LLM): A deep learning model trained with a large amount of data, specifically designed to process and understand human language. This type of model has a wide range of applications in the field of natural language processing, such as text generation, text summarization, machine translation, sentiment analysis, etc.
[0040] Bayesian Model: A model based on probability graphs, which is used to represent the joint probability distribution of a set of variables. It can use known probability distribution information to predict the probability of unknown events. It consists of a set of random variables and a directed acyclic graph (DAG) of conditional dependencies between these variables.
[0041] According to an embodiment of the present application, a method for generating a materialized view is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0042] Considering the huge number of model parameters of large models and the limited computing resources of mobile terminals, the above-mentioned materialized view generation method provided in the embodiment of the present application can be applied to Figure 1 The application scenarios shown are not limited to these. Figure 1 In the application scenario shown, the large model is deployed in the server 10, and the server 10 can be connected to one or more client devices 20 through a local area network connection, a wide area network connection, an Internet connection, or other types of data networks. The client device 20 here may include but is not limited to: a smart phone, a tablet computer, a laptop computer, a PDA, a personal computer, a smart home device, a vehicle-mounted device, etc. The client device 20 can interact with the user through a graphical user interface to implement the call of the large model, thereby implementing the method provided in the embodiment of the present application.
[0043] In an embodiment of the present application, a system composed of a client device and a server can perform the following steps: the client device executes receiving an initial query request acting on an operation interface, displays a target query template of the target query request on the operation interface, and the server obtains the initial query request; predicts the target query request based on the initial query request to obtain a target query template of the target query request; the client device executes receiving a confirmation instruction acting on the operation interface, displays a target query request containing a target variable value on the operation interface, and the server predicts a target query request containing a target variable value based on the target query template; the client device executes receiving a generation instruction acting on the operation interface, displays a target materialized view on the operation interface, and the server generates a target materialized view based on the mapping relationship between the target query request and the target query result corresponding to the target query request. It should be noted that, in the case where the operating resources of the client device can meet the deployment and operation conditions of the large model, the embodiment of the present application can be performed in the client device.
[0044] Under the above operating environment, this application provides Figure 2 The method for generating materialized views is shown in the figure. Figure 2 FIG. 1 is a flow chart of a method for generating a materialized view according to an embodiment of the present application. Figure 2 As shown, the method may include the following steps:
[0045] Step S202: obtaining an initial query request.
[0046] The initial query request in the above steps can be a query request sent by the user, or multiple query requests sent by the user within a period of time. The initial query request can be used as a batch of historical query requests to predict the target query requests that the user will send frequently in the future. The initial query request can be generated based on the interaction between the user and the client on the operation interface. The user enters the query statement in the input box of the operation interface, and the client generates the initial query request based on the query statement entered by the user. In an optional embodiment, an input box and a button are displayed on the operation interface. The user can enter the query statement in the input box of the operation interface and press the button. After the client detects the query statement entered by the user, it generates an initial query request and sends the initial query request to the server.
[0047] Step S204, predicting the target query request based on the initial query request to obtain a target query template of the target query request, wherein the target query request is used to characterize the query request within a preset time period after the current moment, and the target query template is used to characterize the structure of the target query request.
[0048] The target query request in the above step may be a query request that is predicted based on the initial query request and that the user will issue in the future.
[0049] The target query template in the above steps may be a template representing a statement structure in a target query request, serving as a seed for generating a target materialized view.
[0050] The preset time period in the above steps is a pre-set future time period, for example, it can be the next week, the next month, the next quarter, etc., and can be preset according to actual application conditions. The specific value of the preset time period is not limited here.
[0051] In an optional embodiment, after receiving the initial query request, the server uses the trained prediction model to predict the initial query request, and obtains the structure of the target query request that the user may issue within a preset time period after the current moment, that is, the target query template. The prediction model can be an LLM model, a pre-trained language model (Pre-trained Language Models, PLM for short), or a recurrent neural network (Recurrent Neural Networks, RNN for short), but is not limited to this. After generating the target query template, the server sends the target query template to the client, and the client controls the operation interface to display the target query template of the target query request.
[0052] In another optional embodiment, after the server receives multiple initial query requests, it can also perform clustering processing on the multiple initial query requests, use the results of the clustering processing as input to the trained prediction model, and predict the target query template based on the results of the clustering processing and the trained prediction model.
[0053] In another optional embodiment, after the server receives multiple initial query requests, it determines the query requests frequently used by users from the multiple initial query requests based on the frequency of query requests issued by users in the past, and then uses the structure of the frequently used query requests as the target query template.
[0054] Step S206, predicting a target query request including a target variable value based on the target query template, wherein the target query template is used to characterize the variable value corresponding to the target query template. The target variable value in the above step can be obtained by processing the target query template and can be used to generate the target query request.
[0055] In an optional embodiment, a confirmation button is displayed on the operation interface, and the user can press the confirmation button on the operation interface. After the client detects that the user presses the confirmation button, it generates a confirmation instruction and sends the confirmation instruction to the server. After receiving the confirmation instruction, the server uses the target query template displayed on the operation interface to generate a target query request. In the process of generating the target query request, the trained prediction model can be used to predict the target query request to obtain a target query request containing the target variable value. The prediction model used here can be a Bayesian model, a Hidden Markov Model (HMM for short), or a Conditional Random Field (CRF for short), but is not limited to this. After generating the target query request containing the target variable value, the server sends the target query request containing the target variable value to the client, and the client controls the operation interface to display the target query request containing the target variable value.
[0056] In another optional embodiment, after the user issues a confirmation instruction in the operation interface and the server receives the confirmation instruction, the target query template can also be decoupled, the variable can be separated from the target query template, and used as the input of the Bayesian model. The Bayesian model predicts the target query request containing the target variable value, thereby obtaining the target query request containing the target variable value.
[0057] Step S208, in response to the generation instruction acting on the operation interface, the target materialized view is displayed on the operation interface, wherein the target materialized view is used to represent the mapping relationship between the target query request and the target query result corresponding to the target query request, and the target materialized view is generated.
[0058] The operation interface in the above steps is an interface that provides interactive functions for users and clients, and provides elements that users can see and operate, such as buttons, input boxes, icons, menus, etc.
[0059] The generation instruction in the above steps is used to instruct the server to query the database based on the target query request, obtain the target query result corresponding to the target query request, and build the target materialized view based on the target query request and the target query result. The generation instruction can be generated based on the interaction between the user and the client on the operation interface. The user presses the generation button on the operation interface, and the client generates and sends the generation instruction to the server based on the action of pressing the generation button issued by the user.
[0060] The target materialized view in the above steps is a materialized view that includes the target query requests that the user will make in the future and the target query results corresponding to the target query requests. Compared with the existing materialized views, the query request hit rate of the materialized view can be improved by using the predicted high-frequency target query requests that the user will use in the future to construct the target materialized view.
[0061] The target query structure in the above steps is the result returned after performing database query calculation on the target query request.
[0062] In an optional embodiment, a generate button is displayed on the operation interface, and the user can press the generate button on the operation interface. After the client detects that the user presses the generate button, it generates and sends a generate instruction to the server. After receiving the generate instruction, the server performs a database query on the target query request, and sorts and filters the results according to the query logic in the target query request to obtain the target query result. Based on the mapping relationship between the target query request and the target query result, a target materialized view is constructed and stored. The server sends the generated target materialized view to the client, and the client controls the operation interface to display the target materialized view.
[0063] By predicting the target query target based on the initial query request and predicting the target query request based on the target query target, the prediction of the user's future target query request is introduced into the target materialized view, thereby enriching the query requests included in the target materialized view and improving the effectiveness of the target materialized view. When the user makes a query request in the future, a higher query request hit rate can be provided, thereby reducing query calculations and improving query efficiency.
[0064] In an embodiment of the present application, in response to an initial query request acting on an operation interface, a target query template of a target query request is displayed on the operation interface; in response to a confirmation instruction acting on the operation interface, a target query request including a target variable value is displayed on the operation interface; in response to a generation instruction acting on the operation interface, a target materialized view is displayed on the operation interface. It is easy to notice that a target query template representing a target query request structure is predicted based on an initial query request, and a target variable of a target query request is predicted based on a target query template, thereby predicting a target query request to be issued by a user in the future, and constructing a target materialized view based on the predicted target query request and target query structure. By introducing a target query request representing a user's future query behavior into a target materialized view, the purpose of improving the effectiveness of the materialized view is achieved, thereby solving the technical problem of poor effectiveness of the materialized view.
[0065] Optionally, the initial query request includes multiple sub-requests, and the target query request is predicted based on the initial query request to obtain a target query template of the target query request, including: clustering the multiple sub-requests to obtain at least one initial clustering set; sampling different initial clustering sets to obtain multiple initial sampling results; inputting the multiple initial sampling results into a first prediction model, and obtaining the target query template output by the first prediction model.
[0066] The initial clustering set in the above step is a grouping set obtained by clustering multiple sub-requests in the initial query request and dividing the multiple sub-requests into several groups according to the characteristics of the multiple sub-requests.
[0067] The initial sampling result in the above steps is obtained by sampling the initial cluster set and extracting a portion of representative sub-requests (which may be one or more) from each group in the initial cluster set.
[0068] The first prediction model in the above steps is a trained model used to predict the target query template, which may be an LLM model, but is not limited thereto.
[0069] In an optional embodiment, the initial query request includes multiple sub-requests, (t1, q1, f), (t2, q2, f), (t3, q3, f), ..., (tM, qM, f) are all sub-requests, where t represents time, q represents query, and f represents feature. Then, the multiple sub-requests are clustered, and according to the features of the sub-requests, the sub-requests with high feature similarity are divided into an initial cluster set, so that the multiple sub-requests are divided into at least one initial cluster set. The initial cluster set is sampled, and representative sub-requests are extracted from the initial cluster set to obtain multiple initial sampling results: (t1', q1', f'), (t2', q2', f'), (t3', q3', f'), ..., (tM', qM', f'), where t' represents time, q' represents query, and f' represents feature. The initial sampling results are input into a trained large-scale language model, that is, a first prediction model, so that the large-scale language model predicts the target query template based on the initial sampling results.
[0070] Clustering multiple sub-requests can help identify the commonalities of initial query requests, merge similar initial query requests into a few initial clustering sets, and extract samples from the initial clustering sets, that is, the initial sampling results, as the input of the first prediction model. This can significantly reduce the amount of data that the first prediction model needs to process, improve the efficiency of data processing, and speed up the acquisition of the target query template.
[0071] Optionally, the first prediction model is a model obtained by training a deep learning model using multiple historical query requests, training query requests corresponding to the multiple historical query requests, and training event information, wherein the training event information is event information obtained by recalling event information in an event information library based on the training query requests.
[0072] The historical query request in the above steps is a query request issued by the user to the database in a historical time period.
[0073] The training query request in the above step is a query request extracted from all query requests issued by users to the database in the historical time period. The sending time of the query request is later than the sending time of multiple historical query requests, so it can be used as a query request predicted by multiple historical query requests in the future time period.
[0074] The training event information in the above steps is the event information that matches the training query request and is recalled from the event information library. Different types of event information can be obtained for different training requirements. For example, the event information can be the name of a more critical time node, such as a specific festival, anniversary, season, holiday, etc. The event information is stored in the event information library, which is a database that stores event information and can be used to recall event information according to the query time.
[0075] The deep learning model in the above steps is an untrained model, which may be an LLM model, a PLM model, or an RNN model, but is not limited thereto.
[0076] In an optional embodiment, Figure 3 is a schematic diagram of a training deep learning model according to an embodiment of the present application, such as Figure 3 As shown, historical query requests 302 in the past period of time are obtained, and the historical query request 302 contains multiple sub-requests, (t1, q1, f), (t2, q2, f), (t3, q3, f), ..., (tM, qM, f) are all sub-requests, where t represents time, q represents query, and f represents feature. Then, multiple sub-requests are clustered, and sub-requests with high feature similarity are divided into a cluster set 304 according to the features of the sub-requests, so that multiple sub-requests are divided into at least one cluster set 304. Figure 3 In the cluster 304, cluster1, cluster2, ..., clusterN are all cluster sets 304. The cluster set 304 is sampled, and representative sub-requests are extracted from the cluster set 304 to obtain multiple sampling results 306, (t1', q1', f'), (t2', q2', f'), (t3', q3', f'), ..., (tM', qM', f') are all sampling results 306, where t' represents time, q' represents query, and f' represents feature. The sampling results 306 are sub-requests in different cluster sets 304, and the sampling results 306 are input into a large-scale language model 308, that is, a deep learning model, to train the large-scale language model 308. In addition, query information (tN, queryN, f) 312 at time N, i.e., training query requests corresponding to multiple historical query requests, is also input into the large-scale language model 308 to train the large-scale language model 308, where tN is time, queryN is the query request corresponding to tN, and f is a feature. Moreover, the event knowledge text can be seasons, holidays, festivals, etc., and event knowledge (tK, knowledge) 310 at time K is extracted from an event knowledge base composed of multiple event knowledge texts, i.e., an event information base, where tK is time and knowledge is the event knowledge corresponding to tK, and the event knowledge (tK, knowledge) 310 at time K is also input into the large-scale language model 308 to train the large-scale language model 308.
[0077] In another optional embodiment, Figure 4 is a schematic diagram of training a deep learning model according to an embodiment of the present application, such as Figure 4As shown, from all query requests issued by users to the database in the historical time period, query requests whose sending time is later than the sending time of multiple historical query requests are extracted to obtain query information of time N, that is, training query requests. Based on the query information of time N, event information of time K that matches the query information of time N is recalled from the event knowledge base, that is, the event information base, that is, the training event information. Among them, N is approximately equal to K. The query information of time N and the event information of time K are input into a large-scale language model, that is, a deep learning model. At the same time, the historical query requests of time M are also input into the large-scale language model, where M is less than N. The deep learning model is trained using the historical query requests of time M, the query information of time N, and the event information of time K to obtain the first prediction model.
[0078] Optionally, the first prediction model is a model obtained by training a deep learning model using multiple training sampling results, training query requests and training event information, wherein the multiple training sampling results are results obtained by sampling different training clustering sets, and different training clustering sets are sets obtained by clustering multiple historical query requests.
[0079] The multiple training sampling results in the above steps are query sequences obtained after clustering and sampling the historical query requests, and are used to train the first prediction model.
[0080] In an optional embodiment, feature extraction is performed on multiple historical query requests, and the multiple historical query requests are clustered according to the extracted features, and historical query requests with high feature similarity are classified into one category, that is, a training cluster set. Then, each training cluster set is sampled to obtain multiple training sampling results.
[0081] Multiple training sampling results, training query requests and training event information are input into the deep learning model, so that the deep learning model can fully learn the evolution trend of the query requests, so that the first prediction model obtained by training the deep learning model can predict the target query template of the future target query request based on the current initial query request.
[0082] Optionally, the training event information is event information determined based on the similarity between the training query request and different event information in the event information library, and the similarity between the query time of the training query request and the event time of the different event information.
[0083] The query time of the training query request in the above step is the time when the user issued the training query request in the past.
[0084] The event time of different event information in the above steps is the time when the event information is generated, such as the time of a special holiday, the time of a memorial day, etc.
[0085] In an optional embodiment, the formula for calculating the similarity between the training query request and different event information in the event information library is as follows:
[0086]
[0087] Among them, Dis(x g ,x q ) represents the similarity between the training query request and different event information in the event information database, d represents the number of different event information in the event information database, and x gi is the training query request, x qi It is different event information in the event information library.
[0088] The formula for calculating the similarity between the query time of the training query request and the event time of different event information is as follows:
[0089]
[0090] Among them, Sim(t k ,t j ) is the similarity between the query time of the training query request and the event time of different event information, t j is the query time of the training query request, t k The event time of different event information.
[0091] Based on the similarity between the training query request and different event information in the event information database, and the similarity between the query time of the training query request and the event time of different event information, the formula for recalling the training event information is as follows:
[0092]
[0093] Among them, Score(t k ,t j ,g,q) is the training event information, Sim(t k ,t j ) is the similarity between the query time of the training query request and the event time of different event information, Dis(x g ,x q ) represents the similarity between the training query request and different event information in the event information database.
[0094] Optionally, a target query request containing a target variable value is obtained based on the target query template prediction, including: decoupling the target query template to obtain the target variable contained in the target query request; inputting the target variable into a second prediction model, using the second prediction model to predict the variable value corresponding to the target variable, and obtaining the target query request containing the target variable value output by the second prediction model.
[0095] The target variable in the above steps is the variable corresponding to the target query request, and the target variable value is the specific value of the target variable predicted by the second prediction model.
[0096] The second prediction model in the above steps is pre-trained and used to predict the variable value corresponding to the target variable, and may be a Bayesian model, but is not limited thereto.
[0097] In an optional embodiment, Figure 5 is a schematic diagram of using the second prediction model to predict a target query request according to an embodiment of the present application, such as Figure 5 As shown, the target query template is decoupled, the conditional variables in the target query template are identified, and the conditional variables are used as the target variables included in the target query request. The target query template and the target variable are input into the trained Bayesian model, that is, the second prediction model, and the specific value corresponding to the target variable is predicted by the Bayesian model, and the specific value predicted by the Bayesian model is used as the target variable value. The second prediction model is used to predict and output statements in multiple materialized views based on the target query target and the target variable value, that is, the target query request containing the target variable value.
[0098] Optionally, the second prediction model is a model obtained by training a statistical model using a training query template, training query variables, and training variable values corresponding to the training query variables, wherein the training query template and the training query variables are the results of decoupling query requests in the training materialized view, and the training variable values are the variable values contained in the training materialized view.
[0099] The training materialized view in the above steps is a materialized view used to train the statistical model. A materialized view with a high usage frequency can be selected from the historical materialized views as the training materialized view. The high usage frequency of the materialized view can indicate that the materialized view has a high probability of hitting the user's query request. Using a materialized view with a high usage frequency to train the statistical model can enable the statistical model to fully learn the corresponding relationship between the query target and the query request, thereby improving the prediction accuracy of the second prediction model for the target query request.
[0100] The training query template in the above steps is a query template obtained by decoupling the query request in the training materialized view.
[0101] The training query variable in the above steps is a conditional variable obtained by decoupling the query request in the training materialized view. The training variable value is the specific value corresponding to the training query variable.
[0102] The statistical model in the above steps may be a Bayesian model, a random forest model, or a linear regression model, but is not limited thereto.
[0103] In an optional embodiment, Figure 6 is a schematic diagram of training a statistical model according to an embodiment of the present application, such as Figure 6 As shown, high-frequency query requests can be selected from multiple query requests in the past period of time to form a high-frequency materialized view, and the high-frequency materialized view can be used as a training materialized view for training the Bayesian model, where the Bayesian model is also a statistical model. The query requests in the training materialized view are decoupled, the query requests are parsed, and the query format and query conditions are extracted from them. The query format is used as a training query template, and the query conditions are used as training query variables. The specific value of the query condition, that is, the condition variable value, is then extracted as the training variable value corresponding to the training query variable. The training query template, the training query variable, and the training variable value corresponding to the training query variable are input into the Bayesian model, so that the Bayesian model learns the co-occurrence probability of the query template and the query variable, and then the second prediction model obtained by training can predict the target query request containing the target variable value based on the target variable.
[0104] Optionally, the training materialized view is a materialized view extracted from query request traffic.
[0105] The query request flow in the above steps is the query load, which includes the frequency, type, execution time and resource requirements of the query requests received by the database server within a certain period of time. The query load can represent the workload of the database when processing query requests.
[0106] In an optional embodiment, a materialized view can be extracted from the query load, that is, the query request flow, to construct a materialized view candidate set, and then the hit rates of different materialized views are recorded, a hit rate threshold is set, and a materialized view with a hit rate higher than the hit rate threshold is selected from the materialized view candidate set as a training materialized view. It should be noted that the hit rate threshold can be set according to actual application conditions, and the specific value of the hit rate threshold is not limited here.
[0107] A preferred embodiment is described below. Figure 7 is a schematic diagram of generating a target materialized view according to an embodiment of the present application, such as Figure 7As shown, in the process of using the model to generate a materialized view, the real-time query request, that is, the initial query request, is input into the large-scale language model. The large-scale language model is also the first prediction model. The large-scale language model predicts based on the real-time query request to obtain the materialized view seed, that is, the target query template. The materialized view seed is input into the Bayesian model, that is, the second prediction model. The Bayesian model predicts the target query request containing the target variable value based on the target variable obtained by decoupling the materialized view seed. Based on the target query request and the target query structure corresponding to the target query request, the target materialized view can be constructed. After the target materialized view is generated, the target materialized view is stored in the database to provide query services for users. In the model training process, the large-scale language model is trained based on historical query requests and event information base. The trained large-scale language model has semantic understanding ability. Combined with the event information base, that is, information such as seasons, festivals, and holidays, it can perceive long-term user behavior preferences and predict materialized view behavior preference information, that is, materialized view seeds. The materialized view seeds predicted based on the large-scale language model can reflect the structure of the query request of user preference and provide a basis for predicting the target query request that meets the user preference. The Bayesian model is trained based on the materialized view with high usage frequency, that is, the training materialized view. The trained Bayesian model can predict the specific behavior of users based on the materialized view seed, and predict the behavior that the user has not yet appeared, so as to generate the target query request that meets the user's preferences in advance. The target materialized view constructed based on the target query request that meets the user's preferences has a high hit rate for the user's query request, which can reduce the complex query of the database, improve the response speed of the user's query request, and reduce the system pressure caused by the user's dynamic new behavior.
[0108] 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 this application 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.
[0109] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain 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 present application.
[0110] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, disk, CD), including several instructions for enabling a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0111] According to an embodiment of the present application, an embodiment of a data query method is also provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0112] Figure 8 is a flow chart of a data query method according to an embodiment of the present application, such as Figure 8 As shown, the method may include the following steps:
[0113] Step S802, receiving a current query request sent by a client;
[0114] Step S804, matching the current query request with a pre-generated target materialized view, wherein the target materialized view is a materialized view generated by the above method;
[0115] Step S806, when the current query request successfully matches the target query request in the target materialized view, obtaining the query result corresponding to the target query request from the target materialized view, and obtaining the target query result corresponding to the current query request;
[0116] Step S808: sending the target query result to the client.
[0117] The current query request in the above steps is the query request currently issued by the user. The user can enter a query statement in the input box of the interactive interface, and the client generates the current query request after detecting the query statement entered by the user.
[0118] After the materialized view is generated, it will be stored in the database for providing data query services. Specifically, after receiving the current query request sent by the client, the current query request is matched with the pre-generated target materialized view. If there is a target query request that is consistent with the current query request in the target materialized view, the match is successful, and the query result corresponding to the target query request can be directly obtained from the target materialized view, and it is returned to the client as the target query result corresponding to the current query request. In the case of a successful match, the target query result can be directly obtained from the target materialized view without having to perform complex queries on the database, thereby improving the efficiency of data query.
[0119] If there is no target query request that is consistent with the current query request in the target materialized view, the match fails. At this time, the database can be queried based on the current query request to obtain the target query result, and the target query result is sent to the client.
[0120] It should be noted that the preferred implementation scheme involved in the above embodiments of the present application is the same as the scheme provided in the embodiments, as well as the application scenario and implementation process, but is not limited to the scheme provided in the embodiments.
[0121] According to an embodiment of the present application, an embodiment of a product query method is also provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0122] Fig. 9 is a flow chart of a product data query method according to an embodiment of the present application. Fig. 9 As shown, the method may include the following steps:
[0123] Step S902, receiving a current query request sent by a client, wherein the current query request is used to query a target product;
[0124] Step S904, matching the current query request with a pre-generated target materialized view, wherein the target materialized view is a materialized view generated by the above method, and the target materialized view is used to characterize the mapping relationship between the query request and the product to be queried;
[0125] Step S906, when the current query request successfully matches the target query request in the target materialized view, the target product to be queried corresponding to the target query request is obtained from the target materialized view to obtain the query result of the target product;
[0126] Step S908: sending the query result of the target product to the client.
[0127] The above method can be applied to e-commerce scenarios, and the target materialized view can be used to query products in e-commerce scenarios.
[0128] The target product in the above steps is the product corresponding to the current query request, that is, the product that the user currently wants to query.
[0129] The products to be queried in the above steps are products pre-stored in the target materialized view and have a corresponding relationship with the query request in the target materialized view.
[0130] The target product to be queried in the above step is a product among the products to be queried that corresponds to the target query request when the target query request matches the current query request.
[0131] It should be noted that the preferred implementation scheme involved in the above embodiments of the present application is the same as the scheme provided in the embodiments, as well as the application scenario and implementation process, but is not limited to the scheme provided in the embodiments.
[0132] According to an embodiment of the present application, an embodiment of a method for generating a materialized view is also provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0133] Fig.10 is a flow chart of a method for generating a materialized view according to an embodiment of the present application, such as Fig.10 As shown, the method may include the following steps:
[0134] Step S1002, obtaining an initial query request by calling a first interface, wherein the first interface includes a first parameter, and a parameter value of the first parameter includes the initial query request;
[0135] Step S1004, using the first prediction model to perform query request prediction based on the initial query request, and obtaining a target query template of the target query request, wherein the target query template is used to characterize the structure of the target query request, and the target query request is used to characterize the query request within a preset time period after the current moment;
[0136] Step S1006, using the second prediction model to perform query request prediction based on the target query template to obtain a target query request, wherein the target query request includes a variable value corresponding to the target query template;
[0137] Step S1008, generating a target materialized view based on the mapping relationship between the target query request and the target query result corresponding to the target query request;
[0138] Step S1010 : outputting a target materialized view by calling a second interface, wherein the second interface includes a second parameter, and a parameter value of the second parameter includes the target materialized view.
[0139] The first interface in the above steps is an interface for the server to obtain data from the client. The first parameter is a parameter of the first interface, which may be an initial query request that the client wants to send to the server.
[0140] The second interface in the above steps is an interface for the client to obtain data from the server. The second parameter is a parameter of the second interface, which can be a target materialized view that the server wants to transmit to the client.
[0141] It should be noted that the preferred implementation scheme involved in the above embodiments of the present application is the same as the scheme provided in the embodiments, as well as the application scenario and implementation process, but is not limited to the scheme provided in the embodiments.
[0142] According to an embodiment of the present application, a device for generating a materialized view for implementing the above embodiment is also provided. Fig.11 As shown, the device comprises:
[0143] A target query template display module 110 is used to respond to an initial query request acting on an operation interface and display a target query template of the target query request on the operation interface, wherein the target query template is used to characterize the structure of the target query request predicted based on the initial query request, and the target query request is used to characterize a query request within a preset time period after the current moment;
[0144] The target query request display module 112 is used to respond to the confirmation instruction acting on the operation interface and display the target query request including the target variable value on the operation interface, wherein the target variable value is used to represent the variable value corresponding to the target query template and obtained by prediction based on the target query template;
[0145] The target materialized view display module 114 is used to respond to the generation instruction acting on the operation interface and display the target materialized view on the operation interface, wherein the target materialized view is used to represent the mapping relationship between the target query request and the target query result corresponding to the target query request.
[0146] Optionally, the target query template display module also includes: a clustering unit, used to cluster multiple sub-requests to obtain at least one initial clustering set; a sampling unit, used to sample different initial clustering sets to obtain multiple initial sampling results; an acquisition unit, used to input the multiple initial sampling results into the first prediction model, and obtain the target query template output by the first prediction model.
[0147] Optionally, the first prediction model in the acquisition unit is a model obtained by training a deep learning model using multiple historical query requests, training query requests corresponding to the multiple historical query requests, and training event information, wherein the training event information is event information obtained by recalling event information in an event information library based on the training query requests.
[0148] Optionally, the first prediction model in the acquisition unit is a model obtained by training a deep learning model using multiple training sampling results, training query requests and training event information, wherein the multiple training sampling results are results obtained by sampling different training clustering sets, and different training clustering sets are sets obtained by clustering multiple historical query requests.
[0149] Optionally, the training event information in the acquisition unit is event information determined based on the similarity between the training query request and different event information in the event information library, and the similarity between the query time of the training query request and the event time of the different event information.
[0150] Optionally, the target query request display module also includes: a decoupling unit, used to decouple the target query template to obtain the target variable contained in the target query request; a prediction unit, used to input the target variable into a second prediction model, use the second prediction model to predict the variable value corresponding to the target variable, and obtain the target query request containing the target variable value output by the second prediction model.
[0151] Optionally, the second prediction model in the prediction unit is a model obtained by training the statistical model using a training query template, a training query variable, and training variable values corresponding to the training query variables, wherein the training query template and the training query variables are the results of decoupling the query requests in the training materialized view, and the training variable values are the variable values contained in the training materialized view.
[0152] Optionally, the training materialized view in the prediction unit is a materialized view extracted from query request traffic.
[0153] It should be noted that the target query template display module 110, the target query request display module 112, and the target materialized view display module 114 correspond to steps S202 to S206 in the embodiment, and the three modules and the corresponding steps implement the same instances and application scenarios, but are not limited to the contents disclosed in the above embodiment. It should be noted that the above modules or units can be hardware components or software components stored in a memory and processed by one or more processors, and the above modules can also be run in the server 10 provided in the embodiment as part of the device.
[0154] It should be noted that the preferred implementation scheme involved in the above embodiments of the present application is the same as the scheme provided in the embodiments, as well as the application scenario and implementation process, but is not limited to the scheme provided in the embodiments.
[0155] According to an embodiment of the present application, a data query device for implementing the above embodiment is also provided. Fig.12 As shown, the device comprises:
[0156] The receiving module 120 is used to receive the current query request sent by the client;
[0157] A matching module 122, used to match the current query request with a pre-generated target materialized view, wherein the target materialized view is a materialized view generated by the above method;
[0158] The acquisition module 124 is used to acquire the query result corresponding to the target query request from the target materialized view when the current query request successfully matches the target query request in the target materialized view, so as to obtain the target query result corresponding to the current query request;
[0159] The sending module 126 is used to send the target query result to the client.
[0160] It should be noted that the receiving module 120, matching module 122, acquisition module 124, and sending module 126 correspond to steps S802 to S808 in the embodiment, and the four modules and the corresponding steps implement the same examples and application scenarios, but are not limited to the contents disclosed in the above embodiment. It should be noted that the above modules or units can be hardware components or software components stored in a memory and processed by one or more processors, and the above modules can also be run in the server 10 provided in the embodiment as part of the device.
[0161] It should be noted that the preferred implementation scheme involved in the above embodiments of the present application is the same as the scheme provided in the embodiments, as well as the application scenario and implementation process, but is not limited to the scheme provided in the embodiments.
[0162] According to an embodiment of the present application, a product data query device for implementing the above embodiment is also provided. Fig.13 As shown, the device comprises:
[0163] The receiving module 130 is used to receive a current query request sent by a client, wherein the current query request is used to query a target product;
[0164] A matching module 132 is used to match the current query request with a pre-generated target materialized view, wherein the target materialized view is a materialized view generated by the above method, and the target materialized view is used to represent the mapping relationship between the query request and the product to be queried;
[0165] The acquisition module 134 is used to acquire the target product to be queried corresponding to the target query request from the target materialized view when the current query request successfully matches the target query request in the target materialized view, and obtain the query result of the target product;
[0166] The sending module 136 is used to send the query result of the target product to the client.
[0167] It should be noted that the receiving module 130, matching module 132, acquisition module 134, and sending module 136 correspond to steps S902 to S908 in the embodiment, and the four modules and the corresponding steps implement the same examples and application scenarios, but are not limited to the contents disclosed in the above embodiment. It should be noted that the above modules or units can be hardware components or software components stored in a memory and processed by one or more processors, and the above modules can also be run in the server 10 provided in the embodiment as part of the device.
[0168] It should be noted that the preferred implementation scheme involved in the above embodiments of the present application is the same as the scheme provided in the embodiments, as well as the application scenario and implementation process, but is not limited to the scheme provided in the embodiments.
[0169] According to an embodiment of the present application, a device for generating a materialized view for implementing the above embodiment is also provided. Fig.14 As shown, the device comprises:
[0170] The acquisition module 140 is configured to acquire an initial query request by calling a first interface, wherein the first interface includes a first parameter, and a parameter value of the first parameter includes the initial query request;
[0171] A first prediction module 142 is used to use a first prediction model to perform query request prediction based on the initial query request to obtain a target query template of a target query request, wherein the target query template is used to characterize the structure of the target query request, and the target query request is used to characterize the query request within a preset time period after the current moment;
[0172] A second prediction module 144 is configured to use a second prediction model to perform query request prediction based on the target query template to obtain a target query request, wherein the target query request includes a variable value corresponding to the target query template;
[0173] A generating module 146, configured to generate a target materialized view based on a mapping relationship between a target query request and a target query result corresponding to the target query request;
[0174] The output module 148 is configured to output the target materialized view by calling a second interface, wherein the second interface includes a second parameter, and a parameter value of the second parameter includes the target materialized view.
[0175] It should be noted that the acquisition module 140, the first prediction module 142, the second prediction module 144, the generation module 146, and the output module 148 correspond to steps S1002 to S1010 in the embodiment, and the five modules and the corresponding steps implement the same examples and application scenarios, but are not limited to the contents disclosed in the above embodiment. It should be noted that the above modules or units can be hardware components or software components stored in a memory and processed by one or more processors, and the above modules can also be run in the server 10 provided in the embodiment as part of the device.
[0176] It should be noted that the preferred implementation scheme involved in the above embodiments of the present application is the same as the scheme provided in the embodiments, as well as the application scenario and implementation process, but is not limited to the scheme provided in the embodiments.
[0177] The embodiment of the present application may provide an electronic device, which may be any electronic device in a group of electronic devices. Optionally, in this embodiment, the electronic device may also be replaced by a terminal device such as a mobile terminal.
[0178] Optionally, in this embodiment, the electronic device may be located in at least one network device among a plurality of network devices of a computer network.
[0179] In this embodiment, the computer terminal can execute the program code in the method.
[0180] Optionally, Fig.15 is a structural block diagram of an electronic device according to an embodiment of the present application. Fig.15 As shown, the electronic device A may include: one or more (only one is shown in the figure) processors 152, a memory 154, a storage controller, and a peripheral interface, wherein the peripheral interface is connected to a radio frequency module, an audio module, and a display.
[0181] Among them, the memory can be used to store software programs and modules, such as program instructions / modules corresponding to the methods and devices in the embodiments of the present application. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory, that is, implementing the methods in the above embodiments. The memory may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory may further include a memory remotely arranged relative to the processor, and these remote memories may be connected to the terminal A via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0182] The processor can call the information and application stored in the memory through the transmission device to perform the following steps: in response to an initial query request acting on the operation interface, a target query template of the target query request is displayed on the operation interface, wherein the target query template is used to characterize the structure of the target query request predicted based on the initial query request, and the target query request is used to characterize the query request within a preset time period after the current moment; in response to a confirmation instruction acting on the operation interface, a target query request including a target variable value is displayed on the operation interface, wherein the target variable value is used to characterize the variable value corresponding to the target query template predicted based on the target query template; in response to a generation instruction acting on the operation interface, a target materialized view is displayed on the operation interface, wherein the target materialized view is used to characterize the mapping relationship between the target query request and the target query result corresponding to the target query request.
[0183] Optionally, the processor may also execute program code for the following steps: clustering multiple sub-requests to obtain at least one initial clustering set; sampling different initial clustering sets to obtain multiple initial sampling results; inputting the multiple initial sampling results into the first prediction model, and obtaining the target query template output by the first prediction model.
[0184] Optionally, the processor may also execute the following program code: the first prediction model is a model obtained by training a deep learning model using multiple historical query requests, training query requests corresponding to the multiple historical query requests, and training event information, wherein the training event information is event information obtained by recalling event information in an event information library based on the training query requests.
[0185] Optionally, the processor may also execute the following program code: the first prediction model is a model obtained by training a deep learning model using multiple training sampling results, training query requests, and training event information, wherein the multiple training sampling results are results obtained by sampling different training clustering sets, and different training clustering sets are sets obtained by clustering multiple historical query requests.
[0186] Optionally, the processor may also execute the following program code: the training event information is event information determined based on the similarity between the training query request and different event information in the event information library, and the similarity between the query time of the training query request and the event time of different event information.
[0187] Optionally, the processor may also execute the following program code steps: decoupling the target query template to obtain the target variable contained in the target query request; inputting the target variable into the second prediction model, using the second prediction model to predict the variable value corresponding to the target variable, and obtaining the target query request containing the target variable value output by the second prediction model.
[0188] Optionally, the processor may also execute the following program code: the second prediction model is a model obtained by training the statistical model using a training query template, training query variables, and training variable values corresponding to the training query variables, wherein the training query template and the training query variables are the results of decoupling the query requests in the training materialized view, and the training variable values are the variable values contained in the training materialized view.
[0189] Optionally, the processor may also execute the following program code: the training materialized view is a materialized view extracted from the query request traffic.
[0190] The processor can call the information and application stored in the memory through the transmission device to perform the following steps: receive the current query request sent by the client; match the current query request with a pre-generated target materialized view, wherein the target materialized view is a materialized view generated by the above-mentioned materialized view generation method; when the current query request successfully matches the target query request in the target materialized view, obtain the query result corresponding to the target query request from the target materialized view to obtain the target query result corresponding to the current query request; and send the target query result to the client.
[0191] The processor can call the information and application stored in the memory through the transmission device to execute the following steps: receive the current query request sent by the client, wherein the current query request is used to query the target product; match the current query request with a pre-generated target materialized view, wherein the target materialized view is a materialized view generated using the above-mentioned materialized view generation method, and the target materialized view is used to characterize the mapping relationship between the query request and the product to be queried; when the current query request successfully matches the target query request in the target materialized view, obtain the target product to be queried corresponding to the target query request from the target materialized view to obtain the query result of the target product; and send the query result of the target product to the client.
[0192] The processor can call the information and application stored in the memory through the transmission device to perform the following steps: obtain an initial query request by calling a first interface, wherein the first interface includes a first parameter, and the parameter value of the first parameter includes the initial query request; use the first prediction model to predict the query request based on the initial query request to obtain a target query template for the target query request, wherein the target query template is used to characterize the structure of the target query request, and the target query request is used to characterize the query request within a preset time period after the current moment; use the second prediction model to predict the query request based on the target query template to obtain the target query request, wherein the target query request includes the variable value corresponding to the target query template; generate a target materialized view based on the mapping relationship between the target query request and the target query result corresponding to the target query request; output the target materialized view by calling a second interface, wherein the second interface includes a second parameter, and the parameter value of the second parameter includes the target materialized view.
[0193] According to the embodiment of the present application, in response to an initial query request acting on an operation interface, a target query template of a target query request is displayed on the operation interface; in response to a confirmation instruction acting on the operation interface, a target query request including a target variable value is displayed on the operation interface; in response to a generation instruction acting on the operation interface, a target materialized view is displayed on the operation interface. It is easy to notice that a target query template representing the structure of a target query request is predicted based on an initial query request, and a target variable of a target query request is predicted based on a target query template, thereby predicting target query requests that will be frequently used by users in the future, and constructing a target materialized view based on target query requests and target query results that will be frequently used by users in the future, thereby increasing the probability that the target materialized view hits a query request issued by a user, thereby achieving the purpose of improving the effectiveness of the materialized view, and thus solving the technical problem of poor effectiveness of the materialized view.
[0194] It will be understood by those skilled in the art that the structure shown in the figure is for illustration only, and the electronic device may also be a terminal device such as a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a PDA, and a mobile Internet device (Mobile Internet Devices, MID), PAD, etc. The figure does not limit the structure of the above-mentioned electronic device. For example, the electronic device A may also include more or fewer components (such as a network interface, a display device, etc.) than those shown in the figure, or have a configuration different from that shown in the figure.
[0195] A person of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing the hardware related to the terminal device through a program, and the program can be stored in a computer-readable storage medium, and the storage medium may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0196] The embodiment of the present application further provides a computer-readable storage medium. Optionally, in this embodiment, the computer-readable storage medium can be used to store the program code executed by the method provided in the above embodiment.
[0197] Optionally, in this embodiment, the above storage medium may be located in any electronic device in a group of electronic devices in a computer network, or in any mobile terminal in a group of mobile terminals.
[0198] Optionally, in this embodiment, the computer-readable storage medium is configured to store program codes for executing the following steps: in response to an initial query request acting on an operation interface, displaying a target query template of the target query request on the operation interface, wherein the target query template is used to characterize the structure of the target query request predicted based on the initial query request, and the target query request is used to characterize the query request within a preset time period after the current moment; in response to a confirmation instruction acting on the operation interface, displaying a target query request including a target variable value on the operation interface, wherein the target variable value is used to characterize the variable value corresponding to the target query template predicted based on the target query template; in response to a generation instruction acting on the operation interface, displaying a target materialized view on the operation interface, wherein the target materialized view is used to characterize the mapping relationship between the target query request and the target query result corresponding to the target query request.
[0199] Optionally, the computer-readable storage medium is also configured to store program code for performing the following steps: clustering multiple sub-requests to obtain at least one initial clustering set; sampling different initial clustering sets to obtain multiple initial sampling results; inputting the multiple initial sampling results into a first prediction model, and obtaining a target query template output by the first prediction model.
[0200] Optionally, the computer-readable storage medium is also configured to store program code for performing the following steps: the first prediction model is a model obtained by training a deep learning model using multiple historical query requests, training query requests corresponding to the multiple historical query requests, and training event information, wherein the training event information is event information obtained by recalling event information in an event information library based on the training query requests.
[0201] Optionally, the computer-readable storage medium is also configured to store program code for performing the following steps: the first prediction model is a model obtained by training a deep learning model using multiple training sampling results, training query requests and training event information, wherein the multiple training sampling results are results obtained by sampling different training clustering sets, and the different training clustering sets are sets obtained by clustering multiple historical query requests.
[0202] Optionally, the computer-readable storage medium is also configured to store program code for performing the following steps: the training event information is event information determined based on the similarity between the training query request and different event information in the event information library, and the similarity between the query time of the training query request and the event time of different event information.
[0203] Optionally, the computer-readable storage medium is also configured to store program code for executing the following steps: decoupling the target query template to obtain a target variable contained in the target query request; inputting the target variable into a second prediction model, using the second prediction model to predict a variable value corresponding to the target variable, and obtaining a target query request containing the target variable value output by the second prediction model.
[0204] Optionally, the computer-readable storage medium is also configured to store program code for executing the following steps: the second prediction model is a model obtained by training the statistical model using a training query template, training query variables, and training variable values corresponding to the training query variables, wherein the training query template and the training query variables are the results of decoupling the query requests in the training materialized view, and the training variable values are the variable values contained in the training materialized view.
[0205] Optionally, the computer-readable storage medium is further configured to store program code for executing the following steps: the training materialized view is a materialized view extracted from the query request traffic.
[0206] Optionally, in this embodiment, the computer-readable storage medium is configured to store program code for executing the following steps: receiving a current query request sent by a client; matching the current query request with a pre-generated target materialized view, wherein the target materialized view is a materialized view generated using the above-mentioned materialized view generation method; in a case where the current query request successfully matches the target query request in the target materialized view, obtaining a query result corresponding to the target query request from the target materialized view to obtain a target query result corresponding to the current query request; and sending the target query result to the client.
[0207] Optionally, in this embodiment, a computer-readable storage medium is configured to store program code for executing the following steps: receiving a current query request sent by a client, wherein the current query request is used to query a target product; matching the current query request with a pre-generated target materialized view, wherein the target materialized view is a materialized view generated using the above-mentioned materialized view generation method, and the target materialized view is used to characterize the mapping relationship between the query request and the product to be queried; when the current query request successfully matches the target query request in the target materialized view, obtaining the target product to be queried corresponding to the target query request from the target materialized view, and obtaining a query result for the target product; and sending the query result for the target product to the client.
[0208] Optionally, in this embodiment, a computer-readable storage medium is configured to store program code for executing the following steps: obtaining an initial query request by calling a first interface, wherein the first interface includes a first parameter, and a parameter value of the first parameter includes the initial query request; using a first prediction model to predict a query request based on the initial query request to obtain a target query template for a target query request, wherein the target query template is used to characterize the structure of the target query request, and the target query request is used to characterize a query request within a preset time period after a current moment; using a second prediction model to predict a query request based on the target query template to obtain a target query request, wherein the target query request includes a variable value corresponding to the target query template; generating a target materialized view based on a mapping relationship between the target query request and a target query result corresponding to the target query request; and outputting the target materialized view by calling a second interface, wherein the second interface includes a second parameter, and a parameter value of the second parameter includes the target materialized view.
[0209] The embodiment of the present application further provides a computer program product. Optionally, in this embodiment, the computer program product may include a computer program, and the computer program implements the method provided in the embodiment when executed by a processor.
[0210] The embodiments of the present application also provide a computer program product. Optionally, the computer program product may include a non-volatile computer-readable storage medium, which may be used to store a computer program, and when the computer program is executed by a processor, the method provided in the embodiments is implemented.
[0211] The embodiment of the present application further provides a computer program. Optionally, in this embodiment, when the computer program is executed by a processor, the method provided in the above embodiment is implemented.
[0212] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0213] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0214] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0215] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0216] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0217] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program codes.
[0218] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A method for generating a materialized view, characterized in that: include: Get the initial query request; Predicting a target query request based on the initial query request to obtain a target query template for the target query request, wherein the target query request is used to characterize a query request within a preset time period after a current moment, and the target query template is used to characterize a structure of the target query request; Predicting the target query request including the target variable value based on the target query template, wherein the target query template is used to represent the variable value corresponding to the target query template; In response to a generation instruction acting on the operation interface, a target materialized view is displayed on the operation interface, wherein the target materialized view is used to represent a mapping relationship between the target query request and the target query result corresponding to the target query request, and to generate the target materialized view.
2. The method according to claim 1, characterized in that: The initial query request includes a plurality of sub-requests, and the predicting the target query request based on the initial query request to obtain a target query template of the target query request includes: Clustering the multiple sub-requests to obtain at least one initial clustering set; Sampling different initial clustering sets to obtain multiple initial sampling results; The multiple initial sampling results are input into a first prediction model, and the target query template output by the first prediction model is obtained.
3. The method according to claim 1 or 2, characterized in that: The first prediction model is a model obtained by training a deep learning model using multiple historical query requests, training query requests corresponding to the multiple historical query requests, and training event information, wherein the training event information is event information obtained by recalling event information in an event information library based on the training query requests.
4. The method according to claim 3, characterized in that: The first prediction model is a model obtained by training the deep learning model using multiple training sampling results, the training query requests and the training event information, wherein the multiple training sampling results are the results of sampling different training clustering sets, and different training clustering sets are sets obtained by clustering the multiple historical query requests.
5. The method according to claim 3, characterized in that: The training event information is event information determined based on the similarity between the training query request and different event information in the event information library, and the similarity between the query time of the training query request and the event time of the different event information.
6. The method according to claim 1, characterized in that The step of obtaining the target query request including the target variable value based on the target query template prediction includes: Decoupling the target query template to obtain a target variable included in the target query request; The target variable is input into a second prediction model, the variable value corresponding to the target variable is predicted using the second prediction model, and the target query request including the target variable value output by the second prediction model is obtained.
7. The method according to claim 1 or 6, characterized in that: The second prediction model is a model obtained by training a statistical model using a training query template, a training query variable, and a training variable value corresponding to the training query variable, wherein the training query template and the training query variable are the results of decoupling the query request in the training materialized view, and the training variable value is the variable value contained in the training materialized view.
8. The method according to claim 7, characterized in that The training materialized view is a materialized view extracted from query request traffic.
9. A data query method, characterized in that: include: Receive the current query request sent by the client; Matching the current query request with a pre-generated target materialized view, wherein the target materialized view is a materialized view generated by the method according to any one of claims 1 to 8; When the current query request successfully matches the target query request in the target materialized view, obtaining a query result corresponding to the target query request from the target materialized view to obtain the target query result corresponding to the current query request; Send the target query result to the client.
10. A product query method, characterized in that: include: Receiving a current query request sent by a client, wherein the current query request is used to query a target product; Matching the current query request with a pre-generated target materialized view, wherein the target materialized view is a materialized view generated by the method described in any one of claims 1 to 8, and the target materialized view is used to characterize the mapping relationship between the query request and the product to be queried; When the current query request successfully matches the target query request in the target materialized view, obtaining the target product to be queried corresponding to the target query request from the target materialized view to obtain the query result of the target product; Send the query result of the target product to the client.
11. A method for generating a materialized view, characterized in that: include: Acquire an initial query request by calling a first interface, wherein the first interface includes a first parameter, and a parameter value of the first parameter includes the initial query request; Using the first prediction model to perform query request prediction based on the initial query request, to obtain a target query template of the target query request, wherein the target query template is used to characterize the structure of the target query request, and the target query request is used to characterize the query request within a preset time period after the current moment; Using a second prediction model to predict a query request based on the target query template to obtain the target query request, wherein the target query request includes a variable value corresponding to the target query template; Generate a target materialized view based on the mapping relationship between the target query request and the target query result corresponding to the target query request; The target materialized view is output by calling a second interface, wherein the second interface includes a second parameter, and a parameter value of the second parameter includes the target materialized view.
12. An electronic device, characterized in that: include: A memory storing an executable program; A processor, configured to run the program, wherein the program executes the method according to any one of claims 1 to 11 when running.
13. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored executable program, wherein when the executable program is executed, the device where the computer-readable storage medium is located is controlled to execute the method according to any one of claims 1 to 11.
14. A computer program product, characterized in that The invention comprises a computer program which, when executed by a processor, implements the method according to any one of claims 1 to 11.
Citation Information
Patent Citations
Database materialized view construction system and method and system creation method
CN111597209A
Data query method, electronic equipment and computer readable storage medium
CN116541418A
Automated query selectivity predictions using query graphs
US11921719B1
Predicting future query rewrite patterns for materialized views
US20220083548A1
Cited By
Training method and device of intention recognition model, equipment and medium
CN121302040A
