-
Notifications
You must be signed in to change notification settings - Fork 21
Slow queries retrieval #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…low quewry anlaysis. This groups similarly worded queries in the completed_requests catalog and returns a min, max and average runtime for them
…base cluster, including their bucket settings.
…ueries from the completed_requests catalog. Summary statistics are grouped by like-queries with different filtered values. Specific information can be requested per query.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @Eyal-CB, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request significantly enhances the server's diagnostic capabilities by introducing advanced tools for analyzing N1QL query performance, particularly focusing on identifying and understanding slow queries. It also improves the flexibility of database interactions by shifting from a single, globally configured bucket to a per-operation bucket specification for most data access and query tools.
Highlights
- Enhanced Query Analysis: Introduced new capabilities to analyze slow queries from the
completed_requests
catalog, including aggregate summaries by query pattern and retrieval of specific query execution plans. - Index Advisor Integration: Added a tool (
advise_index_for_sql_plus_plus_query
) to provide index recommendations for SQL++ queries, leveraging the N1QLADVISE
statement. - Flexible Bucket Handling: Refactored the server to remove the global
CB_BUCKET_NAME
configuration, allowing most tools to specify the target bucket per operation, improving multi-bucket support. - New Bucket Listing Tool: A new tool (
get_list_of_buckets_with_settings
) was added to programmatically retrieve a list of all buckets and their settings from the Couchbase cluster.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request adds new features for retrieving slow query information and index advice. The review focuses on critical security vulnerabilities (N1QL injection) that need to be addressed by using parameterized queries.
LIMIT {limit} | ||
""" | ||
|
||
query = query_template.format(limit=query_limit,query_statement=query_statement) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code is vulnerable to N1QL injection. The query_statement
is formatted directly into the query string. You should use parameterized queries to prevent this critical security vulnerability. The query template on lines 463-469 should be updated to use named parameters (e.g., $query_statement
and $limit
), and the call to system_catalog_query
should pass these parameters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added int type verification to param query_limit
LIMIT {limit} | ||
""" | ||
|
||
query = query_template.format(limit=query_limit,query_statement=query_statement) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to the other new query functions, this one is vulnerable to N1QL injection. The query_statement
is formatted directly into the query. This is a critical security risk. Please use a named parameter for query_statement
and pass it to the system_catalog_query
function. The query template on lines 487-515 will need to be updated to use named parameters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added int type verification to param query_limit
|
||
|
||
# Util Functions | ||
def system_catalog_query(ctx: Context, query: str) -> list[dict[str, Any]]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding the capability to query the completed_requests catalog for slow queries.
Two methods added: