SQL optimization interaction method and device based on deep learning framework large model

By fine-tuning the CodeLlama model and verifying the enterprise data dictionary through a deep learning framework, SQL statements are generated and optimized, solving the problems of SQL writing complexity and lack of optimization standardization, and achieving efficient and stable data acquisition and query optimization.

CN120508569BActive Publication Date: 2025-09-16北京科杰科技有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510979920.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-07-16
Publication Date
2025-09-16
Estimated Expiration
2045-07-16

AI Technical Summary

Technical Problem

In existing technologies, the complexity of writing SQL statements and the lack of standardized optimization methods make it difficult for non-professionals to efficiently obtain data. Existing tools also have difficulty interpreting query intent in multi-source heterogeneous data environments, have high maintenance costs, and suffer from performance bottlenecks.

Method used

A deep learning framework is used to fine-tune the CodeLlama large language model through low-rank adaptation technology, generate and optimize SQL statements, verify key elements in combination with the enterprise data dictionary, generate target SQL statements and performance optimization suggestions, and display the generation progress and suggestions in real time through an interactive interface.

Benefits of technology

It significantly improves data acquisition efficiency, establishes a standardized SQL optimization system, lowers technical barriers, ensures the stability of query performance, reduces maintenance costs, and improves user experience and query efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120508569B_ABST
    Figure CN120508569B_ABST
Patent Text Reader

Abstract

The present application relates to an interactive SQL optimization method and device based on a deep learning framework large model. The method includes: deploying a statement construction model for generating and optimizing SQL statements in a target system; responding to natural language requirements input by users in the target system, identifying key elements in the natural language requirements, and verifying whether the key elements exist in the enterprise data platform connected to the target system in combination with the enterprise data dictionary; inputting the verified target key elements into the statement construction model to generate a target SQL statement and corresponding performance optimization suggestions; converting the target SQL statement into business execution steps according to the execution logic and generating business description information; displaying the target SQL statement and the corresponding generation progress to the user in real time in an interactive interface; and displaying performance optimization suggestions and / or business description information matching the target SQL to the user in the interactive interface to assist the user in implementing SQL operations related to the enterprise business.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing, and in particular to a method and device for SQL optimization interaction based on a deep learning framework large model. Background Art

[0002] In the current digital age, big data technologies and database systems have become deeply integrated into every aspect of enterprise operations. Structured Query Language (SQL), as a core tool for enterprise data management and analysis, plays a vital role. It efficiently stores, queries, updates, and manages data in relational databases, providing critical data support for enterprise decision-making.

[0003] However, in the actual business development process, the use of SQL statements has exposed many difficult problems. For non-professional business personnel, the complexity of the SQL syntax structure, especially when it comes to advanced operations such as multi-table joins and nested queries, makes writing complex query statements an extremely challenging task, seriously hindering their ability to efficiently obtain the required data. In terms of SQL performance optimization, it currently relies mainly on the personal experience of developers and lacks a set of objective and standardized optimization methods. This leads to significant subjectivity in the optimization results, making it difficult to ensure the optimal solution for performance optimization, and there are certain limitations. For example, developers with different experience levels may adopt completely different optimization strategies for the same complex query, and the final execution efficiency will also vary greatly. Therefore, it is urgent to propose a new technical solution to solve at least one technical problem in the relevant technology. Summary of the Invention

[0004] In response to the technical problems existing in the prior art, this application provides a SQL optimization interaction method and device based on a deep learning framework large model to solve at least one of the above technical problems.

[0005] In a first aspect, an embodiment of the present application provides a SQL optimization interaction method based on a deep learning framework large model, the method comprising:

[0006] Deploy a statement building model for generating and optimizing SQL statements in the target system; wherein, the statement building model is obtained by fine-tuning and training the CodeLlama large language model through low-rank adaptation technology using a deep learning framework; in response to the natural language requirements input by the user in the target system, identify the key elements in the natural language requirements, and verify whether the key elements exist in the enterprise data platform connected to the target system in combination with the enterprise data dictionary; the key elements include at least: the data table, name description field, and / or operation field contained in the natural language requirements; input the verified target key elements into the statement building model, and generate a statement that matches the target system. Target SQL statements that match key elements and corresponding performance optimization suggestions; converting the target SQL statements into business execution steps according to the execution logic, and generating business description information for describing the business execution steps; wherein, the key tables or key fields involved in the business execution steps are highlighted in the business description information; displaying the target SQL statements and the corresponding generation progress to the user in real time in the interactive interface; in response to the user's viewing operation on the target SQL statements, displaying the performance optimization suggestions and / or business description information that match the target SQL to the user in the interactive interface, so as to assist the user in implementing SQL operations related to the enterprise business.

[0007] In a second aspect, an embodiment of the present application provides a SQL optimization interaction device based on a deep learning framework large model, the device comprising at least the following units:

[0008] A deployment unit is configured to deploy a statement construction model for generating and optimizing SQL statements in a target system; wherein the statement construction model is obtained by fine-tuning and training the CodeLlama large language model using a deep learning framework and a low-rank adaptation technique;

[0009] an identification unit configured to, in response to a natural language requirement input by a user in a target system, identify key elements in the natural language requirement and verify, in conjunction with an enterprise data dictionary, whether the key elements exist in an enterprise data platform connected to the target system; the key elements at least including: a data table, a name description field, and / or an operation field included in the natural language requirement;

[0010] A generating unit is configured to input the verified target key elements into the statement building model, and generate a target SQL statement matching the target key elements and a corresponding performance optimization suggestion;

[0011] a conversion unit configured to convert the target SQL statement into a business execution step according to the execution logic, and generate business description information for describing the business execution step; wherein the business description information highlights key tables or key fields involved in the business execution step;

[0012] The display unit is configured to display the target SQL statement and the corresponding generation progress to the user in real time in an interactive interface; in response to the user's viewing operation on the target SQL statement, the performance optimization suggestions and / or business description information matching the target SQL are displayed to the user in the interactive interface to assist the user in implementing SQL operations related to the enterprise business.

[0013] In a third aspect, an embodiment of the present application provides an electronic device, comprising: at least one processor, a memory, and an input / output unit; wherein the memory is used to store a computer program, and the processor is used to call the computer program stored in the memory to execute the SQL optimization interaction method based on a deep learning framework large model of the first aspect.

[0014] In a fourth aspect, a computer-readable storage medium is provided, which includes instructions. When the instructions are run on a computer, the computer executes the SQL optimization interaction method based on the deep learning framework large model of the first aspect.

[0015] The present application provides an interactive SQL optimization method and device based on a deep learning framework and large model. This technical solution first deploys a statement construction model in the target system for generating and optimizing SQL statements. The statement construction model is obtained by fine-tuning and training the CodeLlama large language model using a deep learning framework and low-rank adaptation technology. Furthermore, in response to a natural language requirement input by a user in the target system, the model identifies key elements in the natural language requirement and verifies, using the enterprise data dictionary, whether the key elements exist in the enterprise data platform connected to the target system. Key elements include at least the data table, name description field, and / or operation field contained in the natural language requirement. The verified target key elements are then input into the statement construction model to generate a target SQL statement that matches the target key elements and corresponding performance optimization recommendations. The target SQL statement is then converted into business execution steps according to the execution logic, and business description information describing the business execution steps is generated. The business description information highlights the key tables or key fields involved in the business execution steps. Furthermore, the target SQL statement and its generation progress are displayed to the user in real time in an interactive interface. Finally, in response to the user's viewing of the target SQL statement, the interactive interface displays performance optimization suggestions and / or business description information matching the target SQL statement, assisting the user in implementing SQL operations related to the enterprise's business. This technical solution significantly improves data acquisition efficiency, allowing business personnel to quickly obtain required information without writing SQL. It also establishes a standardized SQL optimization system, eliminating reliance on manual experience and ensuring stable query performance. Finally, it builds a data-driven business collaboration platform that promotes the deep integration of business and technology through natural language interaction and visual descriptions, ultimately helping enterprises maximize the mining and utilization of data value. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] Figure 1 This is a flowchart of an interactive method for SQL optimization based on a deep learning framework large model according to an embodiment of the present application;

[0017] Figure 2 This is a schematic diagram of the principles of an SQL optimization interaction method based on a deep learning framework large model according to an embodiment of the present application;

[0018] Figure 3 This is a structural diagram of an SQL optimization interaction device based on a deep learning framework large model according to an embodiment of the present application;

[0019] Figure 4 This is a schematic structural diagram of an electronic device according to an embodiment of the present application;

[0020] Figure 5 It is a structural diagram of a medium in an embodiment of the present application. DETAILED DESCRIPTION

[0021] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without making creative efforts are within the scope of protection of this application.

[0022] As big data mining and databases have become deeply integrated into every aspect of enterprise operations, SQL, as a fundamental tool for enterprise management and data analysis, plays a vital role. However, the use of SQL statements in related technologies has exposed many difficult issues.

[0023] First, the applicant found that for non-professional business personnel, the complexity of the SQL syntax structure, especially when it involves advanced operations such as multi-table joins and nested queries, makes writing complex query statements an extremely challenging task, seriously hindering their efficient acquisition of the required data.

[0024] Secondly, the applicant also discovered that SQL performance optimization currently relies primarily on the personal experience of developers, lacking an objective, standardized optimization method. This results in significant subjectivity in optimization results, making it difficult to ensure the optimal performance solution, and presenting certain limitations. For example, developers with different experience levels may adopt vastly different optimization strategies for the same complex query, resulting in significantly different execution efficiency.

[0025] In addition to the above-mentioned technical problems, the applicant also found that the existing SQL analysis tools have obvious deficiencies in their functions and are unable to automatically and accurately interpret the user's query intentions. Especially in a multi-source heterogeneous data environment, the data formats are diverse and the structures are complex, and business requirements change frequently, which makes SQL scripts lengthy and complicated. Not only is the development process time-consuming and labor-intensive, but the subsequent maintenance costs are also high, increasing the company's manpower and time cost investment. For example, common SQL editors and IDE tools have many drawbacks. When processing large data sets, they often exhibit limited performance problems, resulting in low efficiency and interface freezes, which greatly affect work efficiency, especially when conducting complex queries or large-scale data analysis. The problem is more prominent. Some tools also have many bugs and poor stability, and are prone to inexplicable crashes during use.

[0026] Therefore, in order to solve at least one technical problem in the related art, an embodiment of the present application provides a SQL optimization interaction method and device based on a deep learning framework large model.

[0027] In the technical solution of this application, a statement construction model for generating and optimizing SQL statements is first deployed in the target system. The statement construction model is derived by fine-tuning and training the CodeLlama large language model using a deep learning framework and low-rank adaptation technology. Furthermore, in response to natural language requirements entered by users in the target system, the model identifies key elements in the requirements and verifies, using the enterprise data dictionary, whether the key elements exist in the enterprise data platform connected to the target system. Key elements include at least the data tables, name description fields, and / or operation fields contained in the natural language requirements. The verified target key elements are then input into the statement construction model to generate target SQL statements that match the target key elements and corresponding performance optimization recommendations. The target SQL statements are then converted into business execution steps according to the execution logic, and business description information describing the business execution steps is generated. The business description information highlights the key tables or key fields involved in the business execution steps. Furthermore, the target SQL statements and their generation progress are displayed to the user in real time in an interactive interface. Finally, in response to the user's viewing operation on the target SQL statement, performance optimization suggestions and / or business description information matching the target SQL are displayed to the user in the interactive interface to assist the user in implementing SQL operations related to the enterprise business.

[0028] It is understandable that in the context of big data and databases being deeply integrated into corporate operations, non-professional business personnel face challenges with the complexity of SQL syntax, especially advanced operations such as multi-table joins and nested queries. The embodiment of the present application deploys a statement construction model based on a deep learning framework to convert natural language requirements into target SQL statements, which completely lowers the threshold for use. Business personnel do not need to master complex SQL syntax structures. They only need to enter natural language descriptions (such as "query for the top 10 products in sales in each region in the second quarter of 2025"). The system will automatically identify key elements such as data tables, fields, and operation fields, and verify their validity in combination with the enterprise data dictionary. Finally, the model generates corresponding SQL statements. This process converts complex operations such as multi-table associations and nested logic into internal model processing. Business personnel do not need to pay attention to the underlying syntax implementation, thereby efficiently acquiring data.

[0029] In response to the problem that SQL performance optimization relies on the personal experience of developers and lacks standardized methods, the embodiment of the present application constructs an objective optimization system through a deep learning large model. The model uses low-rank adaptation technology to fine-tune the CodeLlama large language model, enabling it to learn a large number of historical optimization cases and performance rules, and generate performance optimization suggestions with standardized logic. Unlike traditional optimization methods that rely on manual experience, the model will automatically analyze the performance bottlenecks of SQL statements based on objective indicators such as execution plans, index usage, and query costs, and output specific optimization solutions such as "adding a composite index to field B of table A" and "adjusting the order of JOIN tables to reduce the amount of data scanning." This method gets rid of the influence of subjective experience differences. Regardless of the developer's experience level, the same query can obtain the optimal optimization strategy based on model training, ensuring the consistency and scientific nature of the performance optimization results.

[0030] To address the difficulties existing SQL analysis tools face in interpreting query intent and high maintenance costs in multi-source, heterogeneous data environments, the present invention utilizes a "key element verification + business description generation" mechanism to achieve a breakthrough. First, the system leverages the enterprise data dictionary to verify data tables, fields, and other elements in natural language requirements, ensuring their accuracy within a multi-source, heterogeneous data platform and avoiding misunderstandings of intent due to complex data structures. Second, the generated SQL statements are converted into business execution steps based on execution logic. The query logic is explained in natural language by highlighting business descriptions of key tables and fields (e.g., "First, filter 2025 data from the order table, then join it with the product table to obtain classification information, and finally calculate sales by regional grouping"). This integrated presentation of SQL statements, business descriptions, and performance recommendations not only clarifies query intent during development but also allows for quick identification of SQL script adjustments when business requirements change, significantly reducing subsequent maintenance costs. Furthermore, the interactive interface displays SQL generation progress and optimization suggestions in real time, avoiding the lag and crash issues often associated with traditional tools processing big data and improving operational fluidity and stability.

[0031] The technical solution of the present application, and the SQL optimization interaction solution based on the deep learning framework large model provided in the embodiments of the present application, can also be executed by an electronic device, which can be a server, server cluster, or cloud server. The electronic device can also be a terminal device such as a mobile phone, computer, tablet computer, wearable device, or dedicated device (such as a dedicated terminal device with a SQL optimization interaction method based on the deep learning framework large model, etc.). These electronic devices can also be equipped with the chips or other hardware processing units described in the above embodiments. Alternatively, these electronic devices can also be installed with a service program for executing the SQL optimization interaction solution based on the deep learning framework large model.

[0032] Figure 1 A flowchart of a SQL optimization interaction method based on a deep learning framework large model provided in an embodiment of the present application is shown as follows: Figure 1 As shown, the method includes the following steps:

[0033] 101, deploying a statement building model for generating and optimizing SQL statements in the target system;

[0034] 102. In response to a natural language requirement input by a user in a target system, identifying key elements in the natural language requirement, and verifying whether the key elements exist in an enterprise data platform connected to the target system in conjunction with an enterprise data dictionary;

[0035] 103. Input the verified target key elements into the statement construction model to generate target SQL statements matching the target key elements and corresponding performance optimization suggestions;

[0036] 104. Convert the target SQL statement into a business execution step according to the execution logic, and generate business description information for describing the business execution step;

[0037] 105. Displaying the target SQL statement and the corresponding generation progress to the user in real time in the interactive interface;

[0038] 106. In response to the user's viewing operation on the target SQL statement, performance optimization suggestions and / or business description information matching the target SQL statement are displayed to the user in the interactive interface to assist the user in implementing SQL operations related to the enterprise business.

[0039] The above steps, through the deep integration of large-scale model technology and the enterprise data ecosystem, comprehensively address the pain points of traditional SQL operations. From a technical perspective, the CodeLlama fine-tuning model based on low-rank adaptation retains the code generation capabilities of the base model while rapidly adapting to enterprise-specific data structures through lightweight training, significantly reducing the model deployment threshold and computational costs. In practical applications, the natural language to SQL conversion process seamlessly meets business needs. Non-technical personnel simply enter a natural language description, and the system automatically identifies data tables, fields, and operation intent. After verification using the enterprise data dictionary, it generates optimized SQL, completely breaking the barrier of SQL syntax complexity. The generation and highlighting of business description information further enhances the transparency and maintainability of data operations. By converting SQL execution logic into business step descriptions with highlighted key tables and fields, business personnel can intuitively understand the data flow and calculation logic, while technical personnel can quickly identify key maintenance points, significantly reducing cross-departmental communication costs and system maintenance difficulties. The interactive design that displays real-time generation progress and performance optimization suggestions improves user experience and query efficiency, avoiding the lag and crash issues that often plague traditional tools when processing complex queries.

[0040] 101. Deploy a statement building model for generating and optimizing SQL statements in a target system.

[0041] In the embodiment of the present application, the statement construction model is obtained by fine-tuning and training the CodeLlama large language model through the low-rank adaptation (LoRA) technology using a deep learning framework. In this way, it inherits the code generation capability of the basic model and realizes the efficient injection of SQL domain knowledge through lightweight adaptation. As a large language model focusing on code generation, CodeLlama itself has the basic ability to understand program logic and grammatical structure, especially when processing structured query languages ​​​​such as SQL. It has a natural advantage. However, when directly applied to enterprise-level SQL optimization scenarios, its generalization ability cannot meet specific business needs, so it is necessary to transform general code capabilities into professional field capabilities through fine-tuning.

[0042] The core advantage of low-rank adaptation technology lies in its lightweight fine-tuning characteristics. Traditional full-parameter fine-tuning requires updating all parameters of a large model, which has high computational cost and is prone to overfitting. LoRA only achieves model adaptation by training a small number of learnable low-rank matrices, which greatly reduces the number of training parameters and computing resource consumption. In the embodiment of the present application, this technical feature enables the model to iterate quickly in the limited computing power environment of the enterprise data platform while maintaining the language understanding ability of the basic model. By converting SQL generation and optimization tasks into low-rank parameter updates for CodeLlama, the model can learn the structural patterns of SQL statements, performance optimization rules, and specific field associations in the enterprise data dictionary.

[0043] During the training process, the model gradually improves its professional capabilities through a multi-stage learning mechanism. First, pre-training is performed using a large-scale public SQL corpus, enabling the model to master basic SQL syntax rules, query patterns, and optimization strategies. Subsequently, historical SQL query logs and corresponding performance optimization records are introduced within the enterprise, allowing the model to learn the company's specific data structures and business logic through supervised learning. In particular, the training data includes a large number of complex query scenarios (such as multi-table joins and nested subqueries) and corresponding optimization solutions, enabling the model to understand the optimization direction of SQL statements for different business needs. Finally, a reinforcement learning mechanism is used to perform performance evaluation and feedback optimization on the generated SQL statements, ensuring that the model generates not only syntactically correct statements but also optimization solutions with high execution efficiency.

[0044] This low-rank adaptation-based fine-tuning training strategy brings significant technical advantages. On the one hand, while maintaining the basic code capabilities of CodeLlama, the model accurately captures the expertise in the SQL field and can generate high-quality SQL statements that conform to the enterprise data structure based on natural language requirements. On the other hand, the lightweight fine-tuning method makes model deployment more flexible and can quickly adapt to the dynamic changes of the enterprise data platform. For example, when a new data table or business field is added, only a small amount of incremental training is required to update the model capabilities. In addition, because LoRA technology only updates a small number of parameters, the interpretability of the model is also improved, making it easier for developers to understand and verify the generated SQL optimization suggestions, ensuring the reliable application of technical solutions in the enterprise environment.

[0045] As an optional embodiment, in 101, a statement construction model for generating and optimizing SQL statements is deployed in the target system, including: using a deep learning framework to load the CodeLlama large language model to be trained; during the setting process, the LoRA rank parameter is set to 8 and the scaling factor is set to 16 through the low-rank adaptation LoRA technology, and the original model parameters of the CodeLlama large language model are frozen, and only the newly added low-rank matrix is ​​trained. The historical SQL statements and the associated user demand texts and table structure descriptions in the enterprise data platform are constructed as a training set, and the training set is used to perform model training on the set CodeLlama large language model to obtain the adaptation layer parameters of the CodeLlama large language model. The adaptation layer parameters are integrated with the pre-selected base model to form the statement construction model, and deployed to the target system.

[0046] In the aforementioned optional embodiment, the statement construction model deployment principle is based on a lightweight transformation of the CodeLlama large model using Low Rank Adaptation (LoRA) technology. Specifically, by freezing the original CodeLlama model parameters and training only a newly added low-rank matrix (with a rank parameter set to 8 and a scaling factor of 16), the model captures the enterprise's specific SQL generation requirements through a low-dimensional mapping. This design leverages the principles of matrix decomposition to transform large-scale parameter updates into fitting a low-rank subspace. This preserves the code generation capabilities of the underlying model while also infusing business knowledge through the enterprise training set (historical SQL, user requirements, and table structure descriptions). For example, when an enterprise data platform contains specific table association rules (such as linking the order table and customer table by customer ID), the training set can guide the model to learn this structured knowledge, allowing the model to automatically adhere to the enterprise data logic when generating SQL.

[0047] Optionally, the high-dimensional model parameter space is mapped to a low-rank subspace to achieve efficient knowledge transfer by capturing the core change patterns in the data. In LoRA technology, the weight matrix of the original model is regarded as a base matrix containing universal knowledge, and the enterprise-specific SQL generation rules are incrementally modified by training the low-rank matrix. This decomposition is similar to breaking down a complex problem into multiple independent simple sub-problems, each of which corresponds to a column in the low-rank matrix, thereby capturing key information with a small number of parameters. For example, when enterprise data has a specific table association pattern (such as the order table and the customer table are associated by customer ID), matrix decomposition can encode this pattern as a specific column vector in the low-rank matrix, so that the model automatically follows the rule when generating SQL.

[0048] The technical advantage of matrix factorization lies in its balance between parameter efficiency and expressiveness. By limiting the rank parameter of low-rank matrices (e.g., 8), the model is forced to learn the essential characteristics of the data rather than superficial noise during training, akin to lossy knowledge compression. This compression not only reduces training parameters but also enhances the model's generalization, making it more adaptable to edge cases not found in the training set. When the training set contains only simple cases like "filtering by date," a model trained with matrix factorization can generate complex queries like "aggregating by date range" by combining existing knowledge, demonstrating reasoning capabilities that exceed those of the training data.

[0049] This dual-track mechanism of freezing and incrementing ensures both model stability and adaptability. The original model parameters are frozen, acting like a solid foundation, supporting the incremental learning of enterprise-specific knowledge. The low-rank matrix, on the other hand, acts like a scalable superstructure, dynamically adjusting to the needs of the enterprise. This architecture avoids the perturbations to global parameters encountered in traditional fine-tuning, preventing the model from forgetting old knowledge when adapting to new tasks. When an enterprise adds a new data field, it only needs to update the low-rank matrix without affecting the underlying model. This is like renovating a specific floor without changing the entire building structure, achieving a perfect combination of knowledge updating and stability.

[0050] The innovation of matrix factorization lies in its paradigm for training large models. By increasing model size or the amount of training data, performance is improved, while reorganizing knowledge representation through mathematical principles, achieving precise domain adaptation without significantly increasing resource consumption. By embedding enterprise-specific knowledge into low-rank matrices in a structured and interpretable manner, the model leverages the general code generation capabilities accumulated during pre-training while rapidly adapting to the enterprise's unique data structures and business logic, opening up new paths for the efficient application of large models in vertical domains.

[0051] As a result, firstly, the computing cost is significantly reduced. Compared with fine-tuning all parameters, the number of trainable parameters is reduced, so that the model can be quickly iterated in the enterprise's regular computing power environment. Secondly, the accuracy of domain adaptation is improved. By incorporating enterprise metadata such as table structure descriptions, the SQL statements generated by the model are more in line with the actual data structure, such as automatically avoiding non-existent fields or incorrect table associations. Thirdly, the deployment flexibility is enhanced. The decoupling design of the adaptation layer parameters and the base model enables the model to be incrementally trained as the enterprise data dictionary is updated, without the need to redeploy the entire base model. For example, when an enterprise adds a new data table, it only needs to supplement the corresponding training data to update the model capabilities, avoiding the time-consuming problem of full retraining in traditional solutions.

[0052] Compared with the existing technology, the embodiments of the present application, firstly, for the first time combine the LoRA technology with the CodeLlama model for enterprise-level SQL generation, and solve the "performance-efficiency" contradiction in large model fine-tuning through the combination of parameter freezing and low-rank training, which is different from the high resource consumption of traditional full-parameter fine-tuning. Secondly, the table structure description is introduced in the construction of the training set, so that the model can understand the enterprise data schema synchronously when learning the conversion from natural language to SQL. This is more adaptable to multi-source heterogeneous data environments than models trained solely on SQL corpora. Thirdly, the integration mechanism of the adaptation layer and the base model realizes a lightweight deployment mode with general capabilities and enterprise customization. Compared with the existing SQL tools that rely on manual rule configuration or fixed templates, it has stronger business adaptability and self-optimization capabilities.

[0053] In another optional embodiment, a visual language model (VLM) is used to build a mapping bridge between image semantics and SQL syntax. Leveraging the VLM's ability to understand visual information (e.g., chart structure and data dimensions) and generate language (e.g., SQL statement construction), it enables automated parsing of non-textual requirements. Taking Llama-3-Vision as an example, the model first uses a visual encoder to extract visual features from a chart, such as the timeline, indicator axis, and grouping dimensions. A language decoder then converts these features into the logical elements of an SQL statement (e.g., table names, fields, and filter conditions). Finally, the system generates executable SQL statements based on the enterprise data dictionary. Its core approach is to convert pixel information in an image into structured data requirements, breaking the limitations of traditional text input. For example, when a user uploads a sales chart (e.g., a bar chart showing quarterly sales), the system first pre-processes the image, using OCR technology to identify textual information within the chart (e.g., "2024 Q1," "Sales") and visual analysis to identify chart type (line chart / pie chart) and data relationships (e.g., horizontal axis: time, vertical axis: value). Next, VLM associates the identified visual elements with the enterprise data dictionary, for example, mapping "sales" to "Sales table. Amount field" and mapping the time range to "WHERE date BETWEEN 2024-01-01 AND 2024-03-31." Finally, based on the chart's implicit analytical intent (such as "group by quarter"), it generates the corresponding SQL statement (e.g., SELECT quarter, SUM(amount) FROM sales table GROUP BY quarter WHERE date BETWEEN...).

[0054] Therefore, traditional SQL generation only supports text input and cannot handle unstructured visual requirements such as charts and screenshots. Users need to manually convert image information into text descriptions, which is inefficient and error-prone. This application uses VLM to achieve "what you see is what you get" cross-modal interaction. Users can directly generate SQL based on charts without language conversion. It is especially suitable for scenarios where business personnel use visual reports to check the original data. It simplifies the data acquisition process from "chart understanding → text description → SQL generation" to "chart upload → automatic generation", greatly improving interaction efficiency.

[0055] In another alternative embodiment, a dynamic decision-making model for user interaction is constructed through reinforcement learning (RL). Each user action (such as modifying query conditions or confirming optimization suggestions) is treated as environmental feedback. By maximizing reward functions such as "demand understanding accuracy" or "user satisfaction," the optimal follow-up strategy or optimization path is learned. An online learning mechanism updates model parameters in real time, enabling the system to adapt to different user interaction habits. For example, when a user enters "search sales figures," the RL model predicts follow-up questions (such as "do I need to group by region?") based on historical interaction data. The model then adjusts its strategy based on user feedback, gradually refining the query to the point where accurate SQL can be generated. For example, the user interaction process can be modeled as a Markov decision process (MDP). The state space includes the current query text, extracted key elements, and historical interaction records; the action space includes follow-up questions (such as "please add a time range") and optimization suggestions (such as "do I need to add an index?"); and the reward function is designed based on the accuracy of the final SQL or the user confirmation rate. When a user enters a vague requirement, the RL model first extracts preliminary elements (such as the table name "sales table") through semantic analysis. It then selects the optimal follow-up action based on the current state (such as "Should statistics be calculated by product category?"). After the user responds, the state is updated and a reward is calculated. The model then optimizes subsequent decisions using a policy gradient algorithm. For example, if a user responds positively to the "time condition" follow-up question multiple times, the model will prioritize this type of follow-up.

[0056] Consequently, traditional SQL generation tools lack the ability to dynamically adjust interactively, requiring users to enter their entire requirements at once or following a fixed process (e.g., asking for table names first, then fields). These tools are unable to adapt to personalized scenarios. This application uses RL to implement "intelligent questioning," which dynamically adjusts interaction strategies based on user history and current context. For example, it reduces redundant questions for users familiar with the business and proactively guides users with ambiguous requirements to refine their requirements. This adaptive interaction model improves the conversion rate of requests from non-expert users.

[0057] 102. In response to a natural language requirement input by a user in a target system, identify key elements in the natural language requirement, and verify whether the key elements exist in an enterprise data platform connected to the target system in combination with an enterprise data dictionary.

[0058] In the embodiment of the present application, the key elements include at least: the data table, name description field, and / or operation field contained in the natural language demand. In the complex data environment of an enterprise, the natural language demands of users are often ambiguous and diverse, and clarifying the key elements such as the data table, name description field and operation field is the core prerequisite for accurately converting the demand into an SQL statement. The technical solution of the present application effectively builds a bridge between natural language and structured queries by accurately identifying these key elements. When the business personnel inputs "total sales of each store in March", potential data tables such as "store table" and "sales table", name description fields such as "store name", "sales date" and "sales amount", and operation fields such as "statistics" and "total amount" can be quickly extracted, and the unstructured language demand is deconstructed into structured data elements, laying the foundation for the subsequent generation of SQL statements.

[0059] The process of verifying key elements in conjunction with the enterprise data dictionary further ensures the accuracy and feasibility of data queries. In the enterprise data platform, data is distributed in different table structures, and field names, data types are closely related to business meanings. If the key elements mentioned in the user's needs do not exist in the data dictionary or are expressed incorrectly, the generated SQL statement will not be executed or will produce incorrect results. The system verification mechanism will check the identified key elements, such as verifying whether the "sales date" field exists in the corresponding table, and whether the "statistics" operation conforms to the data type of the field. If it is found that the expression of "March" is ambiguous, the system can link it to the specific date format of the "sales date" field through the data dictionary, and convert natural language into accurate conditions that can be recognized by SQL, thereby avoiding query failures due to data mismatches.

[0060] These key elements serve as the input core of the statement construction model and directly affect the generation quality and performance optimization direction of the target SQL statement. The clarity of the data table determines the association relationship of the JOIN operation in the SQL statement, the name description field guides the selection of the SELECT clause and the setting of the filter conditions of the WHERE clause, and the operation field corresponds to the logical implementation of aggregation functions, sorting rules, etc. Based on these key elements, the model can not only generate syntactically correct SQL statements, but also output targeted performance optimization suggestions based on the index information of the fields in the data dictionary, the partitioning status of the table, etc. When the system recognizes that the user needs to perform large-scale data statistics on the "sales table", it can recommend adding indexes to the relevant fields to optimize the execution efficiency of the GROUP BY operation, thereby generating SQL statements that meet business needs and have high performance.

[0061] Specifically, in 102, in the process of converting natural language to SQL, the core principle of key element identification and verification lies in building a mapping bridge between semantic understanding and data structure. Natural language processing technology is used to parse the entities and intentions in user needs. For example, from "querying the average consumption amount of new customers last month", data tables such as "customer table" and "consumption table" are extracted, as well as fields such as "registration time" and "consumption amount", and operation types such as "query" and "average". After these elements are converted into structured representations, they are compared with the enterprise data dictionary. The data dictionary stores meta-information such as table names, field names, and data types, which acts like a semantic validator to ensure that the extracted elements are legal and valid. If the user mentions the "membership level" field, it will verify whether the field exists in the customer table to avoid SQL generation errors due to missing fields.

[0062] Specifically, a multi-stage processing mechanism is adopted. First, named entity recognition is performed, and the pre-trained language model is used to annotate the data tables, fields, and operation keywords in the requirements. For example, "counting the number of employees in each department" is parsed into entities such as "department table", "employee table", "department name", "employee ID", and "statistics". Then the semantic disambiguation stage is entered to solve the ambiguity problem of natural language. For example, "customer" may refer to "potential customer table" in some contexts, and "active customer table" in other scenarios. The system determines the accurate mapping through context analysis and data dictionary association. Finally, integrity verification is performed to check whether the necessary elements are complete. For example, the query statement must include the table name and filter conditions. If key elements are missing in the user's requirements, an interactive query will be proactively initiated to complete the information.

[0063] This eliminates the need for business personnel to memorize complex data table structures and field names; they can simply describe their needs in natural language. This lowers the technical barrier and makes data analysis accessible to everyone. A validation mechanism ensures that generated SQL statements conform to the enterprise data architecture, preventing invalid queries and improving data acquisition efficiency. The system continuously learns from user feedback to optimize its recognition model. For example, it adjusts entity recognition rules based on high-frequency query patterns, forming a self-evolving semantic understanding system.

[0064] Compared with the existing technology, the core difference of the embodiment of the present application is the deep integration of enterprise data dictionary and dynamic semantic understanding. Traditional tools mostly rely on fixed templates or predefined keyword matching, and cannot adapt to changes in data structure or complex semantic scenarios. When an enterprise adds a "supplier evaluation form", traditional tools need to manually update the template to support related queries, while the embodiment of the present application automatically associates new tables through the data dictionary to instantly support natural language queries. This solution introduces a semantic disambiguation and integrity verification mechanism, which solves the query failure problem caused by polysemous words and missing elements in the existing technology, makes natural language SQL generation more robust and adaptable, and truly realizes the leap from "manual translation" to "intelligent understanding".

[0065] As an optional embodiment, in step 102, after verifying whether the key element exists in the enterprise data platform connected to the target system using the enterprise data dictionary, if multiple ambiguous associations are detected between the target key element and the enterprise data platform, the multiple ambiguous associations are pushed to the user, prompting the user to confirm at least one of the associations as the target association to be used. Furthermore, the target association is added to the target key element as input to the statement construction model.

[0066] The core principle of the above embodiment is to resolve the contradiction between the ambiguity of natural language and the structuring of the data platform. The ambiguity of natural language means that the same statement may correspond to multiple data objects in the enterprise data platform. For example, "sales record" may refer to multiple tables such as "monthly sales record table" and "quarterly sales summary table". When verifying key elements through the enterprise data dictionary, if there are multiple matching items, the system cannot determine the unique correspondence based on the existing information alone. At this time, pushing ambiguous related items to the user for confirmation is essentially using human understanding of the business scenario to convert fuzzy semantics into clear data objects, forming a closed loop from fuzzy natural language requirements to structured and accurate input, ensuring that the information received by the subsequent statement construction model is unique and accurate.

[0067] The specific solution utilizes a human-computer collaborative interaction mechanism. When the system identifies ambiguity in key elements, for example, if a user inputs "check sales of electronic products," and the data platform lists "electronic products" for both "mobile phone sales table" and "computer sales table," the system organizes all matching ambiguous associations (i.e., "mobile phone sales table" and "computer sales table") into a list or tabbed form, displaying them in the interactive interface and prompting the user to confirm via a prompt. Based on actual business needs, the user can select "mobile phone sales table" or multiple tables simultaneously as the final association. After receiving the user's confirmed selection, the selection is added to the target key element set, replacing the original ambiguous expression. This creates clear input information, such as "mobile phone sales table, sales volume field," which is then passed to the statement construction model.

[0068] Thus, the problem of SQL generation errors caused by natural language ambiguity is effectively solved, the system is prevented from generating invalid or erroneous SQL statements due to misjudgment of data objects, and the accuracy of data queries is improved. By giving the decision-making power to users, the deep understanding of human beings in business scenarios is fully utilized, the adaptability of the system is enhanced, and even if the structure of the enterprise data platform changes or new data tables or fields are added, new business needs can be quickly adapted through user interaction. This mechanism reduces the communication cost between business personnel and technical personnel. Business personnel do not need to confirm data objects with technical personnel in advance and can directly complete the selection in the interactive interface, which speeds up the data acquisition process. Compared with the existing technology, the innovation of this solution is reflected in the active interaction and dynamic adaptation capabilities. Traditional SQL generation tools often rely on fixed rules or predefined mapping relationships. When encountering semantic ambiguity, they either directly report an error and terminate the process, or randomly select a matching item, resulting in an erroneous result. The embodiment of the present application actively identifies ambiguity and guides user intervention through the interactive interface, realizing the transition from passive processing to active collaboration. The existing technology requires technicians to manually update the mapping rules when the data platform structure changes. However, the embodiment of the present application enables the system to dynamically adapt to data changes through instant user confirmation without the need for tedious manual configuration, greatly improving the flexibility and practicality of natural language SQL generation.

[0069] 103. Input the verified target key elements into the statement construction model to generate target SQL statements matching the target key elements and corresponding performance optimization suggestions.

[0070] As an optional embodiment, in 103, the target SQL statement is integrated with the associated business data items in the enterprise data platform through data lineage integration; in response to the user's viewing request or call request for the business data items in the target SQL statement, the current interactive interface is switched to the business application interface corresponding to the associated business data items. The core principle of the above embodiment is to build a full-link association system of "SQL statement-business data-application system" and realize the deep integration of technical logic and business scenarios through data lineage integration. The essence of data lineage is to track the data flow path. When the system generates the target SQL statement, it will synchronously parse the tables, fields and other data objects involved in the statement, and establish a mapping relationship with the business data items in the enterprise data platform, forming a traceability chain from SQL operations to the underlying business data. For example, when the SQL statement queries "customer consumption amount in the sales table", it will recognize that the "sales table" "customer consumption amount" field is associated with the "monthly sales data" and "customer consumption statistical indicators" in the business data items, and record this lineage relationship. When a user triggers a viewing request, the system maps the data object to the corresponding business application interface based on the preset application integration rules, realizing the scene jump from data query to business operation.

[0071] Specifically, the first layer is the lineage modeling layer. This layer uses metadata management tools to extract data objects from SQL statements and, in conjunction with the enterprise data dictionary, defines the lineage relationships between business data items, forming a structured lineage graph (e.g., "sales table → order details table → customer spending amount field → spending statistics module in the financial analysis system"). The second layer is the interaction triggering layer. In the interactive interface, clickable association markers (such as highlighting or underlining) are added to the business data items involved in the SQL statement. When the user clicks, the system captures the request and parses the target data item. Finally, the application switching layer uses pre-set interface protocols (such as URL parameter passing and inter-application messaging) to switch the current interface to the associated business application. This layer also carries data filtering criteria (e.g., "customer spending amount > 10,000"), allowing the business application to directly display the corresponding data content. For example, if a user clicks the "customer spending amount" field in an SQL statement, the system will invoke the financial system interface, jump to the detailed analysis page for that indicator, and automatically filter the relevant data.

[0072] Therefore, at the data governance level, data lineage integration makes the impact scope of SQL operations traceable. When business data items change (such as field renaming), the system can automatically prompt the affected SQL statements to reduce the risk of data changes; at the business efficiency level, users do not need to manually switch between SQL tools and business systems, and can directly jump to the target business interface with a click. For example, one-click entry into the financial approval process from a data analysis scenario shortens the business chain; at the user experience level, the seamless connection between lineage association and interface switching enables technical personnel to quickly obtain business background while understanding SQL logic, and business personnel can also understand data query results through familiar application interfaces, promoting cross-departmental collaboration.

[0073] Traditional SQL tools lack automated management of data lineage, and lineage relationships need to be manually maintained and are difficult to associate with business applications. Compared with existing technologies, the embodiments of the present application realize automatic generation and update of lineage through model training and metadata linkage. In existing solutions, SQL queries and business system operations are separated from each other, and users need to remember the access paths and data correspondences of different systems. The embodiments of the present application realize intelligent interaction of "click to jump" through semantic mapping. In terms of the depth of data application, traditional technologies only stay at the data query level, while the embodiments of the present application extend SQL operations to the business execution link through lineage integration, such as directly jumping from sales data queries to the order processing interface, realizing a closed loop of "data insights-business actions", which is an important expansion of the functional boundaries of traditional SQL tools.

[0074] In another optional embodiment, in 103, an initial SQL statement matching the target key elements is generated through the prediction layer in the statement construction model; potential logical errors and / or grammatical problems in the initial SQL statement are detected through the syntax parser in the statement construction model, and the detected potential logical errors and / or grammatical problems are repaired to obtain the target SQL statement; high-cost operations in the target SQL statement are identified, and performance optimization suggestions for optimizing the high-cost operations are generated.

[0075] The core principle of the above embodiment is to build a closed-loop system of "generation-verification-optimization" to improve the quality of SQL through the collaboration of multiple modules. The prediction layer maps the key elements parsed from the natural language into SQL statements based on a fine-tuned large language model. Its principle is similar to machine translation, and it masters the grammatical rules by learning massive SQL patterns. The syntax parser draws on compilation technology to convert the generated SQL into an abstract syntax tree, traverses the nodes to detect logical errors (such as unrelated tables) or grammatical problems (such as incorrect function calls), and corrects them through predefined repair rules (such as completing JOIN conditions). The performance optimization module is based on the principle of database execution plan, identifies high-cost operations (such as full table scans), and generates optimization suggestions based on the index information in the data dictionary, such as recommending adding indexes to frequently filtered fields.

[0076] In the above pipeline architecture, the prediction layer receives key elements and generates initial SQL (e.g., "SELECT * FROM order_table WHERE date = 2024"). The parser checks and finds a missing GROUP BY clause (if the requirement is statistical), automatically completing it or prompting the user. The performance optimization module analyzes and detects a full table scan of a large table and recommends adding an index on the date field. Throughout this process, each module seamlessly collaborates by sharing an intermediate representation (e.g., AST tree), and repair and optimization results are fed back to the prediction layer for iteration. This improves SQL generation accuracy and reduces manual debugging costs. The automated repair mechanism enables even non-technical personnel to generate compliant SQL. Performance optimization suggestions cover most common bottlenecks, improving query efficiency on average. Compared with existing technologies, traditional tools rely on fixed templates, cannot handle complex semantics, and lack automated repair capabilities. However, the embodiments of this application combine deep learning with compilation technology to achieve dynamic generation, intelligent repair, and real-time optimization, shortening the SQL development cycle and revolutionizing the traditional development model.

[0077] Further optionally, the above steps include detecting potential logical errors and / or grammatical issues in the initial SQL statement and repairing the detected potential logical errors and / or grammatical issues to obtain a target SQL statement, including: detecting whether the initial SQL statement has pre-set grammatical issues, where grammatical issues include at least one of the following: missing brackets, incorrect keyword order, and keyword errors; detecting whether the initial SQL statement has logical errors, where logical errors include at least one of the following: missing JOIN conditions. Then, repairing the detected potential logical errors and / or grammatical issues to obtain a target SQL statement, including: if a JOIN condition is missing in the initial SQL statement, obtaining a library of foreign key relationships between data tables, and recommending supplementary join conditions based on the library of foreign key relationships.

[0078] The core principle of this embodiment is to build an automated SQL statement verification and repair system, and ensure the grammatical and logical correctness of the generated SQL statements through rule matching and semantic analysis technology. In the grammatical parsing stage, the initial SQL statement is subjected to lexical and grammatical analysis based on pre-set grammatical rules, similar to how humans check statement errors against a grammar manual. The statement is broken down into lexical units and matched with preset rules (such as brackets must appear in pairs and keywords must be arranged in a specific order) to quickly locate grammatical problems. In the logical checking stage, the focus is on the rationality of the SQL statement execution logic. Taking the omission of JOIN conditions as an example, by analyzing the semantic associations between data tables, potential logical faults are identified, and the missing connection conditions are supplemented by the foreign key relationship library, thereby converting fuzzy logical intentions into complete execution logic.

[0079] The specific solution adopts a phased verification and repair mechanism. In the syntax detection phase, the system scans the initial SQL statement line by line. Once problems such as the mismatch in the number of brackets or the reversed order of the SELECT and FROM keywords are found, the error location will be marked immediately. During the logic detection, for JOIN operations, the system automatically queries the foreign key relationship library, which stores the associations between the various data tables in the enterprise data platform (such as the order table and the customer table are associated through the customer ID). If it is found that the JOIN operation does not specify the association condition, the corresponding field will be extracted from the foreign key relationship library, and it is recommended to add association conditions such as "ON order table.Customer ID=customer table.Customer ID". During the repair process, the recommended conditions are automatically completed first, and users are allowed to make manual adjustments to ensure that the repair results are consistent with both grammatical logic and business needs.

[0080] Thus, for non-professionals, the threshold for SQL writing is greatly lowered, and accurate and usable SQL statements can be generated without in-depth understanding of complex grammatical rules and logical relationships. For technical personnel, automated verification and repair reduces the time cost of manual error troubleshooting, avoids query failures due to low-level grammatical or logical errors, and improves development efficiency. At the same time, the application of foreign key relationship libraries makes SQL statements more accurate when tables are associated, ensuring the reliability of data query results. Compared with the existing technology, traditional SQL tools can usually only prompt grammatical errors, but cannot automatically repair them, and it is even more difficult to deal with problems at the logical level. When encountering missing JOIN conditions, developers need to manually check the table structure and supplement the conditions, which is inefficient and prone to errors. The embodiment of the present application not only realizes the automatic detection and repair of grammatical problems, but also innovatively uses the foreign key relationship library to solve logical errors, transforming passive error reporting into active repair, and fundamentally improving the quality and generation efficiency of SQL statements, making the SQL generation process more intelligent, efficient and reliable.

[0081] Further optionally, in the above steps, high-cost operations in the target SQL statement are identified, and performance optimization suggestions for optimizing the high-cost operations are generated, including: identifying high-cost operations in the target SQL statement, and recording the position of the high-cost operations in the target SQL statement; wherein the high-cost operations include at least one of the following: full table scan, sort overflow; counting the number of rows and tables, index coverage, occurrence frequency and associated contextual relationships of high-cost operations in the target SQL statement, and performing nested structure queries in the target SQL statement; based on the statistical results and nested structure queries, generating performance optimization suggestions for optimizing the counted high-cost operations; wherein the performance optimization suggestions include at least one of the following: adding joint indexes for high-frequency filtering fields, rewriting nested queries into temporary tables, and adjusting partitioning strategies to utilize data locality.

[0082] The core principle of the embodiment of the present application is to accurately locate high-cost operations that affect performance by deeply analyzing the SQL statement structure and execution logic, and generate optimization strategies based on data characteristics and execution environment. The system regards SQL statements as a textual expression of a complex execution process, and by disassembling the statement structure, it identifies operations that may cause excessive resource consumption, such as full table scans that reduce efficiency due to traversing a large amount of data, and sort overflows that reflect insufficient memory management. Based on the positioning of these operations, the system further analyzes their contextual relationships (such as associated table structures, query conditions), combines the index information stored in the data dictionary, partitioning schemes and other metadata, and derives optimization directions based on the database execution principles. For example, by adding indexes to reduce the data scanning range, or adjusting the query structure to avoid memory bottlenecks.

[0083] The specific solution adopts a multi-layer analysis and strategy generation mechanism. First, the system scans the target SQL statement section by section, marking high-cost operations such as full table scans and sort overflows and their specific locations in the statement, just like circling key problem paragraphs in an article. Then, it conducts an in-depth analysis of factors such as the number of rows and tables involved in these operations, whether the existing indexes can cover the query conditions, and the frequency of operations. At the same time, it identifies nested query structures and clarifies the order and dependencies of data processing. For example, when it is found that a certain SQL segment frequently performs full table scans on a large table and lacks an index, the system recommends adding a joint index on the high-frequency filtering field based on the frequency of use of the table's fields; if it is detected that complex nested queries lead to low execution efficiency, it is recommended to rewrite them as temporary tables to optimize the execution process. Finally, the system converts these analysis results into intuitive performance optimization suggestions and feeds them back to the user.

[0084] Compared with existing technologies, traditional SQL optimization relies more on the developer's experience and judgment or simple tool prompts, and lacks systematic and automated capabilities. When faced with complex queries, manual analysis is difficult to fully consider various factors and is prone to missing optimization points; ordinary tools can only provide basic performance warnings and cannot generate customized suggestions based on the characteristics of enterprise data. The embodiment of the present application can not only quickly locate high-cost operations through automated in-depth analysis, but also provide optimization strategies that meet the needs based on the actual structure and business scenarios of the data platform, turning passive problem discovery into active performance improvement. At the same time, the special analysis of nested structures and multi-dimensional statistics make the optimization suggestions more targeted and effective, which is significantly different from the one-size-fits-all optimization method of existing technologies, and greatly improves the efficiency and accuracy of SQL optimization.

[0085] Optionally, automated machine learning (AutoML) can be combined with the Bayesian optimization algorithm to build a closed-loop system for SQL performance optimization. AutoML is responsible for automatically generating and evaluating different index combinations and query rewriting solutions, while Bayesian optimization uses a probabilistic model to predict the performance benefits of each solution and quickly screen out the optimal solution. The SQL optimization problem is transformed into a search problem: in the index space (such as single-column indexes, composite indexes) and query structure space (such as nested queries to joins, subquery splitting), the Bayesian optimization algorithm is used to continuously explore high-value areas, while using historical optimization results to build prior knowledge and accelerate the convergence process. For example, when frequently executed aggregation queries are detected, the system automatically evaluates the performance improvement of creating indexes on different field combinations and predicts the optimal index configuration through the Bayesian model.

[0086] Specifically, the query analyzer is first used to identify frequently executed or time-consuming SQL statements and extract their features (such as table association patterns and filter conditions). Based on these features, the AutoML component generates candidate optimization solutions, including index recommendations (such as "create a composite index on the customer ID and date fields in the order table") and query rewriting strategies (such as "convert subqueries to JOIN operations"). The Bayesian optimization module builds a probabilistic model for each candidate solution, estimates its performance benefits based on historical optimization data, and selects the most promising solution for actual testing. The test results (such as execution time and resource consumption) are fed back to the Bayesian model to update parameters and iteratively adjust the search direction. For example, if it is found that adding a "customer ID + amount" index to the "order table" can significantly improve the performance of a certain type of query, the model will prioritize exploring related index combinations and reduce attempts at low-value solutions.

[0087] Traditional SQL optimization relies on DBAs to manually analyze execution plans and try different index configurations, which is inefficient and limited by personal experience. Existing automated tools can provide optimization suggestions, but they are typically based on preset rules or simple statistics and cannot handle complex scenarios (such as multi-table join queries). This introduces Bayesian optimization into the field of SQL optimization. Using probabilistic models to dynamically adjust search strategies, it can find the optimal solution with fewer attempts than random or grid searches. Simultaneously, the AutoML component automatically generates diverse optimization solutions covering multiple dimensions, such as index design and query structure adjustments, addressing the limitations of traditional tools that focus on a single optimization dimension. This combination of intelligent exploration and rapid convergence enables the system to find the optimal optimization solution for complex SQL queries in a short period of time, increasing optimization efficiency several times or even dozens of times. This is particularly suitable for enterprise-level scenarios with large data volumes and complex query patterns.

[0088] In an optional embodiment, after step 103, during the model operation and interaction process, user input information is collected, and input data relevant to the model operation is extracted from the input information. The extracted input data is constructed into user feedback terms, or new business terms and corresponding SQL statements are constructed for new businesses. The statement construction model is periodically incrementally trained based on the user feedback terms, new business terms, and corresponding SQL statements to improve its adaptability to enterprise business scenarios.

[0089] The core principle of the embodiment of the present application is to build a closed-loop mechanism for model adaptive optimization, and to feed back knowledge from real business scenarios into the model training process by continuously collecting user interaction data. The system regards user input information as a valuable training resource, from which it extracts natural language requirements, corresponding SQL generation results, and user correction operations. These data constitute a "living corpus" that reflects the real business logic of the enterprise. When the user adjusts the generated SQL (such as adding filtering conditions) or enters new requirements for new business scenarios, the system captures these changes and converts them into trainable terms. Through incremental training, the model continuously learns the enterprise-specific business rules and data patterns, forming a positive cycle of "use-feedback-optimization", and ultimately improving the accuracy and adaptability of the model in enterprise scenarios.

[0090] The specific solution adopts a three-stage process of data collection, knowledge extraction and model update. In the data collection stage, the system records the natural language requirements input by the user, the generated SQL statements, the user's modification operations on the SQL and the execution results in real time to form a complete interaction log. In the knowledge extraction stage, valid information is filtered from the log, the user's revised SQL is associated with the original requirements, and feedback entries are constructed; for new businesses, their characteristic patterns are identified through semantic analysis, new entries are created and demonstration SQL is generated. In the model update stage, these newly generated entries are regularly added to the training set, and the model is fine-tuned using low-rank adaptation technology. Only the parameters related to business changes are updated, and new business knowledge is injected while retaining existing capabilities. For example, when an enterprise adds a new "supplier rating" business, the system analyzes the relevant requirements and SQL, and integrates the calculation logic of the supplier rating into the model, so that it can automatically generate corresponding queries.

[0091] Compared with the existing technology, the traditional large model fine-tuning method usually relies on static training data, which is difficult to quickly adapt to the dynamically changing business scenarios of the enterprise, and the cost of frequent full-scale training is high. The innovation of the embodiment of the present application is to capture the dynamic knowledge in user interactions in real time, convert it into lightweight incremental training data, and achieve efficient fine-tuning through low-rank adaptation technology, which greatly reduces the cost and time of training. The existing technology lacks in-depth use of user feedback, and the embodiment of the present application regards every correction made by the user as an optimization opportunity, so that the model can continue to learn the data relationships and business logic unique to the enterprise, such as specific table association methods, field naming habits, etc. This dynamic optimization mechanism based on real scenarios makes the model's adaptability in the enterprise environment far superior to traditional pre-training models, and truly realizes the intelligent evolution from general capabilities to enterprise customization.

[0092] Furthermore, during model execution and interaction, a data skew detection algorithm can be used to identify hotspots of uneven data distribution. By combining data features with business scenarios, a more optimal partitioning strategy can be automatically recommended. Data skew can cause some partitions to be overloaded during queries, impacting overall performance. For example, when partitioning by user_id, if the data volume of a few users is too large, the corresponding partition can become a performance bottleneck. The detection algorithm analyzes the balance of data distribution to determine whether skew exists and, based on the storage structure and query patterns of the enterprise data platform, recommends partition key adjustments. Its core logic is to distribute data across multiple partitions through data feature analysis to improve parallel processing capabilities and query efficiency.

[0093] Before or during SQL execution, the data tables involved are tested for data skew. First, by scanning data samples or metadata, the differences in data volume, field value distribution and other indicators of each partition are evaluated to determine whether the data is skewed. For example, if it is found that after a table is partitioned by user_id, some users occupy 80% of the data volume, it is determined to be skewed. Subsequently, the system recommends a new partition key combination based on the query conditions of the table (such as high-frequency filtering fields) and business needs (such as statistics by time). If the query often involves time range and user information, the system may recommend changing the single user_id partition to a composite partition of date+user_id, so that the data is evenly distributed in both time and user dimensions. Finally, the system will feedback the optimization suggestions to the user and provide specific operational instructions for partition adjustment to help users quickly resolve data skew problems.

[0094] Therefore, traditional data partitioning relies on manual experience or fixed rules, which makes it difficult to adapt to dynamic data changes and complex query scenarios. For example, operations and maintenance personnel may choose partition keys based on historical experience, but as data grows or business changes, the original partitioning strategy may become invalid. Even if existing tools can detect data skew, they only provide simple warnings and lack targeted optimization suggestions. The innovation of lies in combining data skew detection with intelligent recommendations, which can not only automatically identify problems, but also generate customized partitioning strategies based on data characteristics and business needs. By dynamically adjusting the partition key, data hotspots can be effectively avoided, query performance can be improved, and the cost of manual intervention can be reduced. It is especially suitable for enterprise scenarios with large data scales and changing query patterns, solving the problems of poor flexibility and low optimization efficiency of traditional solutions.

[0095] Furthermore, during model execution and interaction, machine learning algorithms can be used to analyze historical query patterns, predict future high-frequency query fields, and strike a balance between index optimization and storage overhead. Traditional indexing strategies are prone to over-indexing. While excessive indexing improves query speed, it takes up a large amount of storage space and slows down data writing efficiency. RandomForest or time series prediction models, on the other hand, can mine patterns from massive amounts of historical query records, identify the field combinations that truly impact query performance, create indexes only for high-frequency query fields, and delete inefficient or redundant indexes, enabling dynamic allocation and intelligent management of index resources.

[0096] Therefore, data such as historical SQL query statements, execution time, and resource consumption are continuously collected to build a data set containing dimensions such as query fields, execution frequency, and response time. The RandomForest model classifies historical queries to identify frequently accessed field combinations; the time series prediction model analyzes query trends based on the time dimension and predicts high-frequency queries that may appear in the future. For example, if the model finds that the frequency of joint queries on the "Date" and "Sales" fields of the "Sales Table" surges at the end of each month, it will recommend creating a composite index in advance. Conversely, if an index has not been used for a long time, the system will prompt you to delete it. Before executing the index adjustment, the system will also simulate the impact of index changes on query performance and storage, generate an optimization plan after weighing the pros and cons, and push the operation suggestions to the administrator for confirmation and execution.

[0097] 104 : Convert the target SQL statement into a business execution step according to the execution logic, and generate business description information for describing the business execution step.

[0098] 105. Display the target SQL statement and the corresponding generation progress to the user in real time in the interactive interface.

[0099] 106. In response to the user's viewing operation on the target SQL statement, performance optimization suggestions and / or business description information matching the target SQL statement are displayed to the user in the interactive interface to assist the user in implementing SQL operations related to the enterprise business.

[0100] In an embodiment of the present application, the business execution step is to decompose the target SQL statement into a concise and intuitive business operation process based on its internal execution logic, and present it in text through business description information. Key tables and fields will also be highlighted. For example, when the SQL statement is "SELECT product_name, COUNT (*) FROM sales JOINproducts ON sales.product_id = products.product_id GROUP BY product_name", the corresponding business execution step description is "first associate the sales table with the product table based on the product ID, then group the associated data according to the product name, and count the sales quantity of each product", among which key information such as "sales table", "product table", "product ID" and "product name" will be highlighted. This method allows business personnel to quickly understand the data query logic without being proficient in SQL syntax, reduces communication barriers between business and technical personnel, and provides a clear context for the adjustment and maintenance of subsequent SQL statements, reducing the risk of errors caused by misunderstandings.

[0101] As an optional embodiment, after generating a target SQL statement matching the target key elements and the corresponding performance optimization suggestions in step 103, or after generating business description information describing the business execution steps in step 104, the process further includes detecting whether the target SQL statement, the corresponding performance optimization suggestions, and the business description information contain sensitive data. If sensitive data is contained, the corresponding user authorization information is obtained through a permission module, and permission verification is performed on the user to be fed back to determine whether the user to be fed back has permission to view and / or operate the sensitive data.

[0102] The core principle of the above embodiment is to build a protection system for data security and permission control, and to ensure the controllable access to the core data of the enterprise by identifying sensitive data in SQL operations and combining it with the user permission verification mechanism. In the enterprise data environment, some data (such as financial statements and customer privacy information) involve commercial secrets or privacy protection, which will cause serious risks once leaked. The system scans the generated target SQL statements, performance optimization suggestions and business description information to identify the sensitive data types contained therein (such as ID number and salary fields), and binds data access rights to user identities based on the permission policies pre-set by the enterprise. This design is based on the "principle of least privilege", that is, sensitive data is only open to users with corresponding permissions, and a security line is built in the data display link through permission verification to prevent unauthorized access.

[0103] The specific solution utilizes a three-level protection mechanism: data identification, permission verification, and access control. First, during the data identification phase, a sensitive data dictionary and pattern matching techniques are used to scan for keywords in target SQL statements, the field names, the operation objects involved in performance optimization recommendations, and the business description. For example, if the "customer ID number" field appears in an SQL statement, or if the business description mentions "employee salary statistics," these data are immediately marked as sensitive. Next, the permission verification phase begins. The permission module retrieves user authorization information, which records the user's role, permission scope, and data access level (e.g., "Finance Department can view salary data"). The user's identity is matched to the access permissions granted to sensitive data to determine whether the user has permission to view or operate. Finally, the access control phase performs appropriate actions based on the verification results. If the user's permissions match, the data is displayed normally. If the permissions are insufficient, sensitive information is automatically blocked or access is denied, and a notification indicating insufficient permissions is provided to the user, ensuring that sensitive data remains securely protected.

[0104] Compared with existing technologies, the permission control of traditional SQL tools or data platforms often stays at the database level, and only imposes coarse-grained restrictions on access to tables or libraries, and cannot accurately control sensitive information in specific query content, optimization suggestions, or business descriptions. For example, a user may obtain an SQL statement containing sensitive fields but cannot identify its sensitivity, resulting in the risk of data leakage. The innovation of this application lies in extending permission control to the entire process of data generation and display, actively identifying sensitive information from the content level, and dynamically controlling it in combination with fine-grained permission policies. At the same time, this solution achieves a balance between data security and business needs, which not only ensures the security of sensitive data, but also provides users with complete SQL analysis results and business descriptions when permissions permit, avoiding the impact of excessive protection on normal business operations. Compared with traditional technologies, it achieves a better balance between data security and ease of use.

[0105] In an embodiment of the present application, the key tables or key fields involved in the business execution steps are highlighted in the business description information. In the scenario of enterprise data processing and analysis, the execution logic of SQL statements is often obscure and difficult to understand, and the communication cost between business personnel and technical personnel is extremely high. In an embodiment of the present application, by converting the target SQL statement into a business execution step and highlighting the key tables or key fields in the business description information, the abstract SQL language can be converted into an intuitive and easy-to-understand business language. When the SQL statement "query the sales of each product category in the past three months" is generated, its execution logic will be disassembled into business execution steps such as "filtering the data of the past three months from the sales record table, then associating with the product information table to obtain category information, and finally summarizing the sales by product category". The key tables and fields involved, such as "sales record table", "product information table", "sales amount", "product category", etc., will be highlighted, so that business personnel can quickly understand the specific process and core elements of data query without having to understand complex SQL syntax.

[0106] It is understandable that highlighting key tables and key fields can significantly improve the transparency and traceability of data operations. In a multi-source heterogeneous data environment, data is distributed in different database tables and fields, and the execution of SQL statements involves multiple links. Through highlighting, users can see at a glance where the data comes from, what processing it has undergone, and what results are finally output. When an enterprise needs to trace the calculation process of a certain business indicator, the key tables and fields highlighted in the business description information can clearly present the data flow, helping users quickly locate the data source and calculation logic, avoiding confusion about "where the data comes from and how it is calculated", and greatly improving the efficiency of data auditing and problem solving.

[0107] This design also helps reduce the maintenance cost of SQL statements. As the business grows and the data structure changes, SQL statements need to be constantly adjusted and optimized. The highlighted business description information provides a clear guide for subsequent maintenance work. When business requirements change and SQL statements need to be modified, developers can quickly identify the affected business execution steps based on the highlighted key tables and fields, and accurately locate the parts of the SQL statement that need to be modified without having to reorganize the entire query logic. This visual presentation method not only reduces maintenance time, but also reduces the risk of modification errors caused by misunderstandings, making the maintenance of SQL statements more efficient and accurate.

[0108] In the embodiment of the present application, the generation progress is the process of generating the target SQL statement, and the system provides real-time feedback to the user through the interactive interface on the real-time status of the statement generation. When the user inputs a complex natural language requirement such as "analyze the consumption trends of customers of different age groups in various regions in the past year", the statement construction model needs to go through multiple links. At this time, the interactive interface will display the generation progress in the form of a progress bar, percentage text, etc., such as "SQL statement generation progress: 75%". Users can use this to intuitively understand the system processing progress and reduce anxiety while waiting. If the generation process is abnormally stagnant, they can also discover and adjust the needs in time, improve work efficiency, and avoid wasting time and energy in inefficient waiting.

[0109] In the embodiments of the present application, the performance optimization suggestion is an execution efficiency improvement strategy proposed by the system for the generated target SQL statement using the analysis capability of the statement construction model. For example, when the SQL statement involves a complex query on a large data table, the system may give the suggestion of "establishing a composite index for the relevant fields according to the query conditions." If the statement contains multiple JOIN operations, it may be suggested to "adjust the JOIN order of the table and give priority to associating tables with small data volumes." These suggestions get rid of the dependence on the individual experience of developers, and provide users with a unified and scientific optimization solution based on objective model training and data analysis. Regardless of the user's technical level, they can obtain professional optimization guidance to ensure the efficient operation of SQL statements, reduce the resource loss and operating costs of enterprises due to SQL performance issues, and improve data processing efficiency.

[0110] In combination with the above embodiments, refer to Figure 2 In one optional example of this application, users enter requirements through the development management platform. The platform then passes these requirements to the natural language interaction module, which takes the relevant content (SQL, natural language, numerical values, etc.) as input and calls the large model interface, triggering the SQL generation and optimization engine. During model training and deployment, historical SQL and corresponding business requirement text are exported from the enterprise data platform to build a dataset. After cleaning, the pre-trained large language model is fine-tuned using low-rank adaptation techniques. Upon completion, the adaptation layer and the base model are integrated to form a deployment model. During SQL generation and optimization, the natural language interaction module first parses user input, extracts core elements, verifies the associated data dictionary, calls the model to generate initial SQL, corrects syntax and logic, and then uses execution plan analysis tools to optimize performance and provide suggestions such as indexing and query rewriting. For system integration applications, SQL functionality is encapsulated as a RESTful API with permission authentication. A visual interactive interface is designed on the front end to display generation progress and optimization suggestions. It also integrates data lineage, records the table fields involved in the SQL, and downstream dependencies, making it easier for users to trace the source. Finally, verification and iteration are carried out. The generation accuracy is verified using the historical use case library before going online. User feedback is collected during operation. The model is trained incrementally on a regular basis to continuously improve the generation effect in complex scenarios and ensure continuous optimization of the system.

[0111] In an optional embodiment, by leveraging the cross - language representation ability of the pre - trained model, through zero - shot learning or lightweight adapter fine - tuning, the SQL generation ability is migrated to low - resource languages or dialect scenarios. Taking LM - RoBERTa as an example, during the pre - training stage, the semantic commonalities of multiple languages are learned. By adjusting a small number of parameters (such as adding language - specific adapters), the mapping ability of "natural language → SQL" in Chinese can be migrated to low - resource languages such as Spanish and Swahili. Zero - shot learning directly utilizes the cross - language understanding ability of the model. Without target - language training data, it can parse the requirements in low - resource languages into SQL key elements. Specifically, for a low - resource language input (such as Arabic "أحصلعلىإجماليالمبيعات"), first, the semantic features are extracted through a multilingual pre - trained model, and then mapped to the semantic space of Chinese or English using cross - language word embedding technology. Subsequently, the corresponding SQL statement is generated based on the existing SQL generation model. For dialect scenarios (such as Cantonese "揾下季度各分店销售额"), fine - tuning is performed by adding a dialect adapter. The adapter only contains a small number of trainable parameters. By learning the mapping relationship between dialect words and standard languages (such as "揾" → "查询"), the parsing accuracy is improved. During the training process, a cross - language contrastive learning strategy is adopted to ensure the alignment of semantic representations in different languages and avoid over - fitting caused by data scarcity.

[0112] Consequently, traditional SQL tools only support mainstream languages such as English and Chinese, and have almost no support for low - resource languages or dialects. Enterprises need to rely on manual translation for cross - border business requirements, increasing communication costs and error risks. Through multilingual transfer learning, the system can directly process natural language inputs in dozens of low - resource languages and dialects. For example, Southeast Asian enterprises can directly input requirements in Indonesian to generate SQL without the translation process. Compared with traditional solutions, its innovation lies in leveraging the cross - language generalization ability of the pre - trained model to achieve language expansion at an extremely low training cost (only requiring a small number of target - language samples or zero samples), solving the problem of data acquisition in low - resource language scenarios.

[0113] In the technical solution of this application, first, it significantly improves the data acquisition efficiency. Business personnel can quickly obtain the required information without writing SQL. Second, it establishes a standardized SQL optimization system, getting rid of the dependence on manual experience and ensuring the stability of query performance. Third, it constructs a data - driven business collaboration platform. Through natural - language interaction and visual description, it promotes the deep integration of business and technology, ultimately helping enterprises maximize the mining and utilization of data value.

[0114] In another embodiment of this application, a SQL optimization interaction device based on a large - model of a deep - learning framework is also provided. Refer to Figure 3 As described, the device includes the following units:

[0115] A deployment unit is configured to deploy a statement construction model for generating and optimizing SQL statements in a target system; wherein the statement construction model is obtained by fine-tuning and training the CodeLlama large language model using a deep learning framework and a low-rank adaptation technique;

[0116] an identification unit configured to, in response to a natural language requirement input by a user in a target system, identify key elements in the natural language requirement and verify, in conjunction with an enterprise data dictionary, whether the key elements exist in an enterprise data platform connected to the target system; the key elements at least including: a data table, a name description field, and / or an operation field included in the natural language requirement;

[0117] A generating unit is configured to input the verified target key elements into the statement building model, and generate a target SQL statement matching the target key elements and a corresponding performance optimization suggestion;

[0118] a conversion unit configured to convert the target SQL statement into a business execution step according to the execution logic, and generate business description information for describing the business execution step; wherein the business description information highlights key tables or key fields involved in the business execution step;

[0119] The display unit is configured to display the target SQL statement and the corresponding generation progress to the user in real time in an interactive interface; in response to the user's viewing operation on the target SQL statement, the performance optimization suggestions and / or business description information matching the target SQL are displayed to the user in the interactive interface to assist the user in implementing SQL operations related to the enterprise business.

[0120] The above-mentioned device can implement various steps in the above-mentioned method embodiment, which will not be expanded here.

[0121] See also Figure 4 , Figure 4 This is a schematic diagram of an embodiment of an electronic device provided in an embodiment of the present application. Figure 4 As shown, an embodiment of the present application provides an electronic device 500, including a memory 510, a processor 520, and a computer program 511 stored in the memory 510 and executable on the processor 520. When the processor 520 executes the computer program 511, an SQL optimization interaction method based on a deep learning framework large model is implemented.

[0122] See also Figure 5 , Figure 5 This is a schematic diagram of an embodiment of a computer-readable storage medium provided in an embodiment of the present application. Figure 5As shown, this embodiment provides a computer-readable storage medium 600 on which a computer program 611 is stored. When the computer program 611 is executed by a processor, an SQL optimization interaction method based on a deep learning framework large model is implemented.

[0123] It should be noted that in the above embodiments, the descriptions of each embodiment have different emphases. For portions not described in detail in a particular embodiment, reference should be made to the relevant descriptions of other embodiments. Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Furthermore, the present application may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk drives, CD-ROMs, optical storage devices, etc.) containing computer-usable program code. Although preferred embodiments of the present application have been described, those skilled in the art may make further changes and modifications to these embodiments once they understand the basic inventive concepts. Therefore, the appended claims are intended to include the preferred embodiments and all variations and modifications falling within the scope of the present application. Obviously, those skilled in the art may make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if such changes and modifications fall within the scope of the present claims and their equivalents, the present application is intended to include such changes and modifications.

Claims

1. A SQL optimization interaction method based on a deep learning framework large model, characterized in that: The method comprises: A statement construction model for generating and optimizing SQL statements is deployed in a target system, including: using a deep learning framework to load the CodeLlama large language model to be trained; during the setting process, the LoRA rank parameter is set to 8, the scaling factor is set to 16 through the low-rank adaptation LoRA technology, and the original model parameters of the CodeLlama large language model are frozen, and only the newly added low-rank matrix is ​​trained; historical SQL statements and associated user demand texts and table structure descriptions in the enterprise data platform are constructed as a training set, and the set CodeLlama large language model is trained using the training set to obtain the adaptation layer parameters of the CodeLlama large language model; the adaptation layer parameters are integrated with the pre-selected base model into the statement construction model, and deployed to the target system; wherein, the statement construction model is obtained by fine-tuning and training the CodeLlama large language model through the low-rank adaptation technology using the deep learning framework; In response to a natural language requirement input by a user in a target system, identifying key elements in the natural language requirement and verifying, in conjunction with an enterprise data dictionary, whether the key elements exist in an enterprise data platform connected to the target system; the key elements include at least: a data table, a name description field, and / or an operation field included in the natural language requirement; Inputting the verified target key elements into the statement construction model, generating a target SQL statement that matches the target key elements and corresponding performance optimization suggestions, including: generating an initial SQL statement that matches the target key elements through a prediction layer in the statement construction model; detecting potential logical errors and / or grammatical problems in the initial SQL statement through a syntax parser in the statement construction model, and repairing the detected potential logical errors and / or grammatical problems to obtain a target SQL statement; identifying high-cost operations in the target SQL statement, and generating performance optimization suggestions for optimizing the high-cost operations; Convert the target SQL statement into a business execution step according to the execution logic, and generate business description information for describing the business execution step; wherein the business description information highlights the key tables or key fields involved in the business execution step; Display the target SQL statement and the corresponding generation progress to the user in real time in the interactive interface; In response to the user's viewing operation on the target SQL statement, performance optimization suggestions and / or business description information matching the target SQL are displayed to the user in the interactive interface to assist the user in implementing SQL operations related to the enterprise business.

2. The SQL optimization interactive method based on the deep learning framework large model according to claim 1 is characterized in that: The step of inputting the verified target key elements into the statement building model to generate target SQL statements matching the target key elements and corresponding performance optimization suggestions includes: Performing data lineage integration on the target SQL statement and the associated business data items in the enterprise data platform; In response to a user's request to view or call a business data item in the target SQL statement, the current interactive interface is switched to a business application interface corresponding to the associated business data item.

3. The SQL optimization interactive method based on the deep learning framework large model according to claim 1 is characterized in that: The detecting potential logical errors and / or grammatical problems in the initial SQL statement and repairing the detected potential logical errors and / or grammatical problems to obtain the target SQL statement includes: Check whether there are pre-set syntax problems in the initial SQL statement; syntax problems include at least one of the following: missing brackets, incorrect keyword order, and incorrect keywords; Check whether there are logical errors in the initial SQL statement; logical errors include at least one of the following: missing JOIN conditions; Repairing the detected potential logic errors and / or syntax problems to obtain the target SQL statement includes: If there are any missing JOIN conditions in the initial SQL statement, obtain the foreign key relationship library between the data tables and recommend additional association conditions based on the foreign key relationship library.

4. The SQL optimization interactive method based on the deep learning framework large model according to claim 1 is characterized in that: The step of identifying high-cost operations in the target SQL statement and generating performance optimization suggestions for optimizing the high-cost operations includes: Identify high-cost operations in the target SQL statement and record the location of the high-cost operations in the target SQL statement; wherein the high-cost operations include at least one of the following: full table scan, sort overflow; Counting the number of rows and tables, index coverage, occurrence frequency, and associated contextual relationships of high-cost operations in the target SQL statement, and performing nested structure query in the target SQL statement; Based on the statistical results and nested structure queries, performance optimization suggestions are generated for optimizing the statistically high-cost operations. The performance optimization suggestions include at least one of the following: adding joint indexes for high-frequency filtering fields, rewriting nested queries into temporary tables, and adjusting partitioning strategies to utilize data locality.

5. The SQL optimization interactive method based on the deep learning framework large model according to claim 1 is characterized in that: After verifying whether the key elements exist in the enterprise data platform connected to the target system by combining the enterprise data dictionary, the following steps are also included: If it is detected that there are multiple ambiguous association items between the target key element and the enterprise data platform, the multiple ambiguous association items are pushed to the user to prompt the user to confirm at least one of the association items as the target association item to be finally used; The target association items are added to the target key elements as inputs to the sentence building model.

6. The SQL optimization interactive method based on the deep learning framework large model according to claim 1 is characterized in that: After inputting the verified target key elements into the statement building model and generating target SQL statements matching the target key elements and corresponding performance optimization suggestions, the method further includes: During the model operation and interaction process, user input information is collected and input data related to the model operation is extracted from the input information; Construct the extracted input data into user feedback terms, or construct new business terms and corresponding SQL statements for new businesses; Combined with user feedback terms, newly added business terms and corresponding SQL statements, the statement construction model is regularly incrementally trained to improve the adaptability of the statement construction model to enterprise business scenarios.

7. The SQL optimization interactive method based on the deep learning framework large model according to claim 1 is characterized in that: After generating the target SQL statement matching the target key element and the corresponding performance optimization suggestion, or generating the business description information for describing the business execution steps, the method further includes: Detect whether the target SQL statement, the corresponding performance optimization suggestions, and the business description information contain sensitive data; If sensitive data is included, the corresponding user authorization information is obtained through the permission module, and the permission of the user to be fed back is verified to determine whether the user to be fed back has the permission to view and / or operate the sensitive data.

8. A SQL optimization interactive device based on a deep learning framework large model, characterized in that: The device comprises the following units, wherein: A deployment unit is configured to deploy a statement construction model for generating and optimizing SQL statements in a target system; wherein, the statement construction model is obtained by fine-tuning and training the CodeLlama large language model using a deep learning framework through low-rank adaptation technology; the deployment unit is specifically configured to: load the CodeLlama large language model to be trained using a deep learning framework; during the setting process, set the LoRA rank parameter to 8 and the scaling factor to 16 through the low-rank adaptation LoRA technology, and freeze the original model parameters of the CodeLlama large language model, and only train the newly added low-rank matrix; construct historical SQL statements and associated user demand texts and table structure descriptions in the enterprise data platform as a training set, and use the training set to train the set CodeLlama large language model to obtain the adaptation layer parameters of the CodeLlama large language model; integrate the adaptation layer parameters with the pre-selected base model into the statement construction model, and deploy it to the target system; an identification unit configured to, in response to a natural language requirement input by a user in a target system, identify key elements in the natural language requirement and verify, in conjunction with an enterprise data dictionary, whether the key elements exist in an enterprise data platform connected to the target system; the key elements at least including: a data table, a name description field, and / or an operation field included in the natural language requirement; The generation unit is configured to input the verified target key elements into the statement construction model, and generate a target SQL statement that matches the target key elements and a corresponding performance optimization suggestion; the generation unit is specifically configured to: generate an initial SQL statement that matches the target key elements through the prediction layer in the statement construction model; detect potential logical errors and / or grammatical problems in the initial SQL statement through the syntax parser in the statement construction model, and repair the detected potential logical errors and / or grammatical problems to obtain a target SQL statement; identify high-cost operations in the target SQL statement, and generate performance optimization suggestions for optimizing the high-cost operations; a conversion unit configured to convert the target SQL statement into a business execution step according to the execution logic, and generate business description information for describing the business execution step; wherein the business description information highlights key tables or key fields involved in the business execution step; The display unit is configured to display the target SQL statement and the corresponding generation progress to the user in real time in an interactive interface; in response to the user's viewing operation on the target SQL statement, the performance optimization suggestions and / or business description information matching the target SQL are displayed to the user in the interactive interface to assist the user in implementing SQL operations related to the enterprise business.

Citation Information

Patent Citations

  • Text2SQL semantic parsing method for domain large language model

    CN118377796A

  • Data query and visualization method and system based on large language model

    CN118820315A