Report Optimization for Crystal Reports

28
Report Optimization for Crystal Reports Report Optimization for Crystal Reports Charlotte Craig, Crystal Advantage

Transcript of Report Optimization for Crystal Reports

Page 1: Report Optimization for Crystal Reports

Report Optimizationfor Crystal Reports

Report Optimizationfor Crystal Reports

Charlotte Craig, Crystal Advantage

Page 2: Report Optimization for Crystal Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 2

Presentation Information (Hidden Slide)

Author: Charlotte CraigCompany: Crystal AdvantageTrack session title

Report Optimization for Crystal ReportsTrack 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.

Page 3: Report Optimization for Crystal Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 3

Topics

Learning to analyze the SQL queryThe use of functions within selection criteriaUsing SQL expressions to improve performanceAvoiding formulas in record selectionThe importance of database indexesSQL commands and report performanceEffectively using subreports and variablesQ&A Clear Easy to

Understand Report

Performance

Ease of Development

Page 4: Report Optimization for Crystal Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 4

Learning to Analyze the SQL Query 1/4 Crystal creates a SQL query that can be viewed as follows

Page 5: Report Optimization for Crystal Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 5

Learning to Look at the SQL Query 2/4SQL query results

Correlates to Record Selection Criteria

Page 6: Report Optimization for Crystal Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 6

Learning to Look at the SQL Query 3/4Displaying record selection criteria

Page 7: Report Optimization for Crystal Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 7

Learning to Look at the SQL Query 4/4Comparing record selection criteria

Page 8: Report Optimization for Crystal Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 8

Topics

Learning to analyze the SQL queryThe use of functions within selection criteriaUsing SQL expressions to improve performanceAvoiding formulas in record selectionThe importance of database indexesSQL commands and report performanceEffectively using subreports and variablesQ&A Clear Easy to

Understand Report

Performance

Ease of Development

Page 9: Report Optimization for Crystal Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 9

The Use of Functions within Selection Criteria 1/6

Functions that don’t passSample query result of a function that doesn’t passExamples of functions that don’t pass

Functions that do passSample query result of a function that does passExamples of functions that pass

Options when a function doesn’t passUse Other Crystal FunctionsUse a SQL ExpressionUse a SQL Command

Some functions pass to the Where clause while others don’t

Page 10: Report Optimization for Crystal Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 10

The Use of Functions within Selection Criteria 2/6

Sample query result of a function that doesn’t passThe database returns all customers—not just those starting with C Crystal Reports further filters the data so the results appear the same

Functions that don’t pass

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

Page 11: Report Optimization for Crystal Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 11

The Use of Functions within Selection Criteria 3/6

Examples of functions that don’t passMidLengthTrimUppercaseRight…DateDiffDateAddMonthYear…CstrCdate,

Functions that don’t pass

Page 12: Report Optimization for Crystal Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 12

The Use of Functions within Selection Criteria 4/6

Functions that don’t passSample query result of a function that doesn’t passExamples of functions that don’t pass

Functions that do passSample query result of a function that does passExamples of functions that pass

Options when a function doesn’t passUse Other Crystal FunctionsUse a SQL ExpressionUse a SQL Command

Some functions pass to the Where clause while others don’t

Page 13: Report Optimization for Crystal Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 13

The Use of Functions within Selection Criteria 5/6

Sample query result of a function that does passThe database returns only customers starting with C

Functions that do pass

Page 14: Report Optimization for Crystal Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 14

The Use of Functions within Selection Criteria 6/6

Examples of functions that passSubscript []LastFullMonthMonthToDateLastYearYTDYearToDateCurrentDateDateIsNull

Functions that do pass

Page 15: Report Optimization for Crystal Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 15

Topics

Learning to analyze the SQL queryThe use of functions within selection criteriaUsing SQL expressions to improve performanceAvoiding formulas in record selectionThe importance of database indexesSQL commands and report performanceEffectively using subreports and variablesQ&A Clear Easy to

Understand Report

Performance

Ease of Development

Page 16: Report Optimization for Crystal Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 16

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

Page 17: Report Optimization for Crystal Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 17

Using SQL Expressions to Improve Performance

Create a SQL expression from the field explorer

The SQL expression Editor

Page 18: Report Optimization for Crystal Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 18

Topics

Learning to analyze the SQL queryThe use of functions within selection criteriaUsing SQL expressions to improve performanceAvoiding formulas in record selectionThe importance of database indexesSQL commands and report performanceEffectively using subreports and variablesQ&A Clear Easy to

Understand Report

Performance

Ease of Development

Page 19: Report Optimization for Crystal Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 19

Avoiding Formulas in Record Selection

Formulas won’t always pass to SQLIf / then / else formulasCustom function formulas

Instead of formulas, write the syntax in the record selectionAvoid 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

Page 20: Report Optimization for Crystal Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 20

Topics

Learning to analyze the SQL queryThe use of functions within selection criteriaUsing SQL expressions to improve performanceAvoiding formulas in record selectionThe importance of database indexesSQL commands and report performanceEffectively using subreports and variablesQ&A Clear Easy to

Understand Report

Performance

Ease of Development

Page 21: Report Optimization for Crystal Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 21

The Importance of Database Indexes

The equivalent of a file cabinet with no file foldersDatabase scans each recordProcessing time increases

Use the visual linking expert to verify fields are indexedMany production databases are indexed for transactional performance rather than reporting performanceA reporting database is optimal

Work with your DBA to get indexes where neededTheir primary concern is database performanceReporting without proper indexes will affect transactional users as well as the report

Page 22: Report Optimization for Crystal Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 22

Topics

Learning to analyze the SQL queryThe use of functions within selection criteriaUsing SQL expressions to improve performanceAvoiding formulas in record selectionThe importance of database indexesSQL commands and report performanceEffectively using subreports and variablesQ&A Clear Easy to

Understand Report

Performance

Ease of Development

Page 23: Report Optimization for Crystal Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 23

SQL Commands and Report Performance

Ability to completely control SQL queryGood for hierarchical reportingGood for outer join integrity

What to avoidLinking to other tables—no indexLinking to other commands—no index

Page 24: Report Optimization for Crystal Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 24

Topics

Learning to analyze the SQL queryThe use of functions within selection criteriaUsing SQL expressions to improve performanceAvoiding formulas in record selectionThe importance of database indexesSQL commands and report performanceEffectively using subreports and variablesQ&A Clear Easy to

Understand Report

Performance

Ease of Development

Page 25: Report Optimization for Crystal Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 25

Effectively Using Subreports and Variables 1/2

Subreports are often overusedDisparate record selection—top 5 customers and top 5 salespeopleUnequal number of records—2 comp lines 4 deduction lines

Report placement and performanceReport header or footer is bestAvoid 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

Not all subreports are bad, some improve performance!

Page 26: Report Optimization for Crystal Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 26

Effectively Using Subreports and Variables 2/2

Variables consume memoryLocalGlobalShared

Consider these alternativesUse formulas and sumsUse running totals

The most overused feature of Crystal

Page 27: Report Optimization for Crystal Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 27

Topics

Learning to analyze the SQL queryThe use of functions within selection criteriaUsing SQL expressions to improve performanceAvoiding formulas in record selectionThe importance of database indexesSQL commands and report performanceEffectively using subreports and variablesQ&A Clear Easy to

Understand Report

Performance

Ease of Development

Page 28: Report Optimization for Crystal Reports

Copyright © 2004 Business Objects S.A. All rights reserved.Slide 28

Q&A

Questions??