Bytebase provides an index advisor to help you speed up your slow queries. The index advisor will analyze the slow queries and recommend the indexes that can speed up the slow queries.
The Bytebase index advisor based on the slow query logs and OpenAI API. Make sure that:
- You have enabled the slow query logs in your database and Bytebase console.
- You have sign up for an account on the OpenAI platform and obtain a confidential key.
Add the API key
Go to Bytebase console, click Settings > General. Scroll down to AI Augmentation, and fill in OpenAI API Key field.
- Go to home, and click Slow Queries on the left bar.
- Click interested slow query to open the detail page.
- If the index advisor is enabled, you'll see the
- Current Indexes section, which shows the indexes that are currently used by the slow query.
- Suggestions section, which shows the indexes that can speed up the slow query.
- Create Index button, which allows you to create the suggested index.
In order to advise indexes, Bytebase must provide the OpenAI platform with the tables and column names of the current database schema and SQL fingerprints(without any literals, use question marks
? or variable signs
$1 instead). However, Bytebase does not transmit any data from the tables.