Cloning Queries
Cloning creates a copy of an existing query. It is the quickest way to build a new query from one that already works, and it also moves a query to another group.
When to clone
- You want a variation of an existing report (for example, the same query for a different table or filter).
- You are about to make large changes and want to keep the original intact.
- You want to use a well-tested query as a template for a new one.
- You want to copy or move a query to another group.
Cloning a query
In the queries list, click the Clone button of a query you can edit. The Clone query window asks for:
- Description — the name of the copy, filled in with the original's description. It may not be empty.
- Group — the group the copy goes to. The list holds the groups where you are an editor and whose plan has room for another query; the group you have open is selected. The editors of the selected group get full access to the copy.
- Delete original query? — tick it to move the query: the copy is created in the selected group and the original is deleted.
Click Clone to create the copy. When no group can take another query, the Clone button opens the Packages screen instead.
What gets copied
The clone is an independent query that starts from the original's SQL, form fields, result layout and the settings of its settings panels, the Cache expiration included. If the original has an unpublished draft, the clone starts from the draft. It also gets:
- the same database connection,
- the links to the snippets the original uses,
- the original's tags (system tags such as
_slow-queryare not copied); they count as tags you added (see Only tags you added), - the same references to other queries: the Joined query of its add button, its Import query and the queries its form fields use stay the same queries, also in another group.
The internal note of the original is not copied.
Because it is a separate query, it gets its own:
- share hash — the clone is not shared, and has no share password or expiry, until you set them,
- history, which starts empty: its first version is recorded when a change of its SQL or form fields is saved,
- schedules — set these up anew if needed.
This separation means you can change the clone freely without any risk to the original or to anything that depends on it. When you move a query with Delete original query?, the original is deleted together with its history, its log entries and its schedules, and its internal note is not carried over. The copy has its own share hash, so the original's shared link and API endpoint and the dashboard tiles that run it stop working. A moved query keeps who added each of its tags.
A clone in another group
- Database connection — the clone runs on the original's connection, but that connection is not added to the connections of its group. When you open the clone in the editor, Database connection shows Add new connection: to change and save the clone, choose one of the group's connections or add one.
- Snippets — a query runs with the snippets of its own
group, so a
snippet('name')of the clone uses the group's snippet of that name, and fails with "Snippet: 'name' not found!" when the group has none.
Cloning vs. drafts
- Use a draft when you want to change the same query safely.
- Use clone when you want a new, separate query based on an existing one.
After cloning, open the new query in the editor to adjust its SQL, then save.