While direct access to the APM production database is not available, you can query the database using the SQL Workbench. Keep in mind that only SELECT statements can be used; SQL cannot be used to manipulate data in the database; for example, using INSERT, UPDATE, or DELETE. SQL statements and their results are not stored. If the SQL Statement needs to be run more than once or if the results need to be captured in an extract or report, QBQuery should be used instead of SQL Workbench.
The SQL Workbench can be opened from the Administrator portal under Tools → SQL Workbench. Query results display in a grid that can be exported to a .CSV or Excel file.

Using SQL Workbench
To create a basic query, enter the SQL query in the Input Parameters window and select Execute.
Setting a Favorite
If you have created a query that you would like to re-use in the future, you can set it as a favorite. The Favorites tab at the top of the query window contains a list of favorite queries.
History
The History tab opens the Workbench History Search screen, which displays all of the queries that have been executed in the SQL Workbench. You can also open this screen under Administrator → Tools → Workbench History.
Row and Export Record Limits
By default, the SQL Workbench returns up to 500 rows of data, and allows an export of up to 10,000 rows.
To remove the limit on query results, uncheck the Limit Results? box. This will return an unlimited number of data rows. You can also set a different limit by changing the number in the Display field.
You can also use the Export field to change the number of rows that can be exported; however, you can also use the system Options to reduce the number of records that can be exported, up to a maximum of 50,000. This limit overrides the limit set in the SQL Workbench.
To set an export record limit:
- From the Administrator portal, select Configuration → Options.
- Search for the option: ui.sqlworkbench.export.max.rows.nonlimitedaccess
- Change the number in the Option Value field.
Variables in SQL Workbench
Using variables in SQL queries allows you to create more robust queries that can be useful for troubleshooting, setting bonuses, and other data analysis.
The image below shows an example of a query in SQL Workbench that uses a variable to set the value for the Broker Type.

Loading a QB Query in SQL Workbench
Although you can save a query as a favorite, as we saw above, the SQL Workbench does not store saved queries. As an alternative, you can create QB Queries, which store SQL queries for retrieval. We will explore QB Queries later in this course.
You can easily load the contents of a QB Query record into the SQL Workbench. To reference a QB Query:
- Select the Input Parameters tab.
- Select Get QB Query SQL
- Search for the QB Query
- Select the arrow next to the query. This will load the query into the SQL Workbench.
- Select Execute.
Monitoring Database Activity
The Database Activity screen displays all SQL statements that are currently running in the system. You can view statements that are running, are idle, or are taking longer than expected to run. Once the SQL statement is done running, it is no longer displayed.
To view database activity, from the Administrator portal, select System Activity → Database Activity.
Canceling a Process
If a process has been taking longer than expected, you can cancel the process using the following steps:
- Select the notifications icon in the upper right of the window.
- This will open the RunList Detail for the process.
- Select Cancel.
Execution Plans
When a SQL query is executed, the server reads the query and determines the most efficient way to retrieve the data based on the available indexes. An Execution Plan contains the details on the retrieval of data.
In some cases, the Execution Plan may not be correct, which can result in SQL processes running slowly or hanging up. If this happens, you can create an Execution Plan Request, which triggers a process that retrieves the execution plan from the server. This allows you to troubleshoot slow processes by identifying issues and fine tuning the query without the need for outside help.
To run an Execution Plan Request from the SQL Workbench:
- Select Execution Plan in the lower right.
- Select Submit.
Note
It takes a few minutes to run the execution plan.To download the execution plan:
- From the Administrator portal, select Tools → Execution Plan.
- Select the new execution plan to open the details.
- Scroll to the bottom and select Download File.
The resulting file can be viewed in a SQL editor such as SQL Studio.