Professional Documents
Culture Documents
Universe Tuning Training Presentation
Universe Tuning Training Presentation
2
Possible Areas to Consider
Data Modeling
Universe Design
Query Design
3
Topics Covered
• Tips on creating better objects, joins, and queries
4
Tip 1: Process Less Data
For all databases:
• The WHERE clause states certain conditions that must be met before
additional processing occurs
5
Example - Running Totals
ACCT_BALANCES
acct_id
month
year
beginning_balance
ending-balance
• Each row contains one account’s totals for a particular month and year.
• Restrict this table by creating a Business Objects join asking for the time period
up front.
• This dramatically reduces the number of rows processed by the SELECT clause.
6
Example - Large Fact Tables
SALES_TRACKING
division
sales_mgr
salesman
period
total_sales
• Data warehouses usually depend on a few large FACT tables that contain
summarized information based on a multi-part key.
• Restrict access to that fact table by providing values for one or more of these
primary key fields.
7
Tip 2: Scan Tables Once
DB: Oracle, Sybase, Informix
• Applied at the same time, they read the same row once.
8
Oracle Conditional Logic
Oracle provides the DECODE function:
Code: Translation:
DECODE (<expression>.
If the Expression
<test 1>, <result 1>,
equals Test 1. then return Result 1
<test 2>, <result 2>.
If it equals Test 2. return Result 2
…
<default result>)
Else return the Default Result
9
Example - Oracle DECODE
Return only revenues from Texas and Oklahoma customers
10
Sybase Conditional Logic
• Sybase does not provide a DECODE function.
T est R e su lt F o rm u la
C h ar N um sig n ( ch arin d e x (< e xp re ssio n > , < T E S T > )) * R E S U L T
N um N um sig n ( < e xp re ssio n > - T E S T ) * R E S U L T
C h ar C har su b strin g ( R E S U L T , 1 ,
ch arin d e x ( < ex p ressio n > , T E S T ) * len g th o f R E S U L T > )
N um C har su b strin g ( R E S U L T , 1 .
sig n ( < e xp re ssio n - T E S T ) * < le ng th o f R E S U L T > )
11
Example - Sybase Logic
12
Informix Conditional Logic
• Informix does not provide a DECODE function, either
• Informix has the smallest set of SQL functions to choose from
• Conditional logic can be emulated through nested TRIMs
Code:
Translation:
13
Example - Informix Logic
Return only revenues from 1st quarter
order_amount*
LENGTH( TRIM(BOTH ‘2’,
TRIM(BOTH ‘3’,
TRIM( BOTH ‘4’, quarter_o_order))))
14
Tip 3: Avoid Outer Joins
DB: All
• Try adding an additional row within the table that has no matching data
15
Time-Dependant Joins
• Some relationships are time-dependant, and cannot be resolved this
way
Requisitions Orders
Receipts
16
Tip 4: Driving Tables
DB: Oracle 6, Oracle 7 with Rule-Based optimization
Sybase (After the first four tables joined)
• The driving table is usually the last table in the FROM clause
• The DB processes the driving table first, retrieving data from other tables via
joins
17
Example - Driving Tables
• Move to the LIBRARY subdirectory of Business Objects
18
Tip 5: Rules for Indexed Columns
DB: All
19
Rule 1 - No Calculations
Do not use calculations or functions on indexed columns
Salary/12>2000 Salary>2000*12
20
Rule 2 - No Open Patterns
Avoid patterns that begin with ‘%’
21
Rule 3 - No NULL Comparisons
Avoid IS NULL, IS NOT NULL Comparisons
22
Rule 4 - No NOT Comparisons
Avoid beginning a comparison with NOT
23
Tip 6: Use ROWID
DB: Oracle, Informix
• It acts like the ultimate primary key, pointing to the physical location of a row
• ROWID can be used as a field, and thought of as the primary key for uniquely
indexed tables.
24
Example - Using ROWID
• Counting table rows the normal way:
COUNT (Employees.Last_Name)
25
Tip 7: Expand Table Indexes
DB: All
• If the index columns all requested information, the DB can skip reading the table
26
Example - Expanding Indexes
LOOKUPS
code
type
description
• If the Type is normally retrieved with the code, add the Type field to the Lookups
index
27
Tip 8: Mark Indexed Columns
DB: All
• For combination keys, only mark the leading (first) indexed column this way
28
Example - Making Indexed Columns
EMPLOYEES EMPLOYEES_INDEX1
employee_id employee_id
last_name
first_name EMPLOYEES_INDEX2
city last_name
first_name
S Q L F rag m en t P o s s ib le O b je c t N a m e
la s t_ n a m e * E m p lo y e e L a s t N a m e
firs t_ n a m e E m p lo y e e F irs t N a m e
la s t_ n a m e ‘ ,’ firs t_ n a m e E m p lo y e e F u ll N a m e
29
Tip 9: Postpone Processing
DB: All
• These same tasks could be removed from the query, and saved for Business
Objects
30
Example - Sort Data Locally
• Sorts can be removed from any query, and applied locally using the
ReportWriter
• One Drawback - Should not remove a sort from a query when Partial Results
option set
31
Example - Postpone Calculations
• Calculations and concatenations within the SELECT clause slows down the
query
• The most recent version of Business Objects contains over 80 report functions
• Remove calculations from the query, saving them for Business Objects
32
End of presentation