Database-oriented data management method and related equipment

By constructing optimization statements and inputting pre-trained optimization models, adapting to different business scenarios and optimizing SQL query statements, the problem of lack of adaptability in SQL optimization in the existing technology is solved, and data management efficiency and accuracy are improved.

CN120045546APending Publication Date: 2025-05-27YUNDI SMART TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510107116.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-22
Publication Date
2025-05-27

AI Technical Summary

Technical Problem

The existing SQL optimization technology lacks adaptability and is unable to effectively respond to changing business needs, which makes it difficult to improve data management efficiency and accuracy.

Method used

By constructing optimization statements and inputting pre-trained optimization models, adapting to different business scenarios, optimizing SQL query statements, and generating management statements that are more in line with actual needs.

Benefits of technology

It realizes the adaptability of SQL optimization solutions, improves data management efficiency and accuracy, and can dynamically adapt to changing business needs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120045546A_ABST
    Figure CN120045546A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a database-oriented data management method and related equipment, which are used for providing an SQL (Structured Query Language) optimization scheme capable of self-adapting to different business scenes so as to improve the data management efficiency and the data management accuracy. The method comprises the steps of determining a management environment to which a first management statement faces, wherein the first management statement is used for executing data management operation on a database; based on the management environment of the first management statement and the first management statement, a first optimization statement is constructed, and the first optimization statement is used for indicating the optimization direction of the first management statement; inputting the first optimization statement into a pre-trained optimization model to obtain a second management statement obtained by optimizing the first management statement based on the optimization direction by the pre-trained optimization model; and initiating a data management operation to the database based on the second management statement.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present application relate to the field of databases, and in particular, to a data management method for databases and related devices. Background Art

[0002] With the deepening of informatization, the amount of data in enterprise business systems has increased sharply, and the role of Structured Query Language (SQL) in business systems has become increasingly important.

[0003] Traditional SQL query optimization mainly relies on the internal optimizer of the database. However, in some business scenarios, the internal optimizer of the database can no longer meet the enterprise's requirements for real-time, accurate, and complex data processing. Therefore, in addition to the internal optimizer, some SQL optimization technologies are also needed to effectively use the data and business in the database under the big data platform. Generally, existing SQL optimization technologies mainly complete tuning through static rule algorithms.

[0004] However, the static rule algorithm obviously lacks adaptability. When new business requirements arise, developers need to re-develop and configure new static rules. This tuning solution obviously lacks adaptability and cannot effectively respond to changing business requirements. Summary of the Invention

[0005] Embodiments of the present application provide a data management method for databases and related devices, which are used to provide an SQL optimization solution that can adapt to different business scenarios, thereby improving data management efficiency and data management accuracy.

[0006] The first aspect of the embodiments of the present application provides a data management method for databases, including:

[0007] Determine the management environment faced by the first management statement, where the first management statement is used to perform data management operations on the database;

[0008] Construct a first optimization statement based on the management environment of the first management statement and the first management statement, where the first optimization statement is used to indicate the optimization direction of the first management statement;

[0009] Input the first optimization statement into a pre-trained optimization model to obtain a second management statement obtained by the pre-trained optimization model optimizing the first management statement based on the optimization direction;

[0010] Initiate a data management operation on the database based on the second management statement.

[0011] In a specific implementation, before inputting the first optimization statement into a pre-trained optimization model to obtain a second management statement obtained by the pre-trained optimization model optimizing the first management statement based on the optimization direction, the method further includes:

[0012] Construct a second optimization statement based on historical management statements and the historical management environment corresponding to the historical management statements, where the historical management statements have corresponding sample management statements;

[0013] Input the second optimization statement into an initial optimization model to obtain a training management statement output by the initial optimization model;

[0014] Calculate a training loss based on the training management statement and the sample management statement, and adjust the initial optimization model based on the training loss until the pre-trained optimization model is obtained.

[0015] In a specific implementation, before determining the management environment faced by the first management statement, the method further includes:

[0016] Obtain the conversation information input by the user, and determine the database that needs to be called to reply to the conversation information;

[0017] Input the identification information of the database and the conversation information into a management statement generation model to obtain the first management statement output by the management statement generation model.

[0018] In a specific implementation, the constructing the first optimization statement based on the management environment of the first management statement and the first management statement includes:

[0019] Determine the access rights of the user in the business scenario according to the business scenario in which the user sends the conversation information;

[0020] Construct a first optimization statement based on the management environment of the first management statement, the first management statement, and the access rights of the user in the business scenario.

[0021] In a specific implementation, the method further includes: if it is determined based on the operation log of the second management statement and / or the response data of the second management statement that the second management statement does not meet the preset optimization conditions, then construct a third optimization statement based on the preset optimization conditions and the second management statement, where the operation log of the second management statement is obtained from the database, and the response data of the second management statement is obtained after the database processes the second management statement;

[0022] Input the third optimized statement into the pre-trained optimization model to obtain a third management statement output by the pre-trained optimization model;

[0023] If the third management statement meets the preset optimization condition, iterate the pre-trained optimization model based on the third management statement and the first management statement.

[0024] In a specific implementation, the management environment faced by the first management statement includes database performance information, and the database performance information includes at least one of the database type of the database, the machine configuration of the database, the inter-table relationship in the database, and the current disk size of the database.

[0025] A second aspect of the embodiments of the present application provides a computer device, including:

[0026] A determination unit, configured to determine the management environment faced by a first management statement, where the first management statement is used to perform data management operations on a database;

[0027] An optimization unit, configured to construct a first optimization statement based on the management environment of the first management statement and the first management statement, where the first optimization statement is used to indicate the optimization direction of the first management statement;

[0028] The optimization unit is further configured to input the first optimization statement into a pre-trained optimization model to obtain a second management statement obtained by the pre-trained optimization model optimizing the first management statement based on the optimization direction;

[0029] A management unit, configured to initiate a data management operation on the database based on the second management statement.

[0030] In a specific implementation, before inputting the first optimization statement into the pre-trained optimization model to obtain a second management statement obtained by the pre-trained optimization model optimizing the first management statement based on the optimization direction, the computer device further includes: a training unit;

[0031] The training unit is configured to construct a second optimization statement based on historical management statements and the historical management environments corresponding to the historical management statements, where the historical management statements have corresponding sample management statements;

[0032] The training unit is further configured to input the second optimization statement into an initial optimization model to obtain a training management statement output by the initial optimization model;

[0033] The training unit is further configured to calculate a training loss based on the training management statement and the sample management statement, and adjust the initial optimization model based on the training loss until the pre-trained optimization model is obtained.

[0034] In a specific implementation manner, before determining the management environment faced by the first management statement, the computer device further includes: an acquisition unit;

[0035] The acquisition unit is configured to acquire the conversation information input by the user and determine the database that needs to be called to reply to the conversation information;

[0036] The acquisition unit is further configured to input the identification information of the database and the conversation information into the management statement generation model, and obtain the first management statement output by the management statement generation model.

[0037] In a specific implementation manner, the optimization unit is specifically configured to determine the access permission of the user in the service scenario according to the service scenario in which the user sends the conversation information; construct a first optimization statement based on the management environment of the first management statement, the first management statement, and the access permission of the user in the service scenario.

[0038] In a specific implementation manner, the computer device further includes: a training unit;

[0039] The optimization unit is further configured to, if it is determined based on the operation log of the second management statement and / or the response data of the second management statement that the second management statement does not meet the preset optimization condition, construct a third optimization statement based on the preset optimization condition and the second management statement, where the operation log of the second management statement is obtained from the database, and the response data of the second management statement is obtained after the database processes the second management statement;

[0040] The optimization unit is further configured to input the third optimization statement into the pre-trained optimization model to obtain a third management statement output by the pre-trained optimization model;

[0041] The training unit is configured to, if the third management statement meets the preset optimization condition, iterate the pre-trained optimization model based on the third management statement and the first management statement.

[0042] In a specific implementation manner, the management environment faced by the first management statement includes database performance information, and the database performance information includes at least one of the database type of the database, the machine configuration of the database, the inter-table relationship in the database, and the current disk size of the database.

[0043] The third aspect of the embodiments of the present application provides a computer device, including:

[0044] A central processing unit, a memory, and an input / output interface;

[0045] The memory is a transient storage memory or a persistent storage memory;

[0046] The central processing unit is configured to communicate with the memory and execute the instruction operations in the memory to execute the method described in the first aspect.

[0047] The fourth aspect of the embodiments of the present application provides a computer program product containing instructions. When the computer program product runs on a computer, it causes the computer to execute the method described in the first aspect.

[0048] The fifth aspect of the embodiments of the present application provides a computer storage medium. Instructions are stored in the computer storage medium. When the instructions are executed on a computer, they cause the computer to execute the method described in the first aspect.

[0049] It can be seen from the above technical solutions that the embodiments of the present application have the following advantages: By inputting a first optimization statement indicating the optimization direction into a pre-trained optimization model, the optimization model outputs a second management statement required by the present application. Among them, the second management statement is formed by optimizing the first management statement in the optimization direction and integrating the management environment faced by the first management statement, which is more in line with actual needs. Moreover, the optimization is completed with the support of the management environment faced by the first management statement, can adapt to the current business scenario, and thus improve data management efficiency and data management accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0050] Figure 1 It is a schematic flowchart of a data management method disclosed in an embodiment of the present application;

[0051] Figure 2 It is a schematic structural diagram of a computer device disclosed in an embodiment of the present application;

[0052] Figure 3 It is another schematic structural diagram of a computer device disclosed in an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0053] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.

[0054] The embodiments of the present application provide a data management method and related devices for a database, which are used to provide an SQL optimization solution that can adapt to different business scenarios, thereby improving data management efficiency and data management accuracy.

[0055] Please refer to Figure 1 , the embodiments of the present application provide a data management method for a database, which is applied to any computer device that can directly or indirectly manage the database, and includes the following steps:

[0056] 101. Determine the management environment faced by the first management statement, where the first management statement is used to perform data management operations on the database. Among them, data management operations include, but are not limited to, creating, querying, updating, and deleting, etc.

[0057] The first management statement can be a statement that can already perform certain data management operations on the database obtained by any means. Among them, the first management statement can be written in languages such as Structured Query Language (SQL), Cassandra Query Language (CQL), or Hive Query Language (HiveQL), and can be any query language that can directly query and operate on data stored in different types of databases.

[0058] The management environment faced by the first management statement can include, but is not limited to, at least one of the following environmental information: the performance information of the database accessed by the first management statement and the business scenario where the first management statement is located. Among them, the performance information of the database includes at least one environmental information that affects management efficiency or affects the operation of the database, such as database type, machine configuration of the database, information between database tables, and current disk size of the database; the business scenario includes at least one information that affects data query accuracy, such as the business type where the first management statement is located, the business department where the user who initiated the first management statement is located, and the rank of the user who initiated the first management statement.

[0059] It should be noted that in traditional business scenarios, the SQL query statements written by business personnel usually only directly reflect their business requirements, and cannot take into account access rights, privacy data security, the current state of the database, and whether it can withstand large amounts of data queries or insertions. For example, when a business person initiates a salary query requirement, if only an SQL statement like "SELECT name, salary FROM employees" is generated, the meaning of this SQL statement is: find the name (name) and salary (salary) fields of all employees from the employees table (employee table). However, the SQL statement does not specify how to retrieve this data - the database can choose different execution methods, such as using index scans, full table scans, or other optimization methods. And in different management environments, the content that an SQL needs to be optimized and adjusted is different. Therefore, by obtaining the management environment described in the above embodiments, it helps to guide the pre-trained optimization model to output a second management statement that is sufficiently in line with actual requirements.

[0060] 102. Based on the management environment of the first management statement and the first management statement, construct a first optimization statement, where the first optimization statement is used to indicate the optimization direction of the first management statement.

[0061] Management statements (including but not limited to the first management statement, the second management statement, and the third management statement described in this application) are used to initiate corresponding data management operations to a specific database. Among them, data management operations include but are not limited to data query, creation, deletion, modification, permission management, etc. Based on the foregoing embodiments, when the management environment faced by the first management statement is different, the optimization methods that the first management statement can adopt are different. For example, when the database performance is poor, in order to avoid database downtime, when initiating a data management operation through the first management statement, it is possible to choose to limit the amount of data returned by the database each time to form a new second management statement, or split a data management operation into multiple management sub-operations, that is, multiple second management statements, to reduce the load pressure on the database; when the business scenario of the first management statement initiated by the user requires permission management, introduce permission control in the second management statement, etc.

[0062] Therefore, the embodiments of this application need to construct a first optimization statement that guides the optimization direction based on the first management statement and the management environment it faces. Among them, the optimization direction indicated by the embodiments of this application can include one or more optimization goals, and each optimization goal is used to indicate that the optimization model performs optimization processing in an optimization method based on the management environment faced by the first management statement.

[0063] Generally, the construction of optimized statements (including but not limited to the first optimized statement, the second optimized statement, the third optimized statement, etc.) can be completed in the following ways including but not limited to: The following takes the construction method of the first optimized statement as an example for illustration: 1. Pre-configure an optimized statement template. By filling each piece of data used for constructing the optimized statement into the corresponding position in the pre-configured optimized statement template, the first optimized statement can be obtained, where each piece of data used for constructing the optimized statement includes but not limited to: the management environment faced by the first management statement and the first management statement; 2. Directly merge each piece of information required for constructing the optimized statement as the first optimized statement; 3. Pre-configure a prompt generation template. By filling each piece of data required for constructing the optimized statement into the corresponding position in the pre-configured prompt generation template, a first prompt for guiding the generative language model to output the first optimized statement can be obtained. Subsequently, inputting the first prompt into the generative language model can obtain the first optimized statement. Among them, the optimized statement template and the prompt generation template can be configured as needed, and are not limited here.

[0064] 103. Input the first optimized statement into a pre-trained optimization model to obtain a second management statement obtained by the pre-trained optimization model optimizing the first management statement based on the optimization direction.

[0065] Based on the foregoing embodiments, it may be that the first optimized statement indicates the optimization direction to the pre-optimized training model. Therefore, after inputting the first optimized statement including the optimization direction, the management environment, and the first management statement into the pre-trained optimization model, the pre-trained optimization model can, under the indication of the first optimized statement, optimize the first management statement to obtain the second management statement, where the second management statement should perform better than the first management statement in the optimization direction indicated by the foregoing first optimized statement.

[0066] The pre-trained optimization model in the embodiments of the present application can be obtained by training based on an initial optimization model, and the initial optimization model can be any generative language model. By fine-tuning the generative language model in the downstream task of generating management statements, a pre-trained optimization model that meets the requirements can be obtained. It should be noted that the initial optimization model can be the generative language model that outputs the first prompt in the foregoing step 102, or a generative language model different from the generative language model that outputs the first prompt in the foregoing step 102, and is not limited here.

[0067] 104. Initiate a data management operation to the database based on the second management statement.

[0068] After obtaining the second management statement, a corresponding data management operation can be directly initiated to the database based on this second management statement. For example, directly send the second management statement obtained in step 103 to the database, or send this second management statement to the data through other computer devices, so that the database executes the second management statement, thereby completing the corresponding data management operation.

[0069] In the embodiment of the present application, by inputting a first optimization statement indicating an optimization direction to a pre-trained optimization model, the optimization model outputs the second management statement required by the present application. Among them, the second management statement is formed by optimizing the first management statement in the optimization direction and integrating the management environment faced by the first management statement, which is more in line with actual requirements. Moreover, the optimization is completed with the support of the management environment faced by the first management statement, and can adapt to the current business scenario, thereby improving data management efficiency and data management accuracy.

[0070] Based on the foregoing embodiment, before the foregoing step 101, the first management statement can be obtained in the following manner: obtain the conversation information input by the user, and determine the database to be called to reply to the conversation information; input the identification information of the database and the conversation information into the management statement generation model, and obtain the first management statement output by the management statement generation model. Among them, the management statement generation model can be the same generative language model as mentioned in the foregoing embodiment or a different generative language model, which is not limited here.

[0071] Specifically, the user sends a conversation information by means of a conversation with the management statement generation model. After obtaining this conversation information, the database to be called to reply to the conversation information can be determined. Finally, the management statement generation model combines the identification information of the database and the conversation information to obtain the data management operation required to reply to the conversation information for the corresponding database. Among them, the database to be called to reply to the conversation information can be determined by including but not limited to the following methods: 1. Pre-configure the keywords or key phrases corresponding to each database. If the conversation information contains the keywords or key phrases of a certain database, it means that it is determined that this database needs to be called to reply to the conversation information; 2. Pre-configure the database name corresponding to each database, call the management statement generation model to match the conversation information with the database name corresponding to each database, and determine the database with the most matching corresponding database name and conversation information as the database to be called to reply to the conversation information.

[0072] In addition, by filling the identification information of the database and the conversation information into the corresponding positions in the management statement generation template, a second prompt that can guide the management statement generation model to output the first management statement can be obtained.

[0073] Further, the foregoing step 102 can be specifically implemented in the following manner: Determine the access rights of the user in the business scenario according to the business scenario in which the user sends the conversation information; Based on the management environment of the first management statement, the first management statement, and the access rights of the user in the business scenario, construct the first optimization statement.

[0074] When the accessed database is a sensitive database, in order to avoid providing all business data to the user without screening, the access rights of the user in different business scenarios can be pre-configured. In this way, when constructing the first optimization statement, consider using the access rights of the user in the business scenario as a piece of data used in constructing the first optimization statement, and construct the first optimization statement based on the management environment of the first management statement, the first management statement, and the access rights of the user in the business scenario. Specifically, each piece of data used in constructing the optimization statement in the embodiments of the present application, in addition to the management environment of the first management statement and the first management statement described in the foregoing embodiments, also includes the access rights of the user in the business scenario. Among them, the manner in which the first optimization statement is constructed based on each piece of data used in constructing the optimization statement in the embodiments of the present application is similar to the foregoing related embodiments and will not be elaborated here.

[0075] Furthermore, after initiating a data management operation on the database based on the second management statement, if it is found that the second management statement does not meet the key optimization objective, the second management statement can also be further optimized in the following manner to obtain a third management statement, including the following steps: If it is determined, based on the operation log of the second management statement and / or the response data of the second management statement, that the second management statement does not meet the preset optimization condition, then construct a third optimization statement based on the preset optimization condition and the second management statement. The operation log of the second management statement is obtained from the database, and the response data of the second management statement is obtained after the database processes the second management statement; Input the third optimization statement into a pre-trained optimization model to obtain the third management statement output by the pre-trained optimization model; If the third management statement meets the preset optimization condition, iterate the pre-trained optimization model based on the third management statement and the first management statement.

[0076] Among them, the preset optimization condition can be specifically configured as needed. For example, it can be that the duration for processing the second management statement is within a preset duration and the data volume of the response data of the second management statement is less than the preset maximum data volume; or all of the response data of the second management statement is within the user's access rights, which can be specifically configured as needed and is not specifically limited in the embodiments of the present application.

[0077] In the embodiments of the present application, the method for determining that the second management statement does not meet the preset optimization conditions based on the operation log of the second management statement and / or the response data of the second management statement can also be applied to determining whether the third management statement meets the preset optimization conditions based on the operation log of the third management statement and / or the response data of the third management statement, which will not be elaborated here.

[0078] In the embodiments of the present application, the automatic picking of training corpus is realized through the algorithm for determining whether the second management statement and the third management statement meet the preset optimization conditions. When the third management statement meets the preset optimization conditions, the first management statement is used as the historical management statement, and the third management statement is used as the sample management statement. By referring to the method of training the pre-trained optimization model based on the historical management statement and the sample management statement, the pre-trained optimization model is trained based on the first management statement and the third management statement, and the pre-trained optimization model is iterated by referring to the way of iterating the initial optimization model into the pre-trained optimization model.

[0079] Based on the foregoing embodiments, in some specific implementation manners, before the foregoing step 103, the pre-trained optimization model used in the foregoing step 103 can be specifically obtained through the following method: constructing a second optimization statement based on the historical management statement and the historical management environment corresponding to the historical management statement, where the historical management statement has a corresponding sample management statement; inputting the second optimization statement into the initial optimization model to obtain the training management statement output by the initial optimization model; calculating the training loss based on the training management statement and the sample management statement, and adjusting the initial optimization model based on the training loss until the pre-trained optimization model is obtained.

[0080] Specifically, the historical management statement, the historical management environment corresponding to the historical management statement, and the sample management statement corresponding to the historical management statement can be used as the training corpus to guide the initial optimization model to perform better in the specific downstream task of outputting the management statement. Similar to using the pre-trained optimization model in actual applications, first, a second optimization statement is constructed based on the historical management statement and the historical management environment corresponding to the historical management statement. This step can refer to the embodiment of constructing the first optimization statement, which will not be elaborated here. Subsequently, the second optimization statement is input into the initial optimization model to obtain the training management statement output by the initial optimization model. Finally, the training loss is calculated based on the training management statement and the sample management statement, and the initial optimization model is adjusted based on the training loss until the pre-trained optimization model is obtained.

[0081] Among them, the sample management statement can be obtained by the developer optimizing based on the historical management statement, or by referring to the method of optimizing the second management statement to obtain the third management statement to optimize the historical management statement, which is not limited here.

[0082] In some specific implementations, the management environment faced by the first management statement includes database performance information, which includes at least one of the database type of the database, the machine configuration of the database, the inter-table relationships in the database, and the current disk size of the database. In addition, the management environment faced by the first management statement further includes the business scenario in which the user sends the corresponding dialogue information, and even the buried point data in the business system, which can be specifically configured according to the various data required for tuning and is not limited here.

[0083] In the traditional solution, when the user inputs dialogue information, regardless of the data range, data volume, whether it involves private data, etc. of the data required to be managed by the dialogue information, the existing tools will convert the text into a management statement and hand it over to the corresponding database for execution. Regardless of the current state of the downstream database and whether it can withstand large-volume queries or insertions, it is very likely to cause the database to crash or private data leakage and other situations.

[0084] The foregoing described various embodiments of the data management method of the present application. Next, in a specific business scenario, the data management method of the embodiments of the present application for a database is described.

[0085] 1. Data preprocessing

[0086] Extract historical SQL (i.e., historical management statements) from the database and the historical management environment corresponding to each historical SQL (including but not limited to the running logs and related business data of the historical SQL). Among them, natural language processing technology is used to perform word segmentation, part-of-speech tagging, and semantic analysis on the running logs and related business data of the historical SQL, and the required information is extracted as the historical management environment.

[0087] 2. Pre-trained optimization model

[0088] Construct a training set using historical SQL and the historical management environment corresponding to each historical SQL. Use supervised learning algorithms (such as deep neural networks, random forests, etc.) to train the initial optimization model in order to obtain an optimized management statement (such as the second management statement). In addition, considering that different databases (such as MySQL, PostgreSQL, Oracle, etc.) have different characteristics, optimization models adapted to different database systems are trained separately, and each pre-trained optimization model has a corresponding database type for processing data management operations of databases of this database type.

[0089] 3. SQL automatic generation and optimization

[0090] The dialogue information input by the user is parsed through the management statement generation model, and an SQL statement (i.e., the first management statement) is automatically generated. Subsequently, through the management environment faced by the SQL statement, the pre-trained optimization model is used to optimize it, and the optimized SQL statement (i.e., the second management statement) is obtained. The second management statement has a better query path index, connection method, paging, etc. compared to the first management statement.

[0091] 4. Dynamic Tuning

[0092] During the execution of the optimized SQL statement, the execution performance is dynamically monitored, and the pre-trained optimization model is continuously iterated using the reinforcement learning method to achieve better query performance.

[0093] 5. Analysis and Feedback of Execution Results

[0094] The corresponding data and execution time of the management statement executed on the database are analyzed to construct a performance database. Based on the foregoing data, the optimization model is further iterated to improve the efficiency and accuracy of future queries.

[0095] It should be noted that the user usually inputs dialogue information through a certain business system. Therefore, in the embodiments of the present application, the user can initiate an operation of the current business system for data burying points, and use it as a part of the management environment faced by the management statement. Combining historical management statements, historical management environments of historical management statements, and even including historical operation logs of historical management statements, the optimization model is iterated. Finally, at the level of management statement execution, the embodiments of the present application train the resource information of the database, historical management statements executed in the past, and historical management environments to optimize the execution of management statements. The optimizable methods include but are not limited to: whether to use indexes, whether to optimize subqueries, and small table driving large table, etc.

[0096] The embodiments of the present application have the following beneficial effects:

[0097] 1. Improve query efficiency: Automatically optimize SQL statements through the pre-trained optimization model, significantly improve the execution speed of complex queries, and reduce the occupation of database resources.

[0098] 2. Reduce labor costs: Automatically generate and optimize SQL statements, reduce the workload of database administrators for SQL tuning, and reduce the cost of manual tuning.

[0099] 3. Dynamically adapt to business requirements: The embodiments of the present application can dynamically adjust the SQL query plan according to changing business scenarios, greatly improving the flexibility and scalability of the data management method.

[0100] Please refer to Figure 2 ., the second aspect of the embodiments of the present application provides a computer device, including:

[0101] A determination unit 201, configured to determine a management environment faced by a first management statement, where the first management statement is used to perform data management operations on a database;

[0102] An optimization unit 202, configured to construct a first optimization statement based on the management environment of the first management statement and the first management statement, where the first optimization statement is used to indicate an optimization direction of the first management statement;

[0103] The optimization unit 202 is further configured to input the first optimization statement into a pre-trained optimization model, and obtain a second management statement obtained by the pre-trained optimization model optimizing the first management statement based on the optimization direction;

[0104] A management unit 203, configured to initiate a data management operation on the database based on the second management statement.

[0105] In a specific implementation manner, before inputting the first optimization statement into a pre-trained optimization model and obtaining a second management statement obtained by the pre-trained optimization model optimizing the first management statement based on the optimization direction, the computer device further includes: a training unit;

[0106] The training unit is configured to construct a second optimization statement based on a historical management statement and a historical management environment corresponding to the historical management statement, where the historical management statement has a corresponding sample management statement;

[0107] The training unit is further configured to input the second optimization statement into an initial optimization model, and obtain a training management statement output by the initial optimization model;

[0108] The training unit is further configured to calculate a training loss based on the training management statement and the sample management statement, and adjust the initial optimization model based on the training loss until the pre-trained optimization model is obtained.

[0109] In a specific implementation manner, before determining the management environment faced by the first management statement, the computer device further includes: an acquisition unit;

[0110] The acquisition unit is configured to acquire conversation information input by a user, and determine a database to be called to reply to the conversation information;

[0111] The acquisition unit is further configured to input the identification information of the database and the conversation information into a management statement generation model, and obtain a first management statement output by the management statement generation model.

[0112] In a specific implementation manner, the optimization unit 202 is specifically configured to determine an access right of a user in a service scenario according to the service scenario in which the user sends conversation information; and construct a first optimization statement based on the management environment of the first management statement, the first management statement, and the access right of the user in the service scenario.

[0113] In a specific implementation, the computer device further includes: a training unit;

[0114] The optimization unit 202 is further configured to, if it is determined that the second management statement does not meet the preset optimization condition based on the operation log of the second management statement and / or the response data of the second management statement, construct a third optimization statement based on the preset optimization condition and the second management statement. The operation log of the second management statement is obtained from the database, and the response data of the second management statement is obtained after the database processes the second management statement;

[0115] The optimization unit 202 is further configured to input the third optimization statement into a pre-trained optimization model to obtain a third management statement output by the pre-trained optimization model;

[0116] The training unit is configured to iteratively train the pre-trained optimization model based on the third management statement and the first management statement if the third management statement meets the preset optimization condition.

[0117] In a specific implementation, the management environment faced by the first management statement includes database performance information, and the database performance information includes at least one of the database type of the database, the machine configuration of the database, the inter-table relationship in the database, and the current disk size of the database.

[0118] Figure 3 FIG. is a schematic structural diagram of a computer device provided by an embodiment of the present application. The computer device 300 may include one or more central processing units (CPUs) 301 and a memory 305. One or more application programs or data are stored in the memory 305.

[0119] Among them, the memory 305 may be volatile storage or persistent storage. The program stored in the memory 305 may include one or more modules, and each module may include a series of instruction operations on the computer device. Further, the central processor 301 may be configured to communicate with the memory 305 and execute a series of instruction operations in the memory 305 on the computer device 300.

[0120] The computer device 300 may further include one or more power supplies 302, one or more wired or wireless network interfaces 303, one or more input / output interfaces 304, and / or one or more operating systems, such as Windows Server, Mac OS X, Unix, Linux, FreeBSD, etc.

[0121] The central processor 301 may execute the foregoing Figures 1 to 2The operations performed by the computer device in the illustrated embodiments will not be elaborated here specifically.

[0122] It should be noted that although the steps in the flowcharts involved in each embodiment are drawn in sequence according to the arrows, unless there is a clear description in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in each embodiment may include multiple steps or multiple stages. These steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily sequential, but can be executed alternately or in turn with at least a part of other steps or steps or stages in other steps.

[0123] Those skilled in the art can clearly understand that for the convenience and conciseness of description, the specific working processes of the systems, devices, and units described above can refer to the corresponding processes in the foregoing method embodiments and will not be elaborated here.

[0124] In several embodiments provided in the present application, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the units is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed coupling or direct coupling or communication connection to each other can be through some interfaces, and the indirect coupling or communication connection of the device or unit can be in the form of electricity, machinery, or others.

[0125] The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or may be distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0126] In addition, the functional units in each embodiment of the present application can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above integrated units can be implemented in the form of hardware or in the form of software functional units.

[0127] When the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of this application. The foregoing storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard disks, read-only memories (ROM, read-only memory), random access memories (RAM, random access memory), magnetic disks, or optical discs.

[0128] The embodiments of this application also provide a computer program product containing instructions. When the computer program product runs on a computer, it causes the computer to execute the data management method for a database as described above.

Claims

1. A data management method for a database, characterized in that: include: Determining a management environment for a first management statement, wherein the first management statement is used to perform a data management operation on a database; constructing a first optimization statement based on the management environment of the first management statement and the first management statement, wherein the first optimization statement is used to indicate an optimization direction of the first management statement; Inputting the first optimization statement into a pre-trained optimization model to obtain a second management statement obtained by optimizing the first management statement based on the optimization direction by the pre-trained optimization model; A data management operation is initiated to the database based on the second management statement.

2. The database-oriented data management method according to claim 1, characterized in that: Before inputting the first optimization statement into a pre-trained optimization model to obtain a second management statement obtained by optimizing the first management statement based on the optimization direction by the pre-trained optimization model, the method further includes: constructing a second optimization statement based on a historical management statement and a historical management environment corresponding to the historical management statement, wherein the historical management statement has a corresponding sample management statement; Inputting the second optimization statement into the initial optimization model to obtain a training management statement output by the initial optimization model; The training loss is calculated based on the training management statement and the sample management statement, and the initial optimization model is adjusted based on the training loss until the pre-trained optimization model is obtained.

3. The database-oriented data management method according to claim 1, characterized in that: Before determining the management environment faced by the first management statement, the method further includes: Acquire the dialogue information input by the user, and determine the database to be called to reply to the dialogue information; The identification information of the database and the dialog information are input into a management statement generation model to obtain the first management statement output by the management statement generation model.

4. The database-oriented data management method according to claim 3, characterized in that: The constructing a first optimization statement based on the management environment of the first management statement and the first management statement includes: Determining the access rights of the user in the business scenario according to the business scenario in which the user sends the conversation information; A first optimization statement is constructed based on the management environment of the first management statement, the first management statement, and the access rights of the user in the business scenario.

5. The database-oriented data management method according to claim 3, characterized in that: The method further comprises: If it is determined based on the running log of the second management statement and / or the response data of the second management statement that the second management statement does not meet the preset optimization condition, constructing a third optimization statement based on the preset optimization condition and the second management statement, the running log of the second management statement is obtained from the database, and the response data of the second management statement is obtained after the database processes the second management statement; Inputting the third optimization statement into the pre-trained optimization model to obtain a third management statement output by the pre-trained optimization model; If the third management statement satisfies the preset optimization condition, the pre-trained optimization model is iterated based on the third management statement and the first management statement.

6. The database-oriented data management method according to any one of claims 1 to 5, characterized in that: The management environment faced by the first management statement includes database performance information, and the database performance information includes at least one of the database type of the database, the machine configuration of the database, the relationship between tables in the database, and the current disk size of the database.

7. A computer device, characterized in that: include: a determining unit, configured to determine a management environment faced by a first management statement, wherein the first management statement is used to perform a data management operation on a database; an optimization unit, configured to construct a first optimization statement based on the management environment of the first management statement and the first management statement, wherein the first optimization statement is used to indicate an optimization direction of the first management statement; The optimization unit is further configured to input the first optimization statement into a pre-trained optimization model, and obtain a second management statement obtained by optimizing the first management statement based on the optimization direction by the pre-trained optimization model; A management unit is used to initiate a data management operation to the database based on the second management statement.

8. A computer device, characterized in that: include: CPU, memory and input / output interface; The memory is a short-term storage memory or a persistent storage memory; The central processing unit is configured to communicate with the memory and execute instructions in the memory to perform the method according to any one of claims 1 to 6.

9. A computer program product comprising instructions, characterized in that When the computer program product is run on a computer, the computer is caused to execute the method according to any one of claims 1 to 6.

10. A computer storage medium, characterized in that: The computer storage medium stores instructions, and when the instructions are executed on a computer, the computer is caused to execute the method according to any one of claims 1 to 6.