Queries
Each cluster has a Queries tab where you can run queries against any database in your cluster. These queries can also be saved, named, organized, and shared publicly.
Query results are available:
- in a table view in the dashboard
- for download as a CSV
- for download as JSON
Permissions
Users with Admin or Manager roles can create and run saved queries by default. You can also create a custom Access Group to give other users fine-grained access to view and/or manage Queries. See the documentation about custom access groups for details.
Creating queries
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.
Saving and naming queries
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 are saved on a team basis for anyone with cluster access.
Query autorun
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.
Sharing queries
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.
Auditing of saved queries
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
Info
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.
Organizing saved queries
You can leave your saved queries uncategorized, or they can be organized into folders that you create.
Admins, Managers, or any user with the Query Manage permission for a given cluster can organize a cluster's queries. See custom access groups for more information.