You are on page 1of 28

Report Optimization for Crystal Reports

Charlotte Craig, Crystal Advantage

Presentation Information (Hidden Slide)


Author: Charlotte Craig Company: Crystal Advantage Track session title
Report Optimization for Crystal Reports

Track session description


An effective report not only returns the desired data, but also performs optimally within the environment. Hear how techniques such as SQL expressions and proper function selection can optimize performance, and how SQL commands can impact reporting. See how to look at the SQL query generated by Crystal Reports and determine if the use of certain functions or techniques is causing inefficiencies. Learn the proper use of variables and sub reports and their role in report optimization. Explore the optimum option settings, the steps that must be taken to allow for grouping on the server, and the importance of database indexes.

Slide 2

Copyright 2004 Business Objects S.A. All rights reserved.

Topics
Learning to analyze the SQL query The use of functions within selection criteria Using SQL expressions to improve performance Avoiding formulas in record selection The importance of database indexes SQL commands and report performance Effectively using subreports and variables Development Q&A
Ease of

Clear Easy to Understand Report

Performance

Slide 3

Copyright 2004 Business Objects S.A. All rights reserved.

Learning to Analyze the SQL Query


Crystal creates a SQL query that can be viewed as follows

1/4

Slide 4

Copyright 2004 Business Objects S.A. All rights reserved.

Learning to Look at the SQL Query


SQL query results

2/4

Correlates to Record Selection Criteria

Slide 5

Copyright 2004 Business Objects S.A. All rights reserved.

Learning to Look at the SQL Query


Displaying record selection criteria

3/4

Slide 6

Copyright 2004 Business Objects S.A. All rights reserved.

Learning to Look at the SQL Query


Comparing record selection criteria

4/4

Slide 7

Copyright 2004 Business Objects S.A. All rights reserved.

Topics
Learning to analyze the SQL query The use of functions within selection criteria Using SQL expressions to improve performance Avoiding formulas in record selection The importance of database indexes SQL commands and report performance Effectively using subreports and variables Development Q&A
Ease of

Clear Easy to Understand Report

Performance

Slide 8

Copyright 2004 Business Objects S.A. All rights reserved.

The Use of Functions within Selection Criteria 1/6


Some functions pass to the Where clause while others dont Functions that dont pass
Sample query result of a function that doesnt pass Examples of functions that dont pass

Functions that do pass


Sample query result of a function that does pass Examples of functions that pass

Options when a function doesnt pass


Use Other Crystal Functions Use a SQL Expression Use a SQL Command

Slide 9

Copyright 2004 Business Objects S.A. All rights reserved.

The Use of Functions within Selection Criteria


Functions that dont pass Sample query result of a function that doesnt pass

2/6

The database returns all customersnot just those starting with C Crystal Reports further filters the data so the results appear the same

**Left() does not pass to the where clause.

Slide 10

Copyright 2004 Business Objects S.A. All rights reserved.

The Use of Functions within Selection Criteria


Functions that dont pass Examples of functions that dont pass
Mid Length Trim Uppercase Right DateDiff DateAdd Month Year Cstr Cdate,

3/6

Slide 11

Copyright 2004 Business Objects S.A. All rights reserved.

The Use of Functions within Selection Criteria


Some functions pass to the Where clause while others dont Functions that dont pass
Sample query result of a function that doesnt pass Examples of functions that dont pass

4/6

Functions that do pass


Sample query result of a function that does pass Examples of functions that pass

Options when a function doesnt pass


Use Other Crystal Functions Use a SQL Expression Use a SQL Command

Slide 12

Copyright 2004 Business Objects S.A. All rights reserved.

The Use of Functions within Selection Criteria


Functions that do pass Sample query result of a function that does pass
The database returns only customers starting with C

5/6

Slide 13

Copyright 2004 Business Objects S.A. All rights reserved.

The Use of Functions within Selection Criteria


Functions that do pass Examples of functions that pass
Subscript [] LastFullMonth MonthToDate LastYearYTD YearToDate CurrentDate Date IsNull

6/6

Slide 14

Copyright 2004 Business Objects S.A. All rights reserved.

Topics
Learning to analyze the SQL query The use of functions within selection criteria Using SQL expressions to improve performance Avoiding formulas in record selection The importance of database indexes SQL commands and report performance Effectively using subreports and variables Development Q&A
Ease of

Clear Easy to Understand Report

Performance

Slide 15

Copyright 2004 Business Objects S.A. All rights reserved.

Using SQL Expressions to Improve Performance


SQL expressions are functions exposed by the database driver that will pass in the Where clause

SQL expressions are not limited to the list displayed from within Crystal

Slide 16

Copyright 2004 Business Objects S.A. All rights reserved.

Using SQL Expressions to Improve Performance


Create a SQL expression from the field explorer

The SQL expression Editor

Slide 17

Copyright 2004 Business Objects S.A. All rights reserved.

Topics
Learning to analyze the SQL query The use of functions within selection criteria Using SQL expressions to improve performance Avoiding formulas in record selection The importance of database indexes SQL commands and report performance Effectively using subreports and variables Development Q&A
Ease of

Clear Easy to Understand Report

Performance

Slide 18

Copyright 2004 Business Objects S.A. All rights reserved.

Avoiding Formulas in Record Selection


Formulas wont always pass to SQL
If / then / else formulas Custom function formulas

Instead of formulas, write the syntax in the record selection Avoid if / then / else statements in record selection in favor of or
If {?Param} = Active then {Emp.Status} = A else. {?Param} = Terminated and {Emp.Status} = T or

Slide 19

Copyright 2004 Business Objects S.A. All rights reserved.

Topics
Learning to analyze the SQL query The use of functions within selection criteria Using SQL expressions to improve performance Avoiding formulas in record selection The importance of database indexes SQL commands and report performance Effectively using subreports and variables Development Q&A
Ease of

Clear Easy to Understand Report

Performance

Slide 20

Copyright 2004 Business Objects S.A. All rights reserved.

The Importance of Database Indexes


The equivalent of a file cabinet with no file folders
Database scans each record Processing time increases

Use the visual linking expert to verify fields are indexed


Many production databases are indexed for transactional performance rather than reporting performance A reporting database is optimal

Work with your DBA to get indexes where needed


Their primary concern is database performance Reporting without proper indexes will affect transactional users as well as the report

Slide 21

Copyright 2004 Business Objects S.A. All rights reserved.

Topics
Learning to analyze the SQL query The use of functions within selection criteria Using SQL expressions to improve performance Avoiding formulas in record selection The importance of database indexes SQL commands and report performance Effectively using subreports and variables Development Q&A
Ease of

Clear Easy to Understand Report

Performance

Slide 22

Copyright 2004 Business Objects S.A. All rights reserved.

SQL Commands and Report Performance


Ability to completely control SQL query
Good for hierarchical reporting Good for outer join integrity

What to avoid
Linking to other tablesno index Linking to other commandsno index

Slide 23

Copyright 2004 Business Objects S.A. All rights reserved.

Topics
Learning to analyze the SQL query The use of functions within selection criteria Using SQL expressions to improve performance Avoiding formulas in record selection The importance of database indexes SQL commands and report performance Effectively using subreports and variables Development Q&A
Ease of

Clear Easy to Understand Report

Performance

Slide 24

Copyright 2004 Business Objects S.A. All rights reserved.

Effectively Using Subreports and Variables


Not all subreports are bad, some improve performance! Subreports are often overused

1/2

Disparate record selectiontop 5 customers and top 5 salespeople Unequal number of records2 comp lines 4 deduction lines

Report placement and performance


Report header or footer is best Avoid details if possible

Where indexing is a problem, performance could improve


Example
Table one has one million rows Table two has one hundred forty rows and has no index Report performance increased from over 14 hours to less than 2 hours

Slide 25

Copyright 2004 Business Objects S.A. All rights reserved.

Effectively Using Subreports and Variables


The most overused feature of Crystal Variables consume memory
Local Global Shared

2/2

Consider these alternatives


Use formulas and sums Use running totals

Slide 26

Copyright 2004 Business Objects S.A. All rights reserved.

Topics
Learning to analyze the SQL query The use of functions within selection criteria Using SQL expressions to improve performance Avoiding formulas in record selection The importance of database indexes SQL commands and report performance Effectively using subreports and variables Development Q&A
Ease of

Clear Easy to Understand Report

Performance

Slide 27

Copyright 2004 Business Objects S.A. All rights reserved.

Q&A
Questions??

Slide 28

Copyright 2004 Business Objects S.A. All rights reserved.

You might also like