Certain tables in the ResourceXpress database are updated with new records on a regular basis. Some of these tables store vital application information, such as Bookings records, while others record device and 3rd party booking system activity which can be useful when troubleshooting a problem.
Having too many records in the database can lead to application performance issues, it can also lead to a large quota of storage being consumed by the database. Scheduled maintenance on the ResourceXpress database is therefore strongly recommended to ensure performance is not affected and storage limits are not reached.
Plan and Decide
Some planning and decision-making will be required before configuring and executing the database maintenance tasks described below. Consideration should be made to how you consume and report data in ResourceXpress and how troubleshooting could be affected when records are deleted.
Database maintenance requires a two-step approach. First, you configure the actions to take for each maintainable table and second you configure and schedule the job to carry out the maintenance.
Table 1.0 lists the database tables that can be maintained with descriptions of the records held in those tables.
Table 1.0 - Target Tables
Table Name | Description | Potential Growth |
---|---|---|
dbo.ConnectivityLog | Records Room Screen connectivity events. | Each Room Screen profile creates 1 record every 60 seconds. To calculate the amount of records generated in a 24 hour period you can multiply the number of room screen devices in your environment by 1440 60 Room Screens would be 60 * 1440 = 86,400 records in a 24 hour period.* |
dbo.BookingSystemConnectivityLog | Any Room Screen profile integrated to a 3rd party booking system will have a corresponding Booking System record when an event is written to the ConnectivityLog | Each Room Screen profile with an active 3rd party booking system integration creates 1 record every 60 seconds. The same formula detailed in the ConnectivityLog table can be used to estimate the number of generated records |
dbo.QubiActivityLog | Connections to the application from a Qubi 2, Qubi 3 or TD-0350 desk device are stored here. | Each of the listed desk devices will create 1 record every 60 seconds. The same formula detailed in the ConnectivityLog table can be used to estimate the number of generated records |
dbo.Bookings | Local bookings and 3rd party booking system records. | Each booking either created locally in the application or synchronized from a 3rd party booking system will create 1 record per configured profile. |
dbo.ResourceMessages | Admin configured resource messages that are broadcast to Room Screens and Kiosks | Resource Messages records still persist in the database even after the configured expiry date has passed. If the message is deleted from the admin console it is also removed from the database. |
dbo.EquipmentProblems | Any “Call for Help” reports for faulty equipment or other resources made from Room Screens or Kiosks. | Equipment Problem records persist in the database even when the problem has been closed in the admin console. |
dbo.AuditLog | Logs the audit information for the admin console | This depends on the changes done in the admin console. |
dbo.GraphSubscription | Logs Graph subscriptions for every profile. This is used for sending un-subscription request in case if there is a new subscription available for a resource. | This depends on the number of Exchange/Office 365 profiles. |
dbo.SchedulerInfo | Store the success profiles, failure profiles, total profiles run by scheduler and their updated time. | This depends on the schedule interval. If it is set to 5, then the table has 144 records per day. |
dbo.UserLoginHistory | Log the user logged-in time, IP address, Device Type, Login Type and OS Version. | This depends on the number of users logged in to Kiosk, Maps, Admin Console, Mobile, Outlook Add-In. |
*Records are not generated when the profile is in Energy Saving Mode
Available Maintenance Actions
There are four available actions for each of the above tables
Delete
The delete action will remove all records from the live target table. Records will not be archived and cannot be retrieved.
Deleting will improve performance and reduces the size of the database.
Archive
The archive option will move the records from the live table to an archive table. Records in an archive table cannot be viewed from the application UI but can be queried directly from the database.
When archiving, you specify the number of days worth of records to retain in the archive table.
Archiving will improve performance as the records do not interfere with application lookups however they still take up the same amount of storage space.
Take No Action
No records will be deleted or archived from the live table.
No performance or storage benefits apply to this option.
Configuring Maintenance Actions
Configuring the available maintenance actions is carried out in the ResourceXpress database and involves executing SQL queries to set your desired configuration.
Table 1.1 describes the available actions and their respective SQL values.
Table 1.2 shows the relevant SQL column names and the value configured by default.
Table 1.1 - SQL Values
Action Description | SQL Value |
---|---|
Delete | 0 |
Archive | Any positive number i.e. 1, 2, 3 etc. The number configured will be the number of days records will be archived |
Take No Action | NULL |
Table 1.2 - Column Names and Default Values
Column Name | Default Value |
---|---|
ConnectivityLogDaysToKeep We recommend that at least 1 day of Connectivity Log Records are kept | 0 DELETE ALL RECORDS |
BookingSystemConnectivityLogDaysToKeep We recommend that at least 1 day of Booking System Connectivity Log Records are kept | 0 DELETE ALL RECORDS |
QubiActivityLogDaysToKeep | 1 ARCHIVE FOR 1 DAY |
BookingDaysToKeep | NULL TAKE NO ACTION |
ResourceMessagesDaysToKeep | NULL TAKE NO ACTION |
EquipmentProblemsDaysToKeep | NULL TAKE NO ACTION |
ConnectivityLogArchiveDaysToKeep | 0 TAKE NO ACTION |
BookingSystemConnectivityLogArchiveDaysToKeep | 0 TAKE NO ACTION |
QubiActivityLogArchiveDaysToKeep | 1 ARCHIVE FOR 1 DAY |
BookingArchiveDaysToKeep | NULL TAKE NO ACTION |
ResourceMessagesArchiveDaysToKeep | NULL TAKE NO ACTION |
EquipmentProblemsArchiveDaysToKeep | NULL TAKE NO ACTION |
GraphSubscriptionDaysToKeep V2023.1 | 3 = Archive for 3 days |
SchedulerInfoDaysToKeep V2023.1 | 1 = Archive for 1 day |
AuditLogDaysToKeep V2023.1 | NULL = Take no action |
AuditLogArchiveDaysToKeep V2023.1 | NULL = Take no action |
UserLoginHistoryDaysToKeep V2023.1 | NULL = Take no action |
UserLoginHistoryArchiveDaysToKeep V2023.1 | NULL = Take no action |
Please ensure you take a full database backup before executing any SQL queries
To view the currently applied configuration execute the query
select * from dbo.ArchiveSetting
To change the maintenance action on any column you can run the below update query against the ResourceXpress database.
update dbo.ArchiveSetting set <column_name> = <value> where TenantId = 1
Example Queries
Archive Device Connectivity Log Records for 5 days
update dbo.ArchiveSetting set ConnectivityLogDaysToKeep = 5 where TenantId = 1
Keep all Qubi Activity Log records (not recommended)
update dbo.ArchiveSetting set QubiActivityLogDaysToKeep = NULL where TenantId = 1
Delete all Bookings records
update dbo.ArchiveSetting set BookingDaysToKeep = 0 where TenantId = 1
The maintenance actions configured in these columns will be carried out when the maintenance job executes. For example, if you configure the Booking option to 0 (delete) and the maintenance job runs at 2:00 am, all booking records will be deleted at that time.
Once you have configured your desired values you can move on to configuring the maintenance job itself.
Configuring the Maintenance Job
Option 1 - SQL Agent Job - MSSQL Server Only
If your ResourceXpress database is hosted on a dedicated SQL Server instance we recommend to carry out database maintenance as a SQL Agent Job.
To configure maintenance for a SQL Express hosted database please refer to Option 2 - Windows Task Scheduler & PowerShell - SQL Express Edition further down the page.
The SQL Server Agent service must be running to execute the job
Connect to the SQL Server using SQL Server Management Studio
Expand SQL Server Agent, right-click the Jobs folder, and select New Job…
On the General page populate the Name, Category, and Description fields then click OK
Select the Steps page and click New…
On the General page add a Step name, select the Type as Transact-SQL script (T-SQL) and ensure the correct Database is selected.
Add the below content into the Command window
exec [dbo].ArchiveConnectivityLog 1 GO exec [dbo].ArchiveBookingSystemConnectivityLog 1 GO exec [dbo].ArchiveQubiActivityLog 1 GO exec [dbo].ArchiveBookings 1 GO exec [dbo].ArchiveResourceMessages 1 GO exec [dbo].ArchiveEquipmentProblems 1 GO exec [dbo].ArchiveGraphSubscription 1 GO exec [dbo].ArchiveSchedulerInfo 1 GO exec [dbo].ArchiveAuditLog 1 GO exec [dbo].ArchiveUserLoginHistory 1 GO exec [dbo].DeleteBookingsArchive 1 GO exec [dbo].DeleteAuditLogArchive 1 GO exec [dbo].DeleteUserLoginHistoryArchive 1 GO exec [dbo].DeleteGraphSubscription 1 GO exec [dbo].DeleteSchedulerInfo 1 GO
On the Advanced page drop down the option On success action and select Go to the next step then click OK to save the step
On the Steps page click New… again to create a second step
On the General page add a Step name, select the Type as Transact-SQL script (T-SQL) and ensure the correct Database is selected.
Add the below content into the Command window
exec [dbo].DeleteConnectivityLogArchive 1 GO exec [dbo].DeleteBookingSystemConnectivityLogArchive 1 GO exec [dbo].DeleteQubiActivityLogArchive 1 GO exec [dbo].DeleteBookingsArchive 1 GO exec [dbo].DeleteResourceMessagesArchive 1 GO exec [dbo].DeleteEquipmentProblemsArchive 1 GO exec [dbo].DeleteArchiveLog 1 GO
On the Advanced page drop down the option On success action and select Quit the job reporting success then click OK to save the step
The two steps will now be listed
Select the Schedules page and click New…
Add a Name and configure the schedule options to your requirements. We recommend running the maintenance job daily at 2:00 am to avoid working hours. Once configured click OK.
Multiple daily schedules can be added at different times based on the number of records to be archived per day.
Select the Notifications page and check the option Write to the Windows Application event log, from the dropdown options select When the job fails.
Click OK to save the maintenance job.
ResourceXpress Database Maintenance for MSSQL Server has now been configured.
Expand the Jobs folder to view the newly created job. If the system has been running for some time you can run the job immediately instead of waiting for the first scheduled run by right-clicking and selecting Start Job at Step…
We do not recommend running the job during working hours
Option 2 - Windows Task Scheduler & PowerShell - SQL Express Edition
SQL Server Agent jobs are not supported on a SQL Express Edition instance, if you’re running SQL Express please use the below steps to configure Database Maintenance.
We do not recommend using SQL Express Edition when running 10 profiles or more
First, create the application directory shown below on the ResourceXpress Server
C:\Program Files (x86)\QED\RxDBMaintenance
Create a new text document and name it RxDBMaintenance.ps1
Copy the below content into the new file and replace the following values in the $connectionString line
<SQL-SERVER\INSTANCE> = Your SQL Server instance name e.g. SQLSRV01\SQLEXPRESS
<database_name> = your ResourceXpress database name e.g. rxpress
# Initial values, replace the {name} with proper values $connectionString = "Data Source=<SQL-SERVER\INSTANCE-NAME>;Initial Catalog=<database_name>;Integrated Security=False; User ID=dbsupport1;Password=D8Supp0rt!;Connect Timeout=60;Encrypt=False;TrustServerCertificate=False" $timeout = 300 # in seconds $tenantId = 1 Write-Output('DB Maintenance - v0.1 started') # Instantiate the connection to the SQL Database $sqlConnection = new-object System.Data.SqlClient.SqlConnection $sqlConnection.ConnectionString = $connectionString # Define the SQL command to run $sqlCommand = new-object System.Data.SqlClient.SqlCommand $sqlCommand.CommandTimeout = $timeout $sqlCommand.Connection = $sqlConnection $sqlCommand.Parameters.AddWithValue("@TenantId",$tenantId) # Opening the SQL connection try{ $sqlConnection.Open() } catch{ Write-Output('An error occurred in opening connection'+ $_.Exception.ToString()) Exit 1 } # Executing the stored procedures $spList = 'ArchiveConnectivityLog','ArchiveBookingSystemConnectivityLog','ArchiveQubiActivityLog','ArchiveBookings','ArchiveResourceMessages','ArchiveEquipmentProblems','DeleteConnectivityLogArchive','DeleteBookingSystemConnectivityLogArchive','DeleteQubiActivityLogArchive','DeleteBookingsArchive','DeleteResourceMessagesArchive','DeleteEquipmentProblemsArchive','DeleteArchiveLog',‘ArchiveGraphSubscription’,’ArchiveSchedulerInfo’,‘ArchiveAuditLog’,’ArchiveUserLoginHistory’,’DeleteGraphSubscription’,‘DeleteSchedulerinfo’,‘DeleteAuditLogArchive’,‘DeleteUserLoginHistoryArchive’ foreach($sp in $spList){ try{ Write-Output('About to execute the sp ' + $sp) $sqlCommand.CommandText= 'exec [dbo].[' + $sp + '] @TenantId' $result = $sqlCommand.ExecuteNonQuery() Write-Output($sp + ' executed successfully') } catch{ Write-Output('An error occurred in executing the sp ' + $sp + ' ' + $_.Exception.ToString()) } } # Close the SQL connection $sqlConnection.Close() Write-Output('DB Maintenance is completed successfully')
Save and close the file.
Open Windows Task Scheduler
In the Actions pane select Create Task…, configure the General Settings as below
Move on to the Triggers tab and configure the desired schedule. We recommend running the maintenance job daily at 2:00 am to avoid working hours. Click OK.
Multiple daily schedules can be added at different times based on the number of records to be archived per day.
Click New… in the Actions tab and configure the required options.
The Program/script path should point to PowerShell.exe
In the Add arguments field add -File “C:\Program Files (x86)\QED\RxDBMaintenance\RxDBMaintenance.ps1
Click OK.
Configure the Settings tab then click OK to save the task.
ResourceXpress Database Maintenance for SQL Express Edition has now been configured.
The new job will be listed in the Task Scheduler Library. If the system has been running for some time you can run the job immediately instead of waiting for the first scheduled run by right-clicking and selecting Run
We do not recommend running the job during working hours
Logs
The number of records deleted and or archived are recorded in the database in the ArchiveLog table, to view the logs execute the below SQL query against the ResourceXpress database.
select * from dbo.ArchiveLog