Best practices for customizing reports
You should customize reports taking into account performance and saving time.
This guide explains what should be taken into account when customizing reports.
User and Event Parameters
- Whenever you want to customize or create from scratch a report, you have to make sure that when you are querying data from a Data Provider you limit the amount of data to be processed. In order to do that you have to use typed parameters which should be a User and an Event when creating an event-based report.
- We need these parameters for two reasons, first because using them enables batch processing. Batch processing is an automatic process that “prepares” the information from a saved report every night, so when you want to generate it the data is ready. If you don´t use typed parameters the batch processing will not process anything and when you want to generate the reports it will take more time to be ready. The second reason is that using typed parameters enables the indexed search on the data provider which will make faster the execution of the query.
- There is a feature on the query editor to include these parameters. When you use it remember to select as parameter type “From Query” since this is the only type that the framework will understand. Then, for the user parameter, you need to select a value from the Users, Tags, or TagUsers system queries and for the event parameter use the EventRules system query.
- If you need to limit the result for the parameters then you should create another query where you can request these values. Let´s think that you want to select as User typed parameter only the list of devices on your application. Assuming that you have a tag called “Devices” on your application then you could create this additional query:
SELECT DISTINCT Users.UserID, Users. Name FROM Users JOIN TagUsers ON TagUsers.UserID = Users.UserID JOIN Tags ON TagUsers.TagID = Tags.TagID WHERE Tags. Name = 'Devices' |
Afterwards, you will need to add the parameter on the query editor the same way it has been explained before, but this time selecting your own query instead of a system query.
Including these parameters in your query will make it much faster! And GpsGate Server's latest version will not let you save your query if you don´t specify these typed parameters. So make sure you use them and that you fix this on previous reports that you had created.
Data Management
- Creating new Data Providers. If you have to create a new Data Provider take into account that the more Data Providers you use, the bigger your database will grow and most of these data will be duplicated if you are just modifying the default ones a bit. Then if you really need to do it, you will create a copy of an existing one. Try to disable the original from all the rest of the reports that use it. The main purpose of keeping the number of Data Providers to a minimum is avoiding redundant data and this will help you to keep your database size controlled.
- Cleaning tool. GpsGate Server includes a cleaning tool in order to get rid of old information. If you navigate to SiteAdmin/Applications/Cleanup and you select one of your applications then you have the option to select for how long you want to keep your report data. This doesn´t mean that the data will be gone forever, but if you run that report again the data will be reprocessed. So try finding a balance between performance and availability and thinking if it is still useful to keep old data already processed.
Query Management
These are 2 things that you don´t need to do on your query.
- Sorting the result of your query is pointless. The layout editor allows you to sort the result by right-clicking the beginning of the row. Select the “Edit Group” option and you will be able to group by and sort your results.
- Don't select more than you need. Pretty simple but effective, the less data you request the less time the query takes. If there´s some data that you don´t need don´t select it. Always try to review your query when you finish writing it. You'll want to remove anything that you ended up not using.
Sometimes the basic stuff is what makes the difference and helps you gain some time when generating a report.