Training method of index recommendation model and index recommendation method and system
By employing a multi-network parallel architecture for training index recommendation models, and utilizing the collaborative training of the global network and sub-networks, the problem of index recommendation not adapting to dynamic load changes in existing technologies is solved, achieving more efficient and accurate index configuration recommendations.
Patent Information
- Application Number
- CN202511120662.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-11
- Publication Date
- 2025-11-18
AI Technical Summary
Existing enumeration and greedy algorithms cannot adapt to complex and dynamic load changes, resulting in inflexible and inefficient index recommendation.
A training method employing a multi-network parallel architecture is adopted. Through the collaborative training of the global network and multiple sub-networks, the global network parameters are updated using local gradients, and the optimal index configuration is recommended.
It improves the learning efficiency and accuracy of the index recommendation model, adapts to complex and dynamic load changes, reduces training rounds, speeds up training, and improves query efficiency.
Smart Images

Figure CN120975175A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present specification relates to the technical field of artificial intelligence, and in particular, to a training method of an index recommendation model, an index recommendation method and system. BACKGROUND
[0002] Databases are an integral part of modern information systems and play a very important role in various industries. However, in the era of big data, the amount of data is growing, and users' demand for database storage and data processing capabilities is increasing. Under this background, index is currently the main method for efficient querying of massive data, which records the mapping relationship between data attributes and data records. In the query execution process, the index table is queried instead of full table scanning, which can greatly reduce the number of disk scans and improve execution efficiency.
[0003] In related technologies, index recommendation can be based on enumeration method and greedy method. The enumeration method is a method of trying all possible index combinations, and the query performance under each combination is evaluated to determine the optimal index configuration. The greedy method is a strategy for gradually constructing an index set, such as starting from an empty index set, and each time selecting a single index that can bring the most benefits under the current conditions to join the existing index set until the predetermined target is reached or there is no more improvement.
[0004] However, the enumeration method and the greedy method cannot adapt to the dynamic changes of complex and variable loads.
[0005] It should be noted that the above related technical content is only the information known by the inventor personally, and does not mean that the above information has entered the public domain before the filing date of the present specification, nor does it mean that it can be prior art of the present specification. SUMMARY
[0006] The present specification provides a training method of an index recommendation model, an index recommendation method and system to avoid at least one of the above technical problems.
[0007] In a first aspect, the present specification provides a training method of an index recommendation model, wherein a base network of the index recommendation model used for training includes a global network and a plurality of sub-networks; the training method includes:
[0008] obtaining a workload and a candidate index set;
[0009] In the nth round of iteration of training:
[0010] For each sub-network, determining a recommended index corresponding to the workload from the candidate index set to determine the local gradient of each sub-network;
[0011] updating parameters of the global network based on the local gradients respectively corresponding to the plurality of sub-networks, and updating the parameters respectively corresponding to the plurality of sub-networks based on the updated parameters of the global network;
[0012] wherein n is an integer greater than 0, the index recommendation model comprises a global network obtained through training convergence, and the index recommendation model is configured to recommend an index configuration for a workload to be recommended.
[0013] In a second aspect, the present specification provides an index recommendation method, comprising:
[0014] obtaining a workload to be recommended;
[0015] inputting the workload to be recommended into an index recommendation model, and determining and outputting an index configuration recommended for the workload to be recommended, wherein the index recommendation model is obtained based on the training method of the first aspect.
[0016] In a third aspect, the present specification provides a training system of an index recommendation model, comprising:
[0017] at least one storage medium storing at least one instruction set for training the index recommendation model;
[0018] at least one processor communicatively connected to the at least one storage medium, wherein the at least one processor reads the at least one instruction set when running, and executes the training method of the first aspect according to the instruction of the at least one instruction set.
[0019] In a fourth aspect, the present specification provides an index recommendation system, comprising:
[0020] at least one storage medium storing at least one instruction set for index recommendation;
[0021] at least one processor communicatively connected to the at least one storage medium, wherein the at least one processor reads the at least one instruction set when running, and executes the index recommendation method of the second aspect according to the instruction of the at least one instruction set.
[0022] In a fifth aspect, the present specification provides a computer-readable non-transitory storage medium, wherein the computer-readable non-transitory storage medium stores at least one instruction set, and the at least one instruction set is executed by at least one processor to implement the method of the first aspect or the second aspect.
[0023] According to the technical solution, the training method of the index recommendation model, the index recommendation method and the system provided by the specification greatly accelerate the training speed through the parallel architecture, such as parallel training of each sub-network, and are very suitable for processing large-scale data sets and complex scenarios. In addition, the parameters of the global network are updated by processing the local gradient of the plurality of sub-networks by the global network, so that the global network can more accurately estimate the real gradient on the entire data set, thereby improving the stability and generalization ability of the index recommendation model.
[0024] Other functions of the training method of the index recommendation model, the index recommendation method and the system provided by the specification will be partially listed in the following description. The creative aspects of the training method of the index recommendation model, the index recommendation method and the system provided by the specification can be fully explained by practicing or using the methods, devices and combinations described in the following detailed examples. BRIEF DESCRIPTION OF DRAWINGS
[0025] In order to more clearly illustrate the technical solutions in the embodiments of the specification, the following will briefly introduce the drawings needed to be used in the embodiment description. Obviously, the drawings in the following description are only some embodiments of the specification, and those skilled in the art can also obtain other drawings according to these drawings without creative labor.
[0026] Figure 1 The application scenario diagram of the training method of the index recommendation model provided by the embodiment of the specification;
[0027] Figure 2 The structure diagram of the training system of the index recommendation model provided by the embodiment of the specification;
[0028] Figure 3 The flow diagram of the training method of the index recommendation model provided by the embodiment of the specification;
[0029] Figure 4 The principle diagram of the training method of the index recommendation model provided by the embodiment of the specification;
[0030] Figure 5 The flow diagram of the training method of the index recommendation model provided by another embodiment of the specification;
[0031] Figure 6 The principle diagram of the training method of the index recommendation model provided by the embodiment of the specification;
[0032] Figure 7 The principle diagram of the training method of the index recommendation model provided by the embodiment of the specification;
[0033] Figure 8 A structure diagram of a network model to be trained provided for an embodiment of the present specification;
[0034] Figure 9 A flow diagram of an index recommendation method provided for an embodiment of the present specification. DETAILED DESCRIPTION
[0035] The exemplary embodiments will be described in detail herein with reference to the attached drawings. In the following description, the same numbers are used to indicate the same or similar components. The embodiments described in the following exemplary embodiments do not represent all the embodiments consistent with the present specification. Rather, they are merely examples of apparatuses and methods consistent with some aspects of the present specification as detailed in the appended claims.
[0036] It should be understood that the terms "comprise" and "have", and any variations thereof, used in the embodiments of the present specification are intended to cover but not exclusively include, for example, a product or apparatus comprising a list of components without necessarily being limited to the clearly listed components, but can include other components not clearly listed or inherent to such products or apparatuses.
[0037] The term "and / or" in the embodiments of the present specification describes the association relationship of the associated objects, which means that there can be three relationships, for example, A and / or B can represent the three cases of A alone, A and B together, and B alone. The character " / " generally represents that the associated objects before and after it are in an "or" relationship.
[0038] The term "a plurality of" in the embodiments of the present specification means two or more, and other quantifiers are similar to it.
[0039] The terms "first", "second", "third", and the like in the present specification are used to distinguish similar or similar objects or entities, and do not necessarily mean to limit the specific order or sequence, unless otherwise indicated. It should be understood that the terms used in this way can be interchanged under appropriate circumstances, for example, those other than the order given in the illustration or description of the embodiments of the present specification can be implemented.
[0040] The term "unit / module" used in the present specification refers to any known or later developed hardware, software, firmware, artificial intelligence, fuzzy logic, or a combination of hardware or / and software code capable of performing functions related to the element.
[0041] To avoid at least one of the technical problems mentioned in the background, the present specification proposes a technical concept with creative labor: training through a multi-network parallel architecture to obtain an index recommendation model. On this basis, the index corresponding to the corresponding query can be recommended to the user based on the index recommendation model.
[0042] For example, the base network used to train the index recommendation model includes a global network and multiple sub-networks. The training of the model is usually multi-round iteration training, so for any sub-network in any round iteration, the sub-network can perform the current round iteration to obtain the local gradient of the current round iteration.
[0043] Therefore, each sub-network can obtain its corresponding local gradient respectively. Each sub-network can send its corresponding local gradient to the global network.
[0044] The global network can update its parameters according to the received local gradients, and can send the updated parameters to each sub-network respectively. Each sub-network can update its own parameters based on the parameters sent by the global network.
[0045] In the next round of iteration, any sub-network can be trained based on the updated parameters.
[0046] By analogy, until the training converges. The global network obtained by training convergence can be an index recommendation model.
[0047] The technical solution provided by the present specification is realized based on the above technical concept. As can be known from the description of the above technical concept, in the technical solution provided by the present specification, the index recommendation model is trained through a multi-network parallel architecture. The learning efficiency and accuracy can be improved, the training rounds can be reduced, and the training speed can be accelerated. In addition, the index recommendation model can also have strong generalization ability, so that the index recommendation model can be relatively adapted to the complex and variable load dynamic change environment.
[0048] In order to facilitate the reader's understanding of the present specification, the application scenario of the present specification will be introduced.
[0049] The technical solution provided by the present specification is applicable to the scenario of training an index recommendation model to recommend an index corresponding to a query based on the index recommendation model. For example, the technical solution provided by the present specification can be widely applied to systems involving data query, analysis and retrieval. For example, a database management system (DBMS), an enterprise-level data analysis platform, an operation and maintenance system, an online analytical processing system, a search engine and a content recommendation system, etc.
[0050] Taking the scenario of the above database management system as an example:
[0051] By the technical solutions provided in the specification, an index recommendation model that reasonably recommends indexes corresponding to queries for a database management system can be trained. Accordingly, the database management system can create indexes reasonably based on the recommendations of the index recommendation model to greatly improve query efficiency.
[0052] For example, the database management system can include a distributed database system, which can be a distributed database system of an e-commerce platform, and specifically can include an e-commerce platform order system. In the e-commerce platform order system, users often filter orders according to fields such as "order status", "order time", "user ID", etc. The index recommendation model trained based on the technical solutions provided in the specification can recommend the e-commerce platform order training system to create composite indexes such as order status (user_id, status) and / or order time (create_time).
[0053] It should be noted that the above examples are only used to illustratively explain the application scenarios to which the technical solutions of the specification can be applied, and cannot be understood as a limitation on the application scenarios.
[0054] Figure 1 The application scenario of the training method (hereinafter referred to as the training method) of the index recommendation model of the embodiments of the specification is shown in the figure, wherein the training method of the specification can be applied to the scenario 100 as shown. Figure 1 As shown in Figure 1 The scenario 100 can include a target user 101, a client 102, a server 103, and a network 104.
[0055] The target user 101 can be a user who triggers the training of the index recommendation model. For example, the target user 101 can perform a target operation on the client 102 to trigger the training of the index recommendation model.
[0056] The client 102 can be an electronic device that provides an interaction function to the target user 101. For example, the client 102 can provide an interaction interface to the target user 101, and the target user 101 can perform an interaction operation in the interaction interface. In some embodiments, the client 102 performs the training method described in the specification in response to detecting a target operation triggered by the target user 101. At this time, the client 102 can store data or instructions for executing the training method described in the specification, and can execute or be used to execute the data or instructions. In some embodiments, the client 102 can include a hardware device with data information processing function and the necessary programs required to drive the hardware device to work, so as to execute the training method described in the specification.
[0057] In some embodiments, the client 102 can include a mobile device, a tablet, a notebook, a built-in device of a motor vehicle, or the like, or any combination thereof. In some embodiments, the mobile device can include a smart home device, a smart mobile device, a virtual reality device, an augmented reality device, or the like, or any combination thereof. In some embodiments, the smart home device can include a smart television, a desktop computer, or the like, or any combination thereof. In some embodiments, the smart mobile device can include a smart phone, a personal digital assistant, a game device, a navigation device, or the like, or any combination thereof. In some embodiments, the built-in device in the motor vehicle can include an on-board computer, an on-board television, or the like.
[0058] In some embodiments, the client 102 can be installed with one or more applications (APPs). The APPs can provide the target user 101 with the ability and interface to interact with the outside world through the network 104. The APPs can include, but are not limited to, a web browser type APP, a search type APP, a chat type APP, a shopping type APP, a video type APP, a financial type APP, an instant messaging tool, an email client, a social platform software, and the like.
[0059] As shown in Figure 1 The client 102 can be in communication connection with the server 103. The server 103 can be in communication connection with one client 102 or multiple clients 102. In some embodiments, the client 102 can interact with the server 103 through the network 104 to receive or send messages, and the like.
[0060] The server 103 can be a server that provides various services. For example, the server 103 can be a cloud server or a local server. The server 103 can be in communication connection with one client 102 and receive data sent by the client 102, or the server 103 can be in communication connection with multiple clients 102 and receive data sent by each of the clients 102.
[0061] In some embodiments, the training method described in the present specification can be executed on the server 103. At this time, the server 103 can store data or instructions for executing the training method described in the present specification, and can execute or be used to execute the data or instructions. The server 103 can include a hardware device having a data information processing function and a necessary program for driving the hardware device to work.
[0062] The network 104 is a medium for providing communication connection between the client 102 and the server 103. The network 104 can facilitate exchange of information or data. As Figure 1As shown, client 102 and server 103 can connect to network 104 respectively and transmit information or data to each other through network 104.
[0063] In some embodiments, network 104 can be any type of wired or wireless network, or a combination thereof. For example, network 104 may include a cable network, a wired network, a fiber optic network, a telecommunications network, an intranet, the Internet, a local area network (LAN), a wide area network (WAN), a wireless local area network (WLAN), a metropolitan area network (MAN), a public switched telephone network (PSTN), a Bluetooth network™, a ZigBee™ short-range wireless network, a near field communication (NFC) network, or a similar network.
[0064] In some embodiments, network 104 may include one or more network access points. For example, network 104 may include wired or wireless network access points, such as base stations or internet switching points, through which one or more components of client 102 and server 103 can connect to network 104 to exchange data or information.
[0065] It is worth noting that, Figure 1 The number of clients 102, servers 103, and networks 104 shown is merely illustrative. Depending on implementation needs, there can be any number of clients 102, servers 103, and networks 104. Furthermore, the training method provided in this specification can be executed entirely on client 102, entirely on server 103, or partially on client 102 and partially on server 103.
[0066] In other words, Figure 1 and targeting Figure 1 The above description is only used to illustrate the possible application scenarios for the training method in this specification, and should not be construed as limiting the application scenarios.
[0067] Figure 2A hardware structure diagram of a training system 200 is shown according to an embodiment of the present specification. The training system 200 can execute the training method described in the present specification. The training method is introduced in other parts of the present specification. When the training method is executed on the client 102, the training system 200 can be the client 102. When the training method is executed on the server 103, the training system 200 can be the server 103. When the training method is partially executed on the client 102 and partially executed on the server 103, the training system 200 can be a system including the client 102 and the server 103.
[0068] As shown in Figure 2 The training system 200 can include at least one storage medium 203 and at least one processor 202. In some embodiments, the training system 200 can further include a communication port 204 and an internal communication bus 201. The training system 200 can further include an I / O component 205.
[0069] The internal communication bus 201 can connect different system components. For example, the internal communication bus 201 can connect the storage medium 203, the processor 202, the communication port 204 and the I / O component 205.
[0070] The I / O component 205 supports input / output between the training system 200 and other components.
[0071] The communication port 204 is used for data communication between the training system 200 and the outside world. For example, the communication port 204 can be used for data communication between the training system 200 and the network 104. The communication port 204 can be a wired communication port or a wireless communication port.
[0072] The storage medium 203 can include a data storage device. The data storage device can be a non-transitory storage medium or a transitory storage medium. For example, the data storage device can include one or more of a magnetic disk 2031, a read-only memory (ROM) 2032 or a random access memory (RAM) 2033. The storage medium 203 further includes at least one instruction set stored in the data storage device. The instruction set includes computer program code, which can include programs, routines, objects, components, data structures, processes, modules, etc. that execute the training method provided by the present specification.
[0073] The at least one processor 202 can be communicatively connected with the at least one storage medium 203. The at least one processor 202 is configured to execute the at least one set of instructions described above. When the training system 200 is running, the at least one processor 202 reads the at least one set of instructions and executes the training method provided in the specification according to the instructions of the at least one set of instructions. The processor 202 can execute all steps included in the training method. The processor 202 can be in the form of one or more processors. In some embodiments, the processor 202 can include one or more hardware processors, such as a microcontroller, a microprocessor, a reduced instruction set computer (RISC), an application-specific integrated circuit (ASIC), an application-specific instruction set processor (ASIP), a central processing unit (CPU), a graphics processing unit (GPU), a physics processing unit (PPU), a microcontroller unit, a digital signal processor (DSP), a field programmable gate array (FPGA), an advanced RISC machine (ARM), a programmable logic device (PLD), any circuit or processor capable of executing one or more functions, or the like, or any combination thereof.
[0074] For the sake of illustration only, only one processor 202 is shown in the training system 200 in the drawings. However, it should be noted that the training system 200 in the specification can also include multiple processors, and therefore the operations and / or method steps disclosed in the specification can be executed by one processor or jointly executed by multiple processors. For example, if the processor 202 of the training system 200 is described in the specification to execute step A and step B, it should be understood that step A and step B can also be executed jointly or separately by two different processors 202 (for example, a first processor executes step A and a second processor executes step B, or the first and second processors jointly execute steps A and B).
[0075] Referring to Figure 3 , Figure 3 A flowchart of a training method of an index recommendation model provided by an embodiment of the specification is shown. In the training method shown in Figure 3 The execution subject of the training method can be a training system. For the description of the training system, please refer to the above examples, which will not be repeated here. In addition, the base network used to train the index recommendation model includes a global network and multiple sub-networks.
[0076] As Figure 3 shown, the method includes the following S301 to S302:
[0077] S301: Obtain a workload and a candidate index set.
[0078] The workload can be understood as a set of tasks that the training system needs to process, such as a series of queries.
[0079] For example, taking the scenario of the database management system described above as an example, the workload can be understood as one or more groups of queries or transactions in the database management system. Specifically, the workload can be read, write, update, or delete operations, etc.
[0080] The candidate index set can be understood as a set of various candidate indexes that can be used to accelerate the processing of the workload.
[0081] For example, continuing to combine the above examples and scenarios. The candidate index set can be a set of various candidate indexes that can be used to accelerate queries in the database management system. That is, the candidate index is an index that has not been created temporarily and can be used to accelerate queries in the database management system.
[0082] In some embodiments, the training system can collect query requests within a period of time (not limited in this embodiment) to take the query requests within the period of time as the workload.
[0083] Correspondingly, the training system can determine the indexes corresponding to the query requests within the period of time, and determine the indexes other than the existing indexes as candidate indexes.
[0084] For example, continuing to combine the above examples and scenarios. Indexes can have been created in the database management system. After the training system determines the indexes corresponding to the query requests within the period of time, the indexes other than the indexes that have been created in the database management system can be determined as candidate indexes, thereby obtaining the candidate index set.
[0085] S302: In the n th (n is an integer greater than 0) round of iteration:
[0086] Step 1: For each subnetwork, determine the recommended index corresponding to the workload from the candidate index set to determine the local gradient of each subnetwork.
[0087] In machine learning and deep learning, the gradient can be understood as the partial derivative of the loss function with respect to the model parameters. It is a vector whose direction indicates the direction of the growth of the loss function in the parameter space, and its size (or length) reflects the speed of such growth. In optimization algorithms (such as gradient descent), the gradient is used to guide how to adjust the model parameters to reduce the loss function value.
[0088] In this embodiment, the base network can include a global network and multiple subnetworks. In order to distinguish the gradients of the global network and the subnetworks, we can call the gradient corresponding to the subnetwork as the local gradient. Different subnetworks have their own corresponding local gradients, and the local gradients of different subnetworks can be the same or different.
[0089] For each sub-network, a reinforcement learning or other optimization algorithm can be used to select a candidate index from the candidate index set that is most matched to the workload as the recommended index, and to calculate a corresponding loss function value. On this basis, the local gradient of each sub-network can be calculated by a back propagation algorithm according to the loss function value.
[0090] The training system can convert the workload into a numerical feature. Correspondingly, the workload obtained by any sub-network is in the form of a numerical feature.
[0091] Step 2: Update the parameters of the global network based on the respective local gradients of the plurality of sub-networks, and update the respective parameters of the plurality of sub-networks based on the updated parameters of the global network.
[0092] The index recommendation model includes the global network obtained by training convergence, and the index recommendation model is used to recommend an index configuration for a workload to be recommended.
[0093] As can be seen from the above analysis, the gradient is not the parameter of the model (i.e., the model parameter) itself, but information used to guide how to optimally adjust these parameters. During the training process, the gradient determines how each parameter should be changed to make the model perform better.
[0094] Correspondingly, the local gradient of a sub-network is not the parameter of the sub-network itself. The parameter can be a variable that needs to be learned by the model through the training process. For example, in a neural network, the parameters usually include weights and biases.
[0095] For example, the parameters of the global network can include the weights and biases of the global network learned through training. The parameters of a sub-network can include the weights and biases of the sub-network learned through training.
[0096] In combination with the above examples and Figure 4 Taking the number of sub-networks as 3, and the sub-networks as sub-network 1, sub-network 2, and sub-network 3, respectively, as an example:
[0097] After the above step 2, the local gradient 1 of the sub-network 1, the local gradient 2 of the sub-network 2, and the local gradient 3 of the sub-network 3 can be obtained.
[0098] All sub-networks can upload their local gradients to the global network. For example, the sub-network 1 can upload the local gradient 1 to the global network; the sub-network 2 can upload the local gradient 2 to the global network; and the sub-network 3 can upload the local gradient 3 to the global network.
[0099] Correspondingly, the global network obtains the local gradient 1, the local gradient 2, and the local gradient 3. On this basis, the global network can process these gradients based on a certain aggregation strategy (such as averaging, etc.), and update its own parameters accordingly. After updating the parameters of the global network, the updated global network parameters can be distributed back to the subnetwork 1, the subnetwork 2, and the subnetwork 3.
[0100] Therefore, the subnetwork 1 can synchronously update the parameters of the subnetwork 1 based on the updated parameters of the global network, the subnetwork 2 can synchronously update the parameters of the subnetwork 2 based on the updated parameters of the global network, and the subnetwork 3 can synchronously update the parameters of the subnetwork 3 based on the updated parameters of the global network.
[0101] Correspondingly, the training system can determine whether to stop training according to a preset convergence criterion (for example, the performance improvement in consecutive several rounds of iterations is less than a certain threshold, or the maximum number of iterations is reached). When the convergence condition is met, the training is completed, and at this time, the global network is the trained index recommendation model, which can be used to recommend an index configuration for a new to-be-recommended work load.
[0102] In this embodiment, the training speed is greatly accelerated by the way of "parallel architecture", such as parallel training of each subnetwork, and it is very suitable for processing large-scale data sets and complex scenarios. In addition, by processing the local gradients of the multiple subnetworks by the global network to update the parameters of the global network, the global network can more accurately estimate the real gradient on the entire data set, thereby improving the stability and generalization ability of the index recommendation model.
[0103] It can be known from the above analysis that the training system can use the optimization algorithm of reinforcement learning to select a candidate index that is relatively most matched with the work load from the candidate index set as the recommended index to determine the local gradient.
[0104] That is, in some embodiments, the local gradient of the subnetwork can be determined based on a reinforcement learning algorithm.
[0105] The reinforcement learning algorithm can be understood as a kind of machine learning method, in which an agent learns how to make a series of decisions to achieve long-term goals through interaction with the environment.
[0106] Compared with other methods, the reinforcement learning algorithm can enable the subnetwork to autonomously learn from experience, solve problems without explicit guidance, and is particularly good at dealing with challenges involving long-term planning and complex interactions. In particular, in this embodiment, the reinforcement learning training is performed in a parallel manner, which can effectively balance the exploration and utilization strategy to improve the learning efficiency and accuracy, reduce the training rounds, accelerate the training speed, and make the training process more stable.
[0107] To make the readers have a better understanding of the implementation principle of the training method provided in the specification, the implementation principle of the training method provided in the specification will be described in combination with Figure 5 The training method provided in the specification will be described in more detail. As shown in the specification, the method comprises: Figure 5
[0108] S501: Obtain the workload and the candidate index set.
[0109] It can be understood that, in order to avoid tedious statements, the same or similar features as in the above examples will not be described again in this embodiment.
[0110] For example, for the implementation principle of S501, please refer to the description of S301 in the above examples, which will not be described again here.
[0111] According to the above analysis, the training method provided in the specification can be applied to the scenario of a database management system. For example, the training method provided in the specification can be applied to a distributed database. The distributed database can be understood as a database system in which data is distributed on multiple independent nodes, aiming to improve scalability and fault tolerance.
[0112] Correspondingly, in the case where the training method provided in the specification is applied to a distributed database, S501 can comprise the following steps 11 and 12:
[0113] Step 11: Obtain the query and the table structure corresponding to the distributed database.
[0114] For example, in combination with Figure 6 It can be known that the training system can collect queries such as actual runtime and table structures corresponding to the queries from the distributed database. To determine the query pattern and data layout of the distributed database and other information.
[0115] Step 12: According to the query and the table structure corresponding to the distributed database, generate the candidate index set, and generate the workload according to the query corresponding to the distributed database.
[0116] In combination with the above examples and Figure 6 , the training system can determine the index (i.e. candidate index) recommended by the distributed database based on the query and the table structure. That is, the training system can generate the corresponding candidate index set based on the obtained query and table structure of the distributed database.
[0117] For example, the training system can determine that the column frequently appearing in the WHERE clause in the distributed system can be a good choice for creating an index based on the query and the table structure. Therefore, it can be determined as a candidate index.
[0118] When generating the workload, the training system can take the queries actually running in the distributed system as input, form a representative query set as the workload to train the index recommendation model. So that the index recommendation model knows which types of queries are relatively more common or more important.
[0119] For example, taking the distributed database system of the e-commerce platform as an example, the training system can select the relatively more common query types and the relatively higher frequency queries as part of the workload according to the actual query records of the e-commerce platform in the past month. For example, select the top 10% of queries with higher query frequency.
[0120] Continue to combine the above examples and Figure 6 The training system can determine the workload based on the obtained queries of the distributed database. For example, the training system can perform the frequency of the obtained queries of the distributed database, thereby constructing a representative query set, i.e., the workload.
[0121] S502: In the nth round of iteration:
[0122] Step 1: based on the first agent corresponding to the first subnetwork, selecting the corresponding index from the action space according to the environment state of the first subnetwork and the current policy, wherein the environment state is determined based on at least the workload, and the action space is determined based on the candidate index set, and the first subnetwork is any network in the plurality of subnetworks.
[0123] Step 2: evaluate the effect of the index selected by the first agent to obtain an evaluation result.
[0124] Step 3: determine the local gradient of the first subnetwork based on the evaluation result.
[0125] From the above analysis, in the reinforcement learning algorithm, the agent learns how to make a series of decisions to achieve long-term goals by interacting with the environment.
[0126] Continue to take the above-mentioned distributed database system of the e-commerce platform as an example, the environment can be understood as the distributed database system. Each agent is in the environment.
[0127] The environment state can also be called state information (abbreviated as state), which can be understood as the current state of the system in which the environment interacts with the first agent. For example, the workload of the distributed database system, or the environment-related information of the distributed database system determined by the workload, etc.
[0128] The current policy can be understood as the policy or basis for the first agent to select actions. The current policy is obtained by gradually optimizing during the training process.
[0129] The action space can be understood as a set of all actions that the first agent can choose. For example, the action space includes a set of candidate indexes (one index corresponds to one action), or is determined based on the set of candidate indexes.
[0130] For example, in combination with the above examples and Figure 7 The agent corresponding to each subnetwork can include an actor-critic network. Each subnetwork can independently interact with the corresponding environment to obtain independent sampling experience. For example, taking agent 1 corresponding to subnetwork 1 as an example:
[0131] During the training process, the environment initializes a new workload for each training set, starting from an empty index configuration, and initializes the parameters of the actor-critic network.
[0132] The actor network can select an action (such as an index) according to the current environment state, the action space, and the current policy.
[0133] The critic network evaluates the reward of the action (i.e., the selected index) selected by the corresponding actor network and calculates the advantage function.
[0134] The reward is a feedback signal from the environment to the agent, indicating whether the action is "good" or "bad" in the current state. Still taking the distributed database system of the e-commerce platform as an example, the reward can be the increase or decrease of query time, resource consumption, storage overhead, query throughput, etc.
[0135] The advantage function is the difference between the actual return and the expected return of the critic network. This difference is used to guide the actor network to update the current policy. According to the advantage function, the current policy of the actor network is updated, and the value function of the critic network is updated according to the difference between the actual return and the expected return, to obtain the local gradient 1 of agent 1. The actual return can be understood as the reward feedback from the environment plus the estimated return of the next state information.
[0136] For example, still taking the distributed database system of the e-commerce platform as an example:
[0137] The distributed database system includes a user table, an order table, and a product table.
[0138] The environment state can be based on the query requests of users in the last month (such as "find orders of a specific user", "get sales statistics of a certain type of product", etc.), and the current database load, etc.
[0139] The action space can be understood as all possible index combinations that can be created, such as creating an index for the user_id field on the user table, creating a composite index for the order_date and product_id fields on the order table, and the like.
[0140] The agent 1 can select an index from the action space according to the current strategy and the environment state. For example, the agent network can select to create an index for the order_date field on the order table.
[0141] In response to the above selection, the agent 1 performs a series of test queries to measure the query performance after the new index is created. For example, if it is found that the query response time is significantly shortened, the evaluation result is positive; otherwise, it is negative.
[0142] Correspondingly, the agent 1 calculates the local gradient 1 according to the evaluation result. For example, if the index improves the query efficiency, the corresponding strategy will be strengthened; otherwise, the strategy will be adjusted accordingly to avoid selecting similar indexes in the future.
[0143] Continuing with the above example and Figure 7 The global network corresponding to the global agent calculates the average gradient of the local gradient 1, the local gradient 2, and the local gradient 3, and updates its own parameters based on the average gradient, and distributes the updated parameters to the agent 1, the agent 2, and the agent 3. So that the agent 1, the agent 2, and the agent 3 update their own parameters based on the parameters distributed by the global agent.
[0144] Based on the above analysis, in the present embodiment, each sub-network determines the local gradient of the sub-network based on the reinforcement learning algorithm in a parallel manner, which not only improves the query efficiency, but also optimizes the use of resources. In addition, as the query changes, the reinforcement learning algorithm can dynamically adjust the index strategy according to the latest workload, which can make the local gradient determined by each sub-network have high accuracy and reliability.
[0145] Step 4: Determine the average gradient of the local gradient corresponding to each of the plurality of sub-networks.
[0146] Step 5: Update the parameters of the global network according to the average gradient, and update the parameters corresponding to each of the plurality of sub-networks based on the updated parameters of the global network.
[0147] For example, continuing with the above example and Figure 4 After receiving the local gradient 1, the local gradient 2, and the local gradient 3, the global network can aggregate and average the local gradient 1, the local gradient 2, and the local gradient 3 to obtain the average gradient, and update the parameters of the global network based on the average gradient.
[0148] In the embodiment, the average gradient is calculated, and the parameters of the global network are updated based on the average gradient. The update of the parameters of the global network can be caused to sufficiently fuse the respective learning conditions of the respective sub-networks, so that the accuracy, reliability and effectiveness of the update of the parameters of the global network can be improved.
[0149] It can be known from the above analysis that the action space can be determined based on the candidate index set. In some embodiments, in order to improve the accuracy and reliability of the action space, the training system can also determine the action space in combination with the pre-trained cost estimation model.
[0150] For example, determining the action space can include the following steps 21 and 22:
[0151] Step 21: predicting a current actual execution cost corresponding to the current index configuration plan based on a pre-trained cost estimation model, wherein the cost estimation model is trained to estimate the actual execution cost of a corresponding query under a preset index set.
[0152] The cost estimation model can be understood as a learning model for predicting the execution cost (such as time, resource consumption, storage cost, etc.) of a given query under a corresponding index configuration. The cost estimation model can be trained based on historical data and can estimate the influence of different index configurations on query performance.
[0153] The current index configuration plan can be understood as an index configuration corresponding to a workload determined based on a current strategy.
[0154] The actual execution cost can be understood as a result predicted by the cost estimation model, indicating the resource consumption or time cost under the corresponding index configuration.
[0155] For example, the training system can use the pre-trained cost estimation model to predict the actual execution cost of the current index configuration plan. That is, without actually creating an index and executing a query, the cost of different index configurations is evaluated. This avoids the high cost and long waiting time caused by testing each index configuration in a real environment, improving efficiency.
[0156] Step 22: determining the action space according to the current actual execution cost and the candidate index set.
[0157] Continuing to combine the above example, the training system can determine the action space in combination with the current actual execution cost and the candidate index set. For example, the training system can select indexes that are likely to reduce the execution cost as optional actions to obtain the action space.
[0158] For example, in combination with the above example and Figure 6A distributed database system may have already created some indexes, which we can call the set of indexes that have been created. To facilitate querying data in the distributed database system, in addition to the indexes in the set of indexes, the distributed database system may also need to create some other indexes, such as a set of candidate indexes.
[0159] like Figure 6 As shown, in the first iteration, the cost estimation model can determine the actual execution cost in the first iteration based on the query configured in the first round of indexes, and can be used to determine the action space in the first iteration based on the actual execution cost and the created set of indexes.
[0160] In other words, during the first iteration, the current index configuration plan can be based on the indexes in the created index set. The cost estimation model can predict the query cost (i.e., the actual execution cost, which may include time and storage costs) required to implement queries in the workload using the indexes in the created index set.
[0161] Continuing with the examples above and Figure 6 It can determine the local gradient and the global gradient based on the environment state and action space, thereby completing the parameter update of the first iteration of the global network and each sub-network.
[0162] In the second iteration (n=2), the training system determines that the actual execution cost of the indexes that the distributed system may need to create is less than the actual execution cost corresponding to the first iteration (n=1). Therefore, the training system can determine the action space corresponding to the second iteration based on the identified indexes that the distributed system may need to create. For example, the action space for the second iteration can be defined as the set of indexes that the distributed system may need to create, and the set of already created indexes.
[0163] Continuing with the example of a distributed database system for an e-commerce platform:
[0164] The training system can train a cost estimation model based on historical query logs. The input is the current index configuration plan (e.g., creating an index on the user_id field on the user table), and the output is the predicted query execution cost (such as average response time).
[0165] If the current index configuration has an index on the `user_id` field of the `users` table, but no index on the `order_date` field of the `orders` table, the training system can use a cost estimation model to predict (rather than actually execute) the cost of executing a query to "find all orders within the past month" under this configuration.
[0166] Considering the query pattern, "create an index on the order_date field of the order table" can be one of the effective candidate indexes. Based on the predicted cost described above, if it is found that the current index configuration leads to a higher query cost, "create an index on the order_date field of the order table" is added to the action space as an action. In addition, other possible index configurations, such as creating an index on certain fields of the product table, can also be considered.
[0167] In combination with the above analysis of steps 21 and 22, in this embodiment, the action space is determined by combining the cost estimation model, without actually creating the corresponding index, which can avoid occupying the storage cost, and also avoid the high cost and long waiting time caused by testing each index configuration in the real environment, thereby improving the efficiency. In addition, by considering the actual execution cost, the action space is dynamically adjusted, so that the optimization process is more targeted, which helps to find a better index configuration, i.e., the effectiveness and reliability of the training can be improved.
[0168] In combination with the above analysis, it can be seen that the environment state is determined based on at least the workload. For example, in some embodiments, the environment state can be determined based on the workload.
[0169] In other embodiments, based on the cost estimation model described above, the environment state can be determined based on other information. For example, in the case where the current actual execution cost is determined, the training system can determine the remaining cost based on the current actual execution cost, and determine the environment state based on the workload, the candidate index set, and the remaining cost.
[0170] In combination with the above example of the distributed database system of the e-commerce platform:
[0171] The training system can obtain the total query cost of the distributed database system of the e-commerce platform, and then subtract the current actual execution cost from the total query cost to obtain the remaining cost. The environment state is formed based on the workload, the candidate index set, and the remaining cost, and is passed to the agent. In order to enable the agent to select and execute the corresponding action (such as the corresponding candidate index) in the environment state.
[0172] In this embodiment, the training system determines the environment state by combining the workload, the candidate index set, and the remaining cost, which can make the environment state have high richness and comprehensiveness. Thus, the agent can better select and execute the corresponding action, thereby improving the effectiveness and reliability of the training.
[0173] In combination with the above analysis, it can be seen that the training method provided by the present specification can be applied to a distributed database. Accordingly, the training system can also determine the environment state based on at least one of the selectivity, the number of scanned rows, and the partition information of the distributed database.
[0174] The selectivity can be understood as the proportion of the number of different values in a field to the total number of records. Relatively speaking, high selectivity means that the field is suitable for establishing an index, because a large number of records that do not meet the conditions can be quickly filtered out through the index.
[0175] The number of scanned rows can be understood as the number of data rows that need to be read or checked when executing a query. The number of scanned rows can be used to measure the complexity of the query. Relatively speaking, a higher number of scanned rows may often mean higher I / O costs and longer query response times.
[0176] The distributed database can be divided into multiple parts according to certain rules (such as by date, geographical location, etc.), and each part can be referred to as a partition. The partition information describes the specific circumstances of these partitions, including the partition key, the partition strategy, etc. Relatively speaking, reasonable partition information can significantly improve query efficiency, especially for large-scale queries involving large amounts of data.
[0177] That is, in the case where the training method provided in the present specification is applied to a distributed database, the above examples and Figure 6 , the training system can not only determine the environment information based on the workload; it can also determine the environment state based on the workload, the candidate index set, and the remaining cost; and it can also determine the environment state based on the workload (or the workload, the candidate index set, and the remaining cost), and at least one of the environment attributes of the distributed database (such as selectivity, number of scanned rows, and partition information of the distributed database).
[0178] Similarly, in the present embodiment, the training system determines the environment state by combining the partition information, which can fully consider the impact of the partition information on the execution of the workload. In addition, the training system determines the environment state by combining the selectivity and the number of scanned rows, which can make the state representation more comprehensive and rich. In this way, not only the current environment state and action are considered, but also the quality of the index and the data distribution are considered, which enables the agent to better understand the characteristics and performance of the current environment, more accurately assess the state of the current environment and select the best action, better optimize the query execution plan, reduce unnecessary data scanning, and also improve query efficiency.
[0179] That is, the training system determines the environment state by combining one or more of the selectivity, the number of scanned rows, and the partition information, which can make the environment state have high richness and comprehensiveness. This can enable the agent to better select and execute the corresponding action, thereby improving the effectiveness and reliability of the training. This can help the reinforcement learning cost estimation model to better optimize the query process and improve performance.
[0180] In some embodiments, the training system can also determine the environment state in combination with other meta information of the distributed database, such as table structure information, query patterns, data distribution, historical query performance data, etc. The environment state is determined from the perspective of diversity and variety to fully represent the environment.
[0181] Based on the above analysis, it can be known that the action space is determined based on the pre-trained cost estimation model. In some embodiments, the training of the cost estimation model can include the following steps 31 and 32:
[0182] Step 31: Obtain a query plan sample set and an index information sample set.
[0183] It should be noted that the training system used to train the cost estimation model can be the training system in the above examples, or other systems, which are not limited in the present embodiment. In the present specification, the training system is mainly exemplarily described.
[0184] In addition, the present embodiment does not limit the way the training system obtains the query plan sample set and the index information sample set. The training system can obtain them, or other systems can obtain them and transmit them to the training system.
[0185] The query plan sample set can be understood as a set of multiple query plan samples, each of which describes how a database management system executes a specific query, including which tables to select, which indexes to use, etc.
[0186] The index information sample set can be understood as a set of index configurations related to the query plan sample set, containing information of different index combinations. These index configurations affect the selection and execution efficiency of the query plan.
[0187] Step 32: Train the estimated performance of the to-be-trained network model according to the query plan sample set and the index information sample set to obtain the cost estimation model, wherein the estimated performance is used to represent the ability of estimating the actual execution cost of the query plan sample in the query plan sample set under different index combinations of the index information sample set.
[0188] The present embodiment does not limit the type and architecture of the to-be-trained network model. For example, the to-be-trained network model can be a graph convolutional network (GCN) model, or a large language model.
[0189] It is worth noting that in this specification, a large language model (LLM) can also be referred to simply as a large model. A large language model is a natural language processing model based on deep learning technology, with a parameter order of magnitude usually reaching tens of billions to hundreds of billions or even higher, with strong language understanding and generation capabilities. A large language model can use a Transformer architecture or its variants (such as GPT, BERT, etc.), which uses attention mechanisms to model global sequence data and can efficiently handle long-range dependencies, making it perform well in natural language tasks. A large language model is pre-trained on a large corpus of text to learn statistical features and semantic relationships, giving it excellent generalization capabilities. The core capabilities of a large language model include but are not limited to understanding contextual semantics, generating coherent and grammatically correct text, performing logical reasoning, and handling multi-task scenarios. Its usage methods usually include direct inference and fine-tuning. In the direct inference mode, users guide the large language model to generate specific outputs by designing prompts. Prompts can be text-based task descriptions or instructions to stimulate the semantic understanding and generation capabilities of the large language model. In the fine-tuning mode, the large language model is further trained on a small dataset in a specific domain to optimize its performance on specific tasks. The powerful generalization capabilities and flexibility of a large language model make it an important tool in the field of artificial intelligence technology, providing efficient and accurate solutions for automated text generation and understanding.
[0190] In some embodiments, a large language model can also have understanding and generation capabilities for other modalities (such as vision, audio, etc.) data, in which case the large language model can also be referred to as a multimodal large language model (MLLM). MLLMs provide a richer and more natural interactive experience by integrating text, images, sounds, and other types of input and output. The core advantage of MLLMs is their ability to process and understand information from different modalities and integrate these information to complete complex tasks. For example, MLLMs can analyze an image and generate descriptive text, or generate corresponding images based on text descriptions. This cross-modal understanding and generation capability makes MLLMs have broad application prospects in many fields.
[0191] It should be noted that the key technologies of large language models can be referred to the detailed description in the paper "A Survey of Large Language Models" (paper number: arXiv:2303.18223v16, publication time: March 11, 2025, publication link: https: / / doi.org / 10.48550 / arXiv.2303.18223). The present specification does not repeat here.
[0192] The graph convolutional network model can be understood as a model of neural network architecture, which can be used to process graph structure data. In the present embodiment, the graph convolutional network model can be used to model the complex relationship between the query plan sample and its related index.
[0193] Based on the above analysis, the estimation performance can be understood as the ability of the cost estimation model to predict the actual execution cost of the query plan sample under different index combinations. In relative terms, higher precision estimation performance means that the cost estimation model can accurately predict the actual execution effect of the query plan sample.
[0194] Taking the distributed database system of the e-commerce platform in the above example as an example:
[0195] The query plan sample can be the execution plan of queries such as "find all orders of users in the past month", "statistical sales of certain products", etc.
[0196] The index information sample can include the following index configurations: create an index on the user_id field in the user table; create an index on the order_date field in the order table; create an index on the category field in the product table; various possible index combinations, such as creating a composite index on the order_date and product_id fields in the order table.
[0197] Correspondingly, based on the above query plan sample set and index information sample set, the to-be-trained network model is trained. The input of the to-be-trained network model is the query plan sample set and the index information sample set, and the output is the predicted actual execution cost (such as response time, CPU usage, etc.) of a certain query under different index combinations.
[0198] During the training process, the training system continuously adjusts the parameters of the to-be-trained network model to minimize the error between the predicted actual execution cost and the preset label. Until convergence, the cost estimation model is obtained.
[0199] Based on the analysis of steps 31 and 32 above, it can be seen that in this embodiment, the training system, by training a cost estimation model, can more accurately predict the actual execution cost of queries under different index configurations, thereby selecting a better indexing scheme and significantly improving query performance. Furthermore, it avoids the storage waste and write operation latency problems caused by blindly adding too many indexes to the action space, allowing for more efficient utilization of system resources.
[0200] In some embodiments, step 32 may include the following sub-steps 1 to 5:
[0201] Sub-step 1: Perform feature extraction processing on the query plan sample set and the index information sample set respectively to obtain the initial query features and the initial index features.
[0202] For example, such as Figure 8 As shown, the network model to be trained can be a graph convolutional network model, and the graph convolutional network model can include a feature extraction layer. The input to the feature extraction layer includes a query plan sample set and an index information sample set.
[0203] The feature extraction layer can extract features from the query plan sample set and the index information sample set, respectively, to obtain initial features corresponding to the query plan sample set (called initial query features) and initial features corresponding to the index information sample set (called initial index features).
[0204] The initial features of the query and / or the initial features of the index include both numerical and non-numerical features.
[0205] For example, the numerical features of the initial index feature may include the number of indexed tuples in the index information sample set. The non-numerical features of the initial index feature may include the names of the indexes in the index information sample set.
[0206] Sub-step 2: Embed the initial query features and initial index features into the low-dimensional space respectively to obtain the low-dimensional query features and low-dimensional index features.
[0207] Low-dimensional space embedding can be understood as the process of mapping relatively high-dimensional features to a relatively low-dimensional space in order to simplify the data structure of the relatively high-dimensional features while retaining important information for subsequent analysis.
[0208] In other words, in this embodiment, by converting the relatively high-dimensional initial query features and initial index features into relatively low-dimensional query features and low-dimensional index features, computational complexity can be reduced and the generalization ability of the cost estimation model can be improved.
[0209] Continuing with the examples above and Figure 8The graph convolutional network model can further include an embedding layer. An input of the embedding layer is connected to an output of the feature extraction layer.
[0210] The embedding layer can embed the query initial features and the index initial features into a low-dimensional space respectively to obtain query low-dimensional features corresponding to the query initial features and index low-dimensional features corresponding to the index initial features.
[0211] Sub-step 3: learning feature representations of the query plan sample set and the index information sample set according to the query low-dimensional features and the index low-dimensional features, wherein the feature representations are used to represent relationships and interactions between the query plan sample set and the index information sample set.
[0212] The feature representations can be understood as relationships and interaction conditions (such as interaction modes, etc.) between the query plans and the index information learned by the graph convolutional network model, which are used to predict actual execution costs of the queries under different index combinations.
[0213] Continuing to combine the above examples and Figure 8 The graph convolutional network model can further include a learning layer. An input of the learning layer is connected to an output of the embedding layer.
[0214] The learning layer, referred to as a query plan / correlation index representation learning layer for short, is used to learn the feature representations of the query plan sample set and the index information sample set to capture relationships and interactions therebetween.
[0215] Sub-step 4: obtaining a prediction result according to the feature representations, the prediction result representing actual execution costs of query plan samples in the query plan sample set under different index combinations of the index information sample set.
[0216] Continuing to combine the above examples and Figure 8 The graph convolutional network model can further include an estimation layer. An input of the estimation layer is connected to an output of the learning layer.
[0217] The estimation layer is used to predict actual execution costs of corresponding queries in the query plan sample set under corresponding index sets in the index information sample set.
[0218] Sub-step 5: optimizing the to-be-trained network model according to the prediction result to obtain a cost estimation model.
[0219] Correspondingly, after the prediction result is determined, the training system can optimize model parameters and a loss function of the to-be-trained network model, so that the to-be-trained network model can gradually improve cost estimation accuracy under different index combinations, thereby obtaining the cost estimation model.
[0220] In combination with the above analysis of sub-step 1 to sub-step 5, in this embodiment, the cost estimation model trained by the training system through the processes of feature extraction, low-dimensional space embedding and feature learning not only improves the query efficiency, but also optimizes the resource usage.
[0221] Based on the above technical concept, the specification also provides an index recommendation method.
[0222] Please refer to Figure 9 , Figure 9 The flowchart of the index recommendation method provided by the embodiment of the specification is shown in FIG. 1. As shown in FIG. 1, the method comprises the following S901 and S902: Figure 9
[0223] S901: Obtain a workload to be recommended.
[0224] Similarly, as for the features same as or similar to those in the above examples, the embodiment will not be described again.
[0225] For example, as for the application scenarios of the index recommendation method, the application scenarios of the training method of the index recommendation model can be referred to; for another example, the subject executing the index recommendation method can be an index recommendation system. The index recommendation system can be the same system as the training system, or can be a different system, and as for the understanding of the index recommendation system, the description of the training system in the above examples can be referred to; and the like, which will not be listed one by one here.
[0226] S902: input the workload to be recommended into the index recommendation model, determine and output the index configuration recommended for the workload to be recommended, wherein the index recommendation model is trained based on the training method described in any of the above embodiments.
[0227] For example, the index recommendation model is a global network model obtained by converging the above training method. The input of the index recommendation model is the workload to be recommended, such as a set of queries for which the index is to be recommended. The output of the index recommendation model is the index configuration, such as a set of indexes recommended for the workload to be recommended.
[0228] In this embodiment, by combining the index recommendation model to recommend the corresponding index configuration for the workload to be recommended, the automation and intelligence of recommending the index can be realized. In addition, in combination with the above analysis, the index recommendation performance of the index recommendation model is relatively strong, and therefore, the index configuration recommended based on the index recommendation model has high accuracy and reliability.
[0229] It should be noted that the above examples are only used to illustrate the possible implementation manners of the training method and the index recommendation method of the present specification, and cannot be understood as a limitation on the implementation manners of the training method and the index recommendation method of the present specification. For example, on the basis of the above technical concept, part of the technical features in the above examples can be combined to obtain a new embodiment; new technical features can be added on the basis of the above examples to obtain a new embodiment; part of the technical features in the above examples can be reduced to obtain a new embodiment; part of the technical features in the above examples can be replaced by other technical features; part of the technical features and the order in the above examples can be adjusted to obtain a new embodiment, and the like, which will not be listed one by one here.
[0230] According to the above technical concept, the present specification also provides a computer-readable non-transitory storage medium, and the computer-readable non-transitory storage medium stores at least one instruction set. When the at least one instruction set is executed by a processor, the steps of the training method and the index recommendation method described in the present specification are implemented.
[0231] In some possible implementation, various aspects of the present specification can also be implemented in the form of a program product, which includes program codes. Taking the training system 200 as an example (for the index recommendation system, please refer to the example, and hereinafter will not be listed one by one), when the program product runs on the training system 200, the program codes are used to make the training system 200 execute the steps of the training method described in the present specification. The program product for implementing the above method can include program codes in a portable compact disc read-only memory (CD-ROM), and can run on the training system 200. However, the program product of the present specification is not limited to this, in the present specification, the readable storage medium can be any tangible medium containing or storing programs, which can be used by or in combination with an instruction execution system. The program product can adopt any combination of one or more readable media. The readable medium can be a readable signal medium or a readable storage medium. The readable storage medium may, for example, be but is not limited to an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or apparatus, or any combination of the above. More specific examples of readable storage media include an electrical connection having one or more wires, a portable disc, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. The computer readable storage medium can include a data signal propagating in the baseband or as part of a carrier wave, which carries readable program codes. Such a propagating data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The readable storage medium can also be any readable medium other than the readable storage medium, which can send, propagate or transmit programs for use by or in combination with an instruction execution system, device or apparatus. The program codes contained on the readable storage medium can be transmitted in any suitable medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the above. The program codes for executing the operations of the present specification can be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" language or similar programming languages. The program codes can be completely executed on the training system 200, partially executed on the training system 200, executed as an independent software package, partially executed on the training system 200 and partially executed on a remote training system, or completely executed on a remote training system 200.
[0232] It should be noted that the collection, storage, use, processing, transmission, provision and disclosure of the relevant information of the user (such as query and the like) involved in the technical solutions of the present specification comply with the provisions of relevant laws and regulations, and do not violate public order and good customs.
[0233] The foregoing description of a specific embodiment of the present specification has been described. Other embodiments are within the scope of the appended claims. In some cases, the acts or steps recited in the claims can be performed in a different order than the order in which they are recited and still achieve desirable results. In addition, the processes depicted in the accompanying drawings do not necessarily require the particular order or sequential order illustrated in order to achieve the desired results. In some implementations, multitasking and parallel processing can be advantageous or possible.
[0234] In summary, after reading the detailed disclosure, those skilled in the art can understand that the foregoing detailed disclosure can be presented only in an exemplary manner, and can not be limiting. Although it is not explicitly stated here, those skilled in the art can understand that the present specification requires to encompass various reasonable changes, improvements and modifications to the embodiments. These changes, improvements and modifications are intended to be presented by the present specification, and are within the spirit and scope of the exemplary embodiments of the present specification.
[0235] In addition, certain terms in the present specification have been used to describe the embodiments of the present specification. For example, "one embodiment", "embodiment" and / or "some embodiments" mean that the specific features, structures or characteristics described in connection with the embodiment can be included in at least one embodiment of the present specification. Therefore, it can be emphasized and should be understood that two or more references to "embodiments" or "one embodiment" or "alternative embodiments" in various parts of the present specification do not necessarily refer to the same embodiment. In addition, specific features, structures or characteristics can be appropriately combined in one or more embodiments of the present specification.
[0236] It should be understood that in the foregoing description of the embodiments of the present specification, for the purpose of helping to understand one feature, the present specification combines various features in a single embodiment, figure or its description for the purpose of simplifying the present specification. However, this does not mean that the combination of these features is necessary, and those skilled in the art can well understand one part of the device as a separate embodiment when reading the present specification. That is, the embodiments in the present specification can also be understood as the integration of multiple secondary embodiments. And the content of each secondary embodiment is also true when less than all the features of a single foregoing disclosed embodiment.
[0237] Each patent, patent application, publication, and other material cited in this document (including any cross-referenced or related patent, patent application, publication, or document) is incorporated herein by reference in its entirety for all purposes to the same extent as if each such patent, patent application, publication, or document had been specifically and individually indicated to be incorporated by reference in its entirety for all purposes.
[0238] Finally, it should be understood that the embodiments of the application disclosed herein are illustrative of the principles of the present specification. Other modifications that fall within the scope of the present specification can also be made. Accordingly, the present specification discloses embodiments only as examples. Those skilled in the art can, given the benefit of this disclosure, make modifications to the present specification without departing from the scope of the present specification. Accordingly, the present specification is not limited to the embodiments described herein but rather the scope of the present specification is to be accorded the broadest scope embodied by the principles and numerous embodiments disclosed herein.
Claims
1. A training method for an index recommendation model, wherein the basic network of the index recommendation model includes a global network and multiple sub-networks; The training method includes: Obtain the workload and candidate index set; In the nth iteration of training: For each subnetwork, a recommended index corresponding to the workload is determined from the candidate index set to determine the local gradient of each subnetwork; Based on the local gradients corresponding to each of the multiple sub-networks, the parameters of the global network are updated, and based on the updated parameters of the global network, the parameters corresponding to each of the multiple sub-networks are updated. Wherein, n is an integer greater than 0, the index recommendation model includes a global network obtained through training and convergence, and the index recommendation model is used to recommend index configurations for workloads to be recommended.
2. The method according to claim 1, wherein, The local gradients of the subnetworks are determined based on reinforcement learning algorithms.
3. The method according to claim 2, wherein, Determining the local gradients of a subnetwork based on reinforcement learning algorithms includes: Based on the first agent corresponding to the first sub-network, according to the environmental state and current policy of the first sub-network, a corresponding index is selected from the action space, wherein the environmental state is determined at least based on the workload, the action space is determined at least based on the candidate index set, and the first sub-network is any network among the plurality of sub-networks; The effectiveness of the index selected by the first agent is evaluated, and the evaluation result is obtained; and The local gradient of the first sub-network is determined based on the evaluation results.
4. The method according to claim 3, wherein, The method further includes: Based on a pre-trained cost estimation model, the current actual execution cost corresponding to the current index configuration plan is predicted, wherein the cost estimation model is trained to estimate the actual execution cost of the corresponding query under a preset set of indexes; The action space is determined based on the current actual execution cost and the candidate index set.
5. The method according to claim 4, wherein, The method further includes: Determine the remaining cost based on the current actual execution cost; and The environment state is determined based on the workload, the candidate index set, and the remaining cost.
6. The method according to claim 4, wherein, The cost estimation model obtained through training includes: Obtain a sample set of query plans and a sample set of index information; The cost estimation model is trained based on the query plan sample set and the index information sample set to obtain the estimation performance of the network model to be trained. The estimation performance is used to characterize the ability of the query plan samples in the query plan sample set to estimate the actual execution cost under different index combinations in the index information sample set.
7. The method according to claim 6, wherein, The cost estimation model is trained based on the query plan sample set and the index information sample set to obtain the estimated performance of the network model to be trained, including: Feature extraction processing is performed on the query plan sample set and the index information sample set respectively to obtain the initial query features and the initial index features; The initial query features and the initial index features are respectively embedded into a low-dimensional space to obtain low-dimensional query features and low-dimensional index features; Based on the query low-dimensional features and the index low-dimensional features, feature representations of the query plan sample set and the index information sample set are learned, wherein the feature representations are used to characterize the relationship and interaction between the query plan sample set and the index information sample set; The prediction result is obtained based on the feature representation, and the prediction result characterizes the actual execution cost of the query plan samples in the query plan sample set under different index combinations in the index information sample set; and The cost estimation model is obtained by optimizing the network model to be trained based on the prediction results.
8. The method according to claim 3, wherein, The training method is applied to a distributed database; the environment state is further determined by at least one of selectivity, number of rows scanned, and partition information of the distributed database.
9. The method according to claim 1, wherein, Based on the local gradients corresponding to each of the multiple sub-networks, the parameters of the global network are updated, including: Determine the average gradient of the local gradient corresponding to each of the multiple sub-networks; and The parameters of the global network are updated based on the average gradient.
10. The method according to claim 1, wherein, The training method is applied to a distributed database; it obtains a workload and a set of candidate indexes, including: Obtain the query and table structure corresponding to the distributed database; The candidate index set is generated based on the query and table structure corresponding to the distributed database, and the workload is generated based on the query corresponding to the distributed database.
11. An index recommendation method, comprising: Obtain the workloads to be recommended; The workload to be recommended is input into the index recommendation model, and an index configuration recommended for the workload to be recommended is determined and output, wherein the index recommendation model is obtained based on the training method as described in any one of claims 1 to 10.
12. A training system for an index recommendation model, comprising: At least one storage medium storing at least one instruction set for training the index recommendation model; At least one processor is communicatively connected to the at least one storage medium, wherein when the at least one processor is running, it reads the at least one instruction set and executes the training method as described in any one of claims 1 to 10 according to the instructions of the at least one instruction set.
13. An index-based recommendation system, comprising: At least one storage medium stores at least one instruction set for index recommendation; At least one processor is communicatively connected to the at least one storage medium, wherein when the at least one processor is running, it reads the at least one instruction set and executes the index recommendation method as described in claim 11 according to the instructions of the at least one instruction set.
Citation Information
Cited By
A data and load co-aware index recommendation method and system
CN122388267A
A data and load co-aware index recommendation method and system
CN122388267B