Merging instances, another performance boost

Saturday 23 May 2015 @ 10:19 am

Last month I wrote about report that took 20 minutes to run, and how using the right indexes brought the run time to under a minute. Yesterday I was able to get another 20-minute report to run in under a minute by fixing a different issue.

At first I wasn’t sure if the run time could be significantly reduced. The report had to pull tables from two different databases, and that is usually a performance killer. So I checked the SQL being generated by the report to see how the two queries were being divided. Instead of two separate queries there were four. One of the two connections was showing up as 3 separate queries in the SQL – as if it were three different connections. So we went into the menu at “Database >> Set DataSource Location” and found that the report was using three different instances of same connection. Once we set all three instances to the same instance, the report ran in under a minute.

So why would tables that all come from one database connection end up under different instances of that connection? Usually I see this happen when the report is designed in stages. A few tables are added, then the user logs out and then more tables are added at a later time. Each new login can be treated as a separate instance of the database. And when that happens Crystal will make a separate query for each instance and combine the data in local memory.  This is very inefficient when compared to a single query that is handled entirely by the database.

Having two different instances of the same DB causes the same performance problem as connecting two different databases. But while it is very difficult to improve performance with two different databases, merging multiple instances on one database is usually pretty simple.

2 Responses to 'Merging instances, another performance boost'

  1. rschwarz - June 18th, 2015 at 4:50 pm

    Thanks for this post. It saved me a lot of time today after making changes to an older report that caused problems. Is there a way to merge multiple instances of one database other than deleting and re-adding tables.

  2. Ken Hamady - June 18th, 2015 at 5:04 pm

    Yes, you can use the “Set Database Location” to set all of the various instances to the same instance.

Leave a Reply

Recrystallize Pro