Queries
Each cluster has a Queries tab where you can run read-only queries against any database in your cluster. 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 previously ran in less than one second will re-run for you when you open the query. Queries that previously took longer than one 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 a sharing URL to a Query cannot be limited to Crunchy Bridge account holders or to specific team members. Anyone with the sharing URL for a Query will be able to see the raw SQL and the results.
Viewers can see Query results in a table, or download JSON or a CSV.
The sharing URL for a query can be destroyed at any time with the sharing toggle. Disabling sharing will delete the URL and can't be undone. Re-enabling sharing for a Query will create a new sharing URL.
Auditing of saved Queries
Operations on saved Queries are captured in the Audit log, including:
- creating a new Query
- updating a 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. Please 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 saved Queries. See custom access groups for more information.