Using AI Optimizer

The AI-powered Query Optimization feature enables users to select a query and optimize it with a single click. The AI engine analyzes the selected query, rewrites it for improved performance, identifies potential bottlenecks, and provides actionable schema recommendations to enhance data efficiency.

Available since Foglight 8.1.0, this feature supports SQL Server, Oracle, Azure DB, DB2, SAP ASE, PostgreSQL, and MySQL.

To access AI Optimizer, click Query Insights on the Welcome page, or navigate to Databases > Query Insights in the left navigation pane. For more information about Query Insights, refer to Viewing Query Insights.

The AI Optimizer is available in multiple locations. You can start using it in Query Insights and Query Explorer. This section demonstrates how to activate it from Query Insights, but the steps are the same in other locations.

Key Benefits

  • Automated Query Rewriting: Instantly generates optimized versions of queries to deliver faster and more efficient results.
  • Bottleneck Detection: Identifies slow-running operations and performance issues, helping users address problems before they affect workflows.
  • Schema Recommendations: Provides AI-driven suggestions for schema enhancements, such as indexing or normalization, to support scalable performance.
  • Enhanced Productivity: Reduces manual analysis time, allowing users to focus on insights and innovation instead of query tuning.

To use the AI Optimizer feature, you need a license. To generate a license, refer to Generating a License.

Literals are always removed before a query is sent for optimization to ensure security.

To use AI Optimizer:

  1. Navigate to Databases > Query Insights in the left pane. The Query Insights page displays the list of all queries.


  2. Click on the required query from the list to display the statement details.

  3. Click AI Optimizer. The Foglight AI Sign in screen appears.


    To use AI Optimizer, you must sign in with your Quest Account. If you do not have a Quest Account yet, sign up to create one.


  4. Click Sign in with your Quest Account.

    If you do not have a license, then the status displayed is disabled. Click Contact Sales to request a license. If your license exists but the feature is not enabled, an error message will be displayed.

The Foglight AI Optimizer screen displays the query details for the selected query.


This screen displays the following details:

  • Performance Bottlenecks Analysis - Identifies issues like inefficient table operations, unnecessary scans, and suboptimal data types.
  • Schema and Index Recommendations - Provides specific solutions including proper indexing strategies and schema optimizations.
  • Query Rewrite Suggestions - Offers concrete SQL code improvements with rewritten examples that eliminate loops, optimize table management, and improve query structure for better performance.
    You can click Compare to view the original SQL text next to the AI-optimized SQL text. The left pane displays the original query while the right pane displays the optimized query.
    This comparison helps you review the changes introduced by the optimizer and verify that the optimized query preserves the original functionality while improving readability, maintainability, and performance.
  • Database and Server-Level Recommendations - Suggests database configuration changes like statistics updates, index maintenance, isolation levels, and compatibility settings.
  • Next Steps - Provides a structured testing and monitoring approach to validate optimizations and measure performance improvements.

When you finish reviewing the AI Optimizer output, you can click Summarize conversation to generate a concise summary of the query analysis and recommendations. If you want to keep the summary for later use, click the Copy icon to copy the response to your clipboard and save it for future reference.

You can collapse or restore the AI Optimizer screen as needed. When you collapse the AI Optimizer screen, the query results are automatically saved for future reference. To view the saved results, click the AI icon. It displays the saved instances of Foglight AI.