Time prediction model training method, time prediction method and device

By constructing a correlation between SQL statements and grayscale images and training a convolutional neural network model, the timeliness and accuracy issues of SQL statement execution time prediction in existing technologies are solved, achieving fast and accurate SQL statement execution time prediction.

CN117453714BActive Publication Date: 2026-11-27CHINA UNITED NETWORK COMM GRP CO LTD +2
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311425911.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-10-30
Publication Date
2026-11-27
Estimated Expiration
2043-10-30

AI Technical Summary

Technical Problem

In existing technologies, log-based monitoring methods cannot effectively predict the timeliness of SQL statement execution, while word frequency analysis-based solutions have poor prediction accuracy, making it difficult to accurately predict the execution time of complex SQL statements.

Method used

By constructing a correlation between SQL statements and grayscale images, and using grayscale images for model training, the execution time of SQL statements is transformed into a regression problem in the field of deep learning. A convolutional neural network model is then used for training to predict the execution time of SQL statements.

Benefits of technology

It enables fast and accurate prediction of SQL statement execution time, improving prediction accuracy and efficiency, and adapting to changes in various business scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117453714B_ABST
    Figure CN117453714B_ABST
Patent Text Reader

Abstract

The application provides a time prediction model training method, a time prediction method and device, and relates to the technical field of databases.The method comprises the following steps: obtaining a first data set, wherein the first data set comprises a plurality of SQL statements with execution time greater than a threshold value and labels of the SQL statements; converting the SQL statements in the target data set into corresponding grayscale images, and taking the labels of the SQL statements as the labels of the grayscale images to obtain a second data set; and training a time prediction model to be trained by using the second data set to obtain a trained time prediction model. The execution time of the SQL statement can be quickly and accurately predicted by using the trained time prediction model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of database technology, and in particular to a time prediction model training method, time prediction method and apparatus. Background Technology

[0002] Structured Query Language (SQL) is a language designed for database querying, primarily used for data storage, management, querying, and modification. As data volumes increase and query scenarios become more complex, the execution time of SQL statements is also growing. For users, knowing the execution time of SQL statements can help them better optimize their SQL queries and schedule execution. How to accurately predict the execution time of complex SQL statements is a technical problem that needs to be solved by those skilled in the art. Summary of the Invention

[0003] This application provides a time prediction model training method, a time prediction method, and an apparatus. By using a neural network model to predict the execution time of SQL statements, the accuracy of the SQL statement execution time can be improved.

[0004] Firstly, this application provides a method for training a time prediction model, including:

[0005] Obtain a first dataset, which includes multiple SQL statements whose execution time exceeds a threshold, and the labels of the SQL statements;

[0006] The SQL statements in the target dataset are converted into corresponding grayscale images, and the labels of the SQL statements are used as the labels of the grayscale images to obtain the second dataset;

[0007] The second dataset is used to train the time prediction model to be trained, resulting in a trained time prediction model.

[0008] Optionally, converting the SQL statements in the target dataset into corresponding grayscale images includes:

[0009] Convert the characters in the SQL statement to their corresponding encoding values ​​according to the character encoding table;

[0010] The gray level corresponding to the character is determined based on the encoded value and the preset bit depth of the grayscale image;

[0011] The SQL statement is converted based on the grayscale level to obtain a two-dimensional grayscale image corresponding to the SQL statement.

[0012] Optionally, before converting the characters of the SQL statement to their corresponding encoded values ​​according to the character encoding table, the method further includes:

[0013] The SQL statements in the first dataset are processed according to a preset statement length and converted into SQL statements of fixed length.

[0014] Optionally, converting the SQL statements in the first dataset into fixed-length SQL statements includes:

[0015] If the length of the SQL statement is greater than the preset statement length, the SQL statement will be truncated to the last digit and converted into a SQL statement of fixed length.

[0016] If the length of the SQL statement is less than the preset statement length, then the SQL statement is padded at the end to convert it into a SQL statement of fixed length.

[0017] Optionally, the process of padding the SQL statement includes:

[0018] The SQL statement is padded with random characters at the end.

[0019] Secondly, this application provides a time prediction method, including:

[0020] Obtain the SQL statement to be predicted, and convert the SQL statement into a target SQL statement of a preset length;

[0021] Convert the target SQL statement into a corresponding grayscale image;

[0022] The grayscale image is input into the time prediction model to obtain the predicted execution time of the target SQL statement; the time prediction model is trained by the model training method according to any one of claims 1-5.

[0023] Thirdly, this application provides a time prediction model training device, comprising:

[0024] The acquisition module is used to acquire a first dataset, which includes multiple SQL statements whose execution time is greater than a threshold, and the labels of the SQL statements;

[0025] The conversion module is used to convert the SQL statements in the target dataset into corresponding grayscale images, and use the labels of the SQL statements as the labels of the grayscale images to obtain the second dataset;

[0026] The training module is used to train the time prediction model to be trained using the second dataset, so as to obtain the trained time prediction model.

[0027] Fourthly, this application provides a time prediction device, comprising:

[0028] The acquisition module is used to acquire the SQL statement to be predicted and convert the SQL statement into a target SQL statement of a preset length.

[0029] The conversion module is used to convert the target SQL statement into a corresponding grayscale image;

[0030] The prediction module is used to input the grayscale image into the time prediction model to obtain the predicted execution time of the target SQL statement; the time prediction model is trained by the model training method according to any one of claims 1-5.

[0031] Fifthly, this application provides an electronic device, including: a memory and a processor;

[0032] The memory is used to store computer instructions; the processor is used to execute the computer instructions stored in the memory to implement the method of any one of the first aspects.

[0033] In a sixth aspect, this application provides a computer-readable storage medium having a computer program stored thereon, the computer program being executed by a processor to implement the method of either the first or second aspect.

[0034] In a seventh aspect, this application provides a computer program product, including a computer program that, when executed by a processor, implements the method of either the first aspect or the second aspect.

[0035] This application provides a training method, a time prediction method, and an apparatus for a time prediction model. The method involves acquiring a first dataset, which includes multiple SQL statements with execution times exceeding a threshold, and the labels of these SQL statements. The SQL statements in the target dataset are then converted into corresponding grayscale images, and the labels of the SQL statements are used as the labels of the grayscale images to obtain a second dataset. The second dataset is then used to train the time prediction model to be trained, resulting in a trained time prediction model. Using the trained time prediction model to predict the execution time of SQL statements allows for fast and accurate prediction of execution time. Attached Figure Description

[0036] Figure 1 This is a schematic diagram of a scenario provided for an embodiment of this application;

[0037] Figure 2 A flowchart illustrating the time prediction model training method provided in this application embodiment;

[0038] Figure 3 A flowchart illustrating the time prediction method provided in this application embodiment;

[0039] Figure 4 A schematic diagram illustrating the model training and time prediction process provided in the embodiments of this application;

[0040] Figure 5 A schematic diagram of the structure of the time prediction model training device provided in the embodiments of this application;

[0041] Figure 6 A schematic diagram of the time prediction device provided in the embodiments of this application;

[0042] Figure 7 The following are schematic diagrams of the structure of the electronic device provided in the embodiments of this application. Detailed Implementation

[0043] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0044] In the embodiments of this application, the terms "first" and "second" are used to distinguish identical or similar items with essentially the same function and effect, without limiting their order. Those skilled in the art will understand that the terms "first" and "second" do not limit the quantity or execution order, and that the terms "first" and "second" do not necessarily imply that they are different.

[0045] It should be noted that, in the embodiments of this application, the terms "exemplary" or "for example" are used to indicate examples, illustrations, or descriptions. Any embodiment or design scheme described as "exemplary" or "for example" in this application should not be construed as being more preferred or advantageous than other embodiments or design schemes. Specifically, the use of terms such as "exemplary" or "for example" is intended to present the relevant concepts in a specific manner.

[0046] Structured Query Language (SQL) is a language designed for database queries, primarily used for data storage, management, querying, and modification. As data volumes increase and query scenarios become more complex, the execution time of SQL statements also grows. For users, knowing the execution time of SQL statements can help them better optimize their SQL queries and manage their time.

[0047] Currently, solutions for predicting the execution time of SQL statements include slow query prediction based on log monitoring and prediction based on term frequency analysis. However, log monitoring lacks timeliness and cannot effectively predict the execution time of long-running SQL statements. Term frequency analysis-based solutions have poor accuracy in predicting SQL statement execution time.

[0048] In view of this, embodiments of this application provide a time prediction model training method, time prediction method and apparatus. By constructing the association between SQL statements and grayscale images, and using grayscale images for model training, the SQL statement execution time prediction problem is transformed into a regression problem in the field of deep learning, which can quickly and accurately predict the execution time of QL statements.

[0049] The technical solution of this application and how the technical solution of this application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be implemented independently or in combination with each other. The same or similar concepts or processes may not be described again in some embodiments.

[0050] Figure 1 This is a schematic diagram illustrating an application scenario of an embodiment of this application, such as... Figure 1 As shown, this includes both clients and servers. Optionally, the number of servers can be one or more, without limitation. If there are multiple servers, a server cluster concept may exist, which may contain a master server, one or more slave servers, etc.

[0051] During model training, users can input the dataset used to train the time prediction model and the time prediction model to be trained into the client. The client will automatically send the dataset and the time prediction model to be trained to the server. The server can train the time prediction model based on the received dataset and return the trained time prediction model to the client.

[0052] During the time prediction process, the user can enter an SQL statement with the execution time to be predicted on the client. The client will automatically send the SQL statement to the server that predicts the execution time of the SQL statement. The server will then use the time prediction model to predict the execution time of the SQL statement and send the predicted execution time to the client. The client will then display the predicted execution time of the SQL statement.

[0053] It should be noted that the execution entity of the SQL statement execution time prediction scheme provided in the following embodiments of this application can be a server. This server can be the same server as the server executing the SQL statement query, or it can be a different server, without limitation. Of course, in the embodiments of this application, the server executing the SQL statement execution time prediction scheme provided in the embodiments of this application can be one or more. In the scenario where there are multiple servers, a master server can receive the SQL statement from the client and distribute the task of predicting the SQL statement execution time to multiple auxiliary servers for execution, etc.

[0054] Figure 2 A flowchart illustrating the time prediction model training method provided in this application embodiment is shown below. Figure 2 As shown, it includes:

[0055] S201. Obtain a first dataset, which includes multiple SQL statements whose execution time exceeds a threshold, and the labels of the SQL statements.

[0056] In this embodiment, the SQL statements requiring time prediction are typically complex in structure and have long execution times. Therefore, all SQL statements in the first dataset have execution times exceeding a threshold.

[0057] The threshold can be set according to business needs, and this application embodiment does not impose any restrictions on it.

[0058] The server can retrieve SQL statements from the database whose execution time exceeds a set threshold. Optionally, the filtered SQL statements can include various types, such as CRUD operations.

[0059] In some embodiments, the execution time of an SQL statement can be determined based on the corresponding operation log.

[0060] When SQL statements are obtained, they can be labeled according to the time corresponding to each SQL statement to obtain the label of each SQL statement.

[0061] S202. Convert the SQL statements in the target dataset into corresponding grayscale images, and use the labels of the SQL statements as the labels of the grayscale images to obtain the second dataset.

[0062] In this embodiment of the application, by finding the correspondence between SQL statements and grayscale images, SQL statements can be converted into corresponding grayscale images.

[0063] In one possible implementation, the SQL statement can be converted into a corresponding grayscale image in the following manner.

[0064] For example, the characters of the SQL statement are converted into corresponding encoding values ​​according to a character encoding table; the gray level corresponding to the character is determined according to the encoding value and the bit depth of a preset grayscale image; the SQL statement is converted according to the gray level to obtain a two-dimensional grayscale image corresponding to the SQL statement.

[0065] The character encoding table can adopt the American Standard Code for Information Interchange (ASCII). ASCII uses a specified combination of 7 or 8 bits of binary numbers to represent 128 or 256 possible characters.

[0066] Standard ASCII code, also known as basic ASCII code, uses 7 binary digits (with the remaining 1 bit set to 0) to represent all uppercase and lowercase letters, numbers 0 to 9, and punctuation marks.

[0067] In a grayscale image, each pixel has a grayscale level, the size of which is determined by the bit depth of the grayscale image. If the bit depth is 7, then the grayscale level is 128, meaning the value of each pixel ranges from 0 to 127. Similarly, each character in an SQL statement can be represented using ASCII codes (0 to 127).

[0068] Using the method described above, an SQL statement can be associated with a grayscale image. Each character in the SQL statement corresponds to a grayscale level; that is, each character in the SQL statement can be mapped to a pixel in a grayscale image with a bit depth of 7. This yields the grayscale image corresponding to the SQL statement.

[0069] S203. Use the second dataset to train the time prediction model to be trained, and obtain the trained time prediction model.

[0070] In this embodiment of the application, the time prediction model can be a Convolutional Neural Network (CNN) model.

[0071] Alternatively, the DenseNet model, which has excellent regression performance among CNN models, can be used.

[0072] It should be understood that other neural network models may also be used in the embodiments of this application, and the embodiments of this application do not limit the type of neural network model.

[0073] In this embodiment of the application, the training process of the time prediction model can adopt the training method in the prior art. For example, the loss function between the prediction result output by the time prediction model and the label can be used to determine whether the time prediction model has achieved the expected result. When the performance index of the model reaches the expected standard, the model can be saved and the training is completed.

[0074] The time prediction model training method provided in this application involves acquiring a first dataset, which includes multiple SQL statements with execution times exceeding a threshold, and the labels of the SQL statements; converting the SQL statements in the target dataset into corresponding grayscale images, and using the labels of the SQL statements as the labels of the grayscale images to obtain a second dataset; and training the time prediction model to be trained using the second dataset to obtain a trained time prediction model. Using the trained time prediction model to predict the execution time of SQL statements allows for fast and accurate prediction of execution time.

[0075] Based on the above embodiments, the time model training method provided in this application can further improve training efficiency and accuracy by processing the SQL statements in the first dataset during the training process.

[0076] For example, the SQL statements in the first dataset are processed according to a preset statement length and converted into SQL statements of fixed length.

[0077] In some embodiments, the preset length can be set according to actual needs; for example, the preset length can be a data quartile.

[0078] For example, the SQL statements in the first dataset are sorted in descending order of character length, and the length of the SQL statement at the 90th percentile is used as the preset length. By processing the length of the SQL statements, the size of the input data can be standardized when converting the SQL statements to grayscale images, thereby improving the model training effect.

[0079] In some embodiments, converting an SQL statement into a fixed-length SQL statement can be performed using the following steps:

[0080] For example, if the length of the SQL statement is greater than the preset statement length, the SQL statement is truncated at the end to convert it into a SQL statement of fixed length; if the length of the SQL statement is less than the preset statement length, the SQL statement is padded at the end to convert it into a SQL statement of fixed length.

[0081] The truncation function deletes characters from SQL statements that exceed a preset length. The padding function adds characters to SQL statements that are too short.

[0082] In one possible implementation, padding the SQL statement at the end can be performed using random characters. That is, the server can randomly generate some characters to pad the SQL statement to the end if its length is insufficient.

[0083] In some embodiments, the server may first convert the SQL statement into a corresponding grayscale image, and then process the remaining grayscale images according to the size (standard size) of the grayscale image corresponding to the SQL statement of a preset length.

[0084] For example, grayscale images larger than the standard size are cropped, and grayscale images smaller than the standard size are padded with random grayscale levels.

[0085] Based on the above embodiments, this application also provides a time prediction method.

[0086] Figure 3 A flowchart illustrating the time prediction method provided in this application embodiment is shown below. Figure 3 As shown, it includes:

[0087] S301. Obtain the SQL statement to be predicted and convert the SQL statement into a target SQL statement of a preset length.

[0088] S302. Convert the target SQL statement into a corresponding grayscale image.

[0089] S303. Input the grayscale image into the time prediction model to obtain the predicted execution time of the target SQL statement.

[0090] The time prediction model is trained according to the model training method described in any of the above embodiments.

[0091] In the above method, the time prediction model, once trained, can quickly and accurately predict the execution time of SQL statements.

[0092] In summary, the time prediction model training method and time prediction method provided in the embodiments of this application are as follows: Figure 4As shown, the training dataset is obtained by collecting SQL operation logs from the database, constructing corresponding grayscale images, and then training the model. When a SQL statement to be predicted is received, a two-dimensional grayscale image is constructed, and the trained time prediction model is used to predict the execution time. This transforms the SQL statement execution time prediction problem into a regression problem in the field of deep learning, exhibiting good versatility. As long as a sufficient number of SQL statements are input into the network model, a sufficiently efficient model will be obtained, and the prediction performance will not significantly degrade due to changes in business scenarios.

[0093] This application also provides a time prediction model training device.

[0094] Figure 5 This is a schematic diagram of the structure of the time prediction model training device 50 provided in the embodiments of this application, as shown below. Figure 5 As shown, it includes:

[0095] The acquisition module 501 is used to acquire a first dataset, which includes multiple SQL statements whose execution time is greater than a threshold, and the labels of the SQL statements.

[0096] The conversion module 502 is used to convert the SQL statements in the target dataset into corresponding grayscale images, and use the labels of the SQL statements as the labels of the grayscale images to obtain the second dataset.

[0097] Training module 503 is used to train the time prediction model to be trained using the second dataset to obtain the trained time prediction model.

[0098] Optionally, the conversion module 502 is further configured to convert the characters of the SQL statement into corresponding encoding values ​​according to a character encoding table; determine the gray level corresponding to the character according to the encoding value and a preset bit depth of the grayscale image; and convert the SQL statement according to the gray level to obtain a two-dimensional grayscale image corresponding to the SQL statement.

[0099] Optionally, the conversion module 502 is also used to process the SQL statements in the first dataset according to a preset statement length and convert them into SQL statements of fixed length.

[0100] Optionally, the conversion module 502 is further configured to, if the length of the SQL statement is greater than a preset statement length, perform truncation on the SQL statement to convert it into a SQL statement of fixed length; and if the length of the SQL statement is less than the preset statement length, perform padding on the SQL statement to convert it into a SQL statement of fixed length.

[0101] Optionally, the conversion module 502 is also used to perform end-filling processing on the SQL statement using random characters.

[0102] The time prediction model training device provided in this application embodiment can execute the time prediction model training method provided in any of the above embodiments, and its principle and technical effect are similar, so it will not be described again here.

[0103] This application also provides a time prediction device.

[0104] Figure 6 This is a schematic diagram of the structure of the time prediction device 60 provided in the embodiments of this application, as shown below. Figure 6 As shown, it includes:

[0105] The acquisition module 601 is used to acquire the SQL statement to be predicted and convert the SQL statement into a target SQL statement of a preset length.

[0106] The conversion module 602 is used to convert the target SQL statement into a corresponding grayscale image.

[0107] The prediction module 603 is used to input the grayscale image into the time prediction model to obtain the predicted execution time of the target SQL statement; the time prediction model is trained according to the model training method described above.

[0108] The time prediction device provided in this application embodiment can execute the time prediction method provided in any of the above embodiments, and its principle and technical effect are similar, so it will not be described again here.

[0109] This application also provides an electronic device.

[0110] Figure 7 This is a schematic diagram of the structure of the electronic device 70 provided in the embodiments of this application, such as... Figure 7 As shown, it includes:

[0111] Processor 701.

[0112] Memory 702 is used to store executable instructions for the terminal device.

[0113] Specifically, the program may include program code, which includes computer operation instructions. Memory 702 may include high-speed RAM, and may also include non-volatile memory, such as at least one disk storage device.

[0114] The processor 701 is used to execute computer execution instructions stored in the memory 702 to implement the technical solutions of the embodiments described in the foregoing method embodiments.

[0115] The processor 701 may be a central processing unit (CPU), an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of this application.

[0116] Optionally, the electronic device 70 may also include a communication interface 703, through which it can communicate and interact with external devices, such as user terminals (e.g., mobile phones, tablets). In specific implementations, if the communication interface 703, memory 702, and processor 701 are implemented independently, then the communication interface 703, memory 702, and processor 701 can be interconnected via a bus to complete communication between them.

[0117] A bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc., but this does not mean there is only one bus or one type of bus.

[0118] Optionally, in a specific implementation, if the communication interface 703, memory 702, and processor 701 are integrated on a single chip, then the communication interface 703, memory 702, and processor 701 can communicate through an internal interface.

[0119] This application also provides a computer-readable storage medium storing a computer program thereon. When the computer program is executed by a processor, it implements the technical solutions of the above embodiments. The implementation principle and technical effects are similar, and will not be repeated here.

[0120] In one possible implementation, a computer-readable medium may include random access memory (RAM), read-only memory (ROM), compact discread-only memory (CD-ROM) or other optical disc storage, disk storage or other magnetic storage devices, or any other medium targeted to carry or to store the required program code in the form of instructions or data structures, and accessible by a computer. Furthermore, any connection is appropriately referred to as a computer-readable medium. For example, if software is transmitted from a website, server, or other remote source using coaxial cable, fiber optic cable, twisted pair, DSL, or wireless technologies such as infrared, radio, and microwave, then coaxial cable, fiber optic cable, twisted pair, DSL, or wireless technologies such as infrared, radio, and microwave are included in the definition of medium. As used herein, disks and optical discs include optical discs, laser discs, optical discs, Digital Versatile Discs (DVDs), floppy disks, and Blu-ray discs, where disks typically reproduce data magnetically, while optical discs optically reproduce data using lasers. The above combinations should also be included within the scope of computer-readable media.

[0121] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the technical solutions of the above embodiments. Its implementation principle and technical effects are similar, and will not be repeated here.

[0122] In the specific implementation of the aforementioned terminal device or server, it should be understood that the processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. A general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in the embodiments of this application can be directly manifested as being executed by a hardware processor, or executed by a combination of hardware and software modules within the processor.

[0123] Those skilled in the art will understand that all or part of the steps in any of the above method embodiments can be implemented by hardware associated with program instructions. The aforementioned program can be stored in a computer-readable storage medium, and when the program is executed, all or part of the steps in the above method embodiments are performed.

[0124] If the technical solution of this application is implemented in software form and sold or used as a product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the technical solution of this application can be embodied in the form of a software product, which is stored in a storage medium and includes a computer program or several instructions. This computer software product causes a computer device (which may be a personal computer, server, network device, or similar electronic device) to execute all or part of the steps of the method described in the embodiments of this application.

[0125] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily essential to this application.

[0126] It should be further noted that although the steps in the flowchart are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowchart may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.

[0127] It should be understood that the above-described device embodiments are merely illustrative, and the device of this application can also be implemented in other ways. For example, the division of units / modules in the above embodiments is only a logical functional division, and there may be other division methods in actual implementation. For example, multiple units, modules, or components may be combined, or integrated into another system, or some features may be ignored or not executed.

[0128] Furthermore, unless otherwise specified, the functional units / modules in the various embodiments of this application can be integrated into one unit / module, or each unit / module can exist physically separately, or two or more units / modules can be integrated together. The integrated units / modules described above can be implemented in hardware or as software program modules.

[0129] When integrated units / modules are implemented in hardware, the hardware can be digital circuits, analog circuits, etc. The physical implementation of the hardware structure includes, but is not limited to, transistors, memristors, etc. Unless otherwise specified, the processor can be any suitable hardware processor, such as a CPU, GPU, FPGA, DSP, and ASIC, etc. Unless otherwise specified, the storage unit can be any suitable magnetic or magneto-optical storage medium, such as Resistive Random Access Memory (RRAM), Dynamic Random Access Memory (DRAM), Static Random Access Memory (SRAM), Enhanced Dynamic Random Access Memory (EDRAM), High-Bandwidth Memory (HBM), Hybrid Memory Cube (HMC), etc.

[0130] If the integrated unit / module is implemented as a software program module and sold or used as an independent product, it can be stored in a computer-readable storage device (CMD). Based on this understanding, the technical solution of this 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. This computer software product is stored in a memory and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned memory includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.

[0131] In the above embodiments, the descriptions of each embodiment have their own emphasis. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments. The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as the combination of these technical features does not contradict each other, it should be considered within the scope of this specification.

[0132] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.

Claims

1. A method for training a time prediction model, characterized in that, include: Obtain a first dataset, which includes multiple SQL statements whose execution time exceeds a threshold, and the labels of the SQL statements; The SQL statements in the first dataset are processed according to a preset statement length and converted into SQL statements of fixed length. Convert the characters in the SQL statement to their corresponding encoded values ​​according to the character encoding table; The gray level corresponding to the character is determined based on the encoded value and the preset bit depth of the grayscale image; The SQL statement is converted based on the gray level to obtain a two-dimensional grayscale image corresponding to the SQL statement, and the label of the SQL statement is used as the label of the grayscale image to obtain a second dataset; The second dataset is used to train the time prediction model to be trained, resulting in a trained time prediction model.

2. The method according to claim 1, characterized in that, The step of converting the SQL statements in the first dataset into fixed-length SQL statements includes: If the length of the SQL statement is greater than the preset statement length, the SQL statement will be truncated to the last digit and converted into a SQL statement of fixed length. If the length of the SQL statement is less than the preset statement length, then the SQL statement is padded at the end to convert it into a SQL statement of fixed length.

3. The method according to claim 2, characterized in that, The process of padding the last digit of the SQL statement includes: The SQL statement is padded with random characters at the end.

4. A time prediction method, characterized in that, include: Obtain the SQL statement to be predicted, and convert the SQL statement into a target SQL statement of a preset length; Convert the target SQL statement into a corresponding grayscale image; The grayscale image is input into the time prediction model to obtain the predicted execution time of the target SQL statement; the time prediction model is trained by the model training method according to any one of claims 1-3.

5. A time prediction model training device, characterized in that, include: The acquisition module is used to acquire a first dataset, which includes multiple SQL statements whose execution time is greater than a threshold, and the labels of the SQL statements; A conversion module is used to convert the SQL statements in the first dataset into corresponding grayscale images, and use the labels of the SQL statements as the labels of the grayscale images to obtain a second dataset; The training module is used to train the time prediction model to be trained using the second dataset to obtain the trained time prediction model. The conversion module is specifically used to process the SQL statements in the first dataset according to a preset statement length, converting them into SQL statements of fixed length; converting the characters of the SQL statements into corresponding encoding values ​​according to a character encoding table; determining the gray level corresponding to the characters according to the encoding values ​​and a preset bit depth of the grayscale image; and converting the SQL statements according to the gray level to obtain a two-dimensional grayscale image corresponding to the SQL statements.

6. A time prediction device, characterized in that, include: The acquisition module is used to acquire the SQL statement to be predicted and convert the SQL statement into a target SQL statement of a preset length. The conversion module is used to convert the target SQL statement into a corresponding grayscale image; The prediction module is used to input the grayscale image into the time prediction model to obtain the predicted execution time of the target SQL statement; the time prediction model is trained by the model training method according to any one of claims 1-3.

7. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the method of any one of claims 1-3 or claim 3.

8. A computer-readable storage medium, characterized in that, It contains a computer program that is executed by a processor to implement the method of any one of claims 1-3 or 4.

Citation Information

Patent Citations

  • Training method of task time prediction model, task scheduling method and related device

    CN113032116A

  • Execution statement recognition method and device

    CN114265860A