简体   繁体   中英

Crystal Reports Performance Options

We create several crystal reports based on SQL Server - usually 2005 or 2008. Broadly there are 2 kind of reports

a) tabular reports - which shows some data in a table (for example, invoice list) b) document layouts - which shows data in specific format - usually from one or two main tables - and several secondary tables (for example, invoice)

We sometimes use tables directly in crystal. Or create a procedure in SQL and than use that procedure. One invoice could refer to usually around 10-12 tables. Most of these linked using left outer join to the primary invoice table.

What option is better - using tables in crystal (and let crystal create and run the sql query) - or create a query - and than use that query in crystal. Which one will give better performance?

There will be no difference in performance between a query generated by the 'Database Expert' versus the same SQL added to a Command. One caveat: ensure that the record-selection formula can be parsed and sent to the database (a filter applied WhileReadingRecords will definitely be less efficient that a pure-SQL one).

Reasons to prefer the 'Database Expert':

  • prior to v 2008, Command objects didn't support a multivalued parameter
  • easier to manage (somewhat subjective)

Reasons to prefer a Command:

  • you can add hints
  • you have more finely-grained control over the SQL (eg in-line views, CTEs, more-complex JOINs, subselects)

Personally, I try to avoid stored procedures as they offer minimal performance benefits, but require a more-signification investment in development and maintenance.

In the end, there is no substitute for performance. Try you query both ways and measure the results.

Coding it yourself will almost invariably run faster -- after all, you know what your data looks like, and Crystal doesn't. Also, there are things you can do in manual queries (windowing functions, for example) that Crystal can't.

Crystal had tendency to do some crazy stuff behind the scenes. You can view the "Show SQL Query" under the Database menu options to see what it creates. If find it easier to write the query in SQL as I can optimize it myself much easier. I also prefer to do any calculated/formula fields in SQL to and just use Crystal as a display interface. If you do put logic in crystal remember that it is running that logic for every record returned... so if there are conditions that exclude a record from a formula put that first to limit the time spent in the calculation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM