Each cluster has a section called "Queries". This feature will let you run queries against any database in your cluster, save and name query results, and share your saved queries.
Query results are available:
- in a table view in the dashboard
- for download as a CSV
- for download as JSON
To create a new query click on the "New Query" button, select the database you want to query against, and enter your SQL in the field below.
If you have a read replica, queries will be created by default to run against the replica. You can choose which replica it should run on, or choose the primary if you prefer.
By default, a new query will have a random name like "Untitled Query 8f19". You can change the name of your query in the box on the top left, and rename it again at any time. Executing the query with a new name will save the name, the SQL, and the results set.
Queries that ran in less than 1 second will re-run for you when you open the query. Queries that took longer than 1 second to run will have a button to update and refresh the query.
You can create a sharing URL for any query by clicking the "Share" button and toggling the slider. This creates a new sharing URL that provides access to the query and results. Note that shared queries are not limited to Crunchy Bridge account holders or specific team members. Anyone with the sharing URL for a shared query can see the raw SQL and the results.
Viewers can see query results in a table, or download JSON or a CSV.
The sharing link for a query can be destroyed at any time with the sharing toggle. This operation can't be undone. Re-enabling sharing for a query will create a new sharing URL.
Operations on queries are captured in the Audit log, including:
- creating a new saved query
- updating a saved query, including the type of update
- creating a sharing URL
- destroying a sharing URL
Queries is a feature in progress and is still under active development. If you have product feedback, we'd love to hear it! Send it our way in a support ticket.
The queries feature has an option to use Open AI as your personal AI-powered SQL Assistant. Enter a question you'd like answered based on your data:
Click "Generate SQL" and a query will be automatically generated for you:
Click on "Execute SQL" to run the query that has been generated. You can edit and save it just like any other saved query.
Note: in order to use the AI-powered SQL generation feature, you must check the box that you agree to share Postgres metadata with OpenAI, including table names, column names, and schema design.