Crystal Report Tips

Wednesday, April 19, 2006

Optimisation of SQL Query

One of the biggest issues facing a Crystal Reports developed is the performance of the report. Many times I've heard users complain that a report takes too long to generate. A good approach to take to optimise performance is to analyse the SQL Query. In Crystal Reports you can view the SQL Query by going to the Database menu and selecting 'Show SQL Query'. You can extract this query and run it through a query analyser.

For Oracle databases you can use Toad to 'explain the plan'. This can tell you what indexes are being used or if the query does a full table scan to get the required data. Always try to make use of the indexes. Sometimes it may be worthwhile creating new indexes on the tables. In some cases you can add additional conditions to the selection formula record which will cause the database optimiser to select a different set of indexes.

At times there may be nothing more you can do so you should speak to your database administrator to see if they can improve the performance on the database side. There was a case where a report took a long time to run because it was not selecting best index. This was because the sample size was too small. The database adminstrator has set a sample size of 2000 records and this was used to specify which index to use for a table of 6 million records.

1 Comments:

At 9:13 PM, Blogger toyumail said...

I am a beginner in CR. May I ask your opinion which is the best way to design a report? DSN, DNS-less, or ADO.Net (xsd)?

I'm a bit confused on all these connection-at-design-time thing because in Visual FoxPro (which I'm more familiar), we just create the fields neccessary when design the report (no connection needed). Then at runtime, prepare the required table alias and just call the report. As long as the fields exist in the table alias, it will work.

Thanks for any advice.

 

Post a Comment

<< Home