Thursday, August 22, 2013

FILTER function to improve performance of OBIEE reports

OBIEE allows developers to write expressions at several places like BMM,prompts, column expression builder etc. And most of the time we end up in writing CASE statements to achieve some or the other logic.
As we all know CASE statements actually are so popular in causing query performance issues and also increases the length of the logical and Physical queries.

Not in all cases we can avoid the CASE statements but thriugh this post i would like to show where we can. Let us know discuss on how these CASE statements can be avoided and use FILTER function to achieve the desired logic when filtering a measure for certain dimension filter.

Where to find

In the Column Expression Builder - Functions -- Display Functions -- Filter

How to write

FILTER( MEASURE_EXPRN  USING (EXPRN ))

Lets see how we can make use of this with an example

How to Use

Consider the below logical expression using CASE statement

CASE WHEN 
"Offices"."D1  Office"='Blue Bell Office' 
THEN 
"Base Facts"."1- Revenue" 
ELSE 0 
END

Now lets see how we can use the FILTER function to achieve the same

FILTER ("Base Facts"."1- Revenue"   USING("Offices"."D1  Office"='Blue Bell Office'  ))

Analyze the physical SQL for understanding the Query performance

What ever we do in Presentation, how best we may design the RPD,how good we may have set the performance metric parameters ,the ultimate thing that counts is the Physical SQL that hits the database.

Below will be the physical SQL generated by these both functions for above examples

The SQL generated from the CASE statement looks something like this as CASE is also supported at the Database level OBIEE will not convert functions that are supported by database as this will improve the formation and execution times :

SELECT
SUM(CASE WHEN 
Office= ‘
Blue Bell Office’  THEN Revenue ELSE 0)
FROM PHY_TABLE1, PHY_TABLE2
ON CONDITION


Lets see the SQL generated by FILTER function,here the filter fucntion is not supported by database and hence OBIEE converts it into best possible way

SELECT
SUM(
Revenue)
FROM PHY_TABLE1, PHY_TABLE2

ON CONDITION
WHERE Office= ‘Blue Bell Office’ 
When we observe the above two physical statements one can easily understand that SQL generated by FILTER is more effective when compared to CASE statements since it uses the conditions in WHERE clause.This is why we have to start using the FILTER where ever we can to avoid the CASE statements

Tuesday, August 20, 2013

OBIEE - Purge BI Server Cache

Oracle BI is most powerful and user friendly Business Analytics tool.This is because its simple to use and generates high data reports in quite a less amount of time (less than a sec for some cases).One of the reasons for such performance is because of the Cache feature in the tool.

When a query is run by one user it can be saved as a file to cache; if another user queries for the same information, rather than wait for the information to be fetched from the database it can be queried or retrieved  from the cache for a better performance.

There are some problems when we are using Cache, one among them is existence of stale data.So purging is one among the admin activities that needs to be carried when we use cache feature.

Ways to Purging BI Server Cache

There are three ways of doing it
  1. via the Presentation Services 
  2. using the Administration Tool
  3. with an OS (Operating System) level command

Purging the Cache via the Presentation Service

Select Settings, Administration; the Administration Window will open
Select to Issue SQL; this window will allow you to issue SQL Directly
In the command window enter the text below and click to Issue SQL
          Call SAPurgeAllCache()

Using the Administration Tool

Administration tool is client tool for OBIEE from which we can access the BI server components like RPD,Cache,Security etc. 

Open Admin Tool
Open RPD in Online Mode
Go to Manage --> Cache

You can now see the cache entries in the window. Select the cache entry you want to purge and right click and purge cache.

With an OS (Operating System) level command

We can also use the nqcmd executable to issue the same command, taking advantage of ODBC extensions functions.

Login to the hosting machine and navigate to the Server Bin directory

Linux Command Shell
$ cd /OracleBI/server/Bin$

Use an editor such as vi to create a file containing the command you want to issue. The first window shows the command to open the text editor, the next is the contents of the file.

     Linux Command Shell
    $ vi purge.txt$


    purge.txt
    Call SAPurgeAllCache()

Follow the instructions listed below to issue the purge command(s)

    Linux Command Shell
    $ cd /OracleBI/server/Bin$ nqcmd -d “AnalyticsWeb” –u Administrator –p Password –s purge.txt$

In this example –d is used to identify the datasource, -u username, -p password and –s sql input file
The advantage of the latter approach is that the executable can be scripted to occur at regular intervals.

Some of the default commands provided by Oracle are below

Call SAPurgeAllCache( );
Call SAPurgeCacheByTable( );
Call SAPurgeCacheByQuery( );






Best Practices for Designing Business Model Mapping Layer for Oracle BI

OBIEE BMM Layer Design Principles / Best Practices

There are some design principles(geeks call them best practices) suggested by oracle in designing the OBIEE repository. we can find these in if open any standard/sample repository provided by oracle.

Below are some design principles for BMM Layer.

1. Multi User Development Environment (MUD)


Use the Multi- User Development  facility if there are multiple developers. Multiple developers to connect “online” to the same repository file and making changes is not recommended.

Multi User Development allows user to define a series of projects within the repository file ,where each project is a subset of the entire repository .If developers want to make changes , they can check out a project to a local machine make and test the changes,and then check the modifications back into the master repository file.

2.  Always run Global Consistency Check before releasing a repository.

Whenever we make changes to a repository ,always be sure to run Global consistency check. It is bad practice to release a repository that still contains consistency check errors. In some cases, consistency errors prevent Oracle BI Server from loading the repository. Use the Consistency check manager to identify and debug check messages.

3.Separate Business Model

Even if you have only a single data source or schema in the physical layer, or you have only one physical data source for the repository, it is still good practice to break out the physical objects into multiple business models in the BMM layer to represent the independent areas of functionality.

4. Logical Tables

When building logical tables, do not merge multiple dimension tables into a single logical dimension table,and do not merge multiple fact tables into a single logical fact table.

Having multiple logical fact tables also makes it easier to create well defined projects for Multi User development.It is also a good practice to prefix logical table names with either Dim-, Fact- ,or Fact Compound .

This allows you to easily see how the tables are being used. It also groups the tables in the business model, so that facts are groups with facts, dimensions with dimensions  and so on.

5. Time Dimension

There are few things to keep in mind in time dimension factor.

Always must ensure that time Dimension hierarchy is built correctly and the logical level of each time- logical table source is set correctly
If there are multiple time dimensions within the business model, for consistency, make sure that all time dimension logical table contains the same columns and general structure. This is good for reporting purpose.

6. Logical Fact & Dimension table columns

Always assign a primary key for logical dimension tables. All logical dimension columns should be renamed in a way that is meaningful to users.
Bring only required columns in to the BMM layer for reporting.
Do not assign logical primary key for logical fact tables.
Create meaningful name for measures
Set aggregation rule for every logical fact columns.
Create “dummy” measures to group facts.

7. Logical Joins

Use only logical(complex ) joins in BMM layer. And always accept default properties when creating joins.

8. Calculated Measure

When building calculated measures try to be a bit cautious.

Use logical columns for calculations that require an aggregation rule that is applied before the calculation.
Use physical columns for calculations that require an aggregation rule to be applied after the calculation.

9. Aggregates

Few important things to keep in mind about Aggregates.

Try to ensure that each aggregate table has an effective summary ration with underlying detail.
Ensure that the logical level of every aggregate logical table source is set correctly.
Always test to ensure that aggregates tables are being used as expected.
If an aggregates is not used ,try changing the number of elements on one of the related logical dimension levels.

10. Dimension Hierarchies

In Dimension Hierarchies few things  are very important to keep in mind

It is best practice to create dimensional hierarchy for every logical dimension table in BMM layer.
All Dimension must have at least two levels : the total level and detail level.
If you are creating Dimensional Hierarchy manually, be sure to check Grand total level for the Total Level.
Use Update Row Counts or Estimate Levels to set the number of elements for every level of every Dimension Hierarchy.
Think about the experience of user when enabling drill down.

11. Avoid Snowflake schema

When there is Snowflaking in physical model,We should try to avoid Snowflaking in BMM layer and build models that use only star schema .

Use WHERE clause filters to help avoid using opaque views or complex joins in the physical layer.

Sunday, August 18, 2013

Calendar Date/Time Functions for OBIEE

The calendar date/time functions manipulate data of the data types DATE and DATETIME based on a calendar year. You must select these functions together with another column; they cannot be selected alone.


Current_Date

Returns the current date. The date is determined by the system in which the Oracle BI Server is running.

Syntax    Current_Date

Current_Time

Returns the server current time. The time is determined by the system in which the Oracle BI Server is running.

Note: The Analytic Server does not cache queries that contain this function.

Syntax   Current_Time(integer)

Current_TimeStamp

Returns the current date/timestamp. The timestamp is determined by the system in which the Oracle BI Server is running.

Syntax  Current_TimeStamp(integer)

Day_of_Quarter

Returns a number (between 1 and 92) corresponding to the day of the quarter for the specified date.

Syntax  Day_Of_Quarter(dateExpr)

DayName

Returns the name of the day for a specified date.

Syntax  DayName(dateExpr)

DayOfMonth

Returns the number corresponding to the day of the month for a specified date.

Syntax  DayOfMonth(dateExpr)

DayOfWeek

Returns a number between 1 and 7 corresponding to the day of the week, Sunday through Saturday, for a specified date.

For example, the number 1 corresponds to Sunday and the number 7 corresponds to Saturday.

Syntax  DayOfWeek(dateExpr)

DayOfYear

Returns the number (between 1 and 366) corresponding to the day of the year for a specified date.

Syntax  DayOfYear(dateExpr)


Hour

Returns the number (between 0 and 23) corresponding to the hour for a specified time.
For example, 0 corresponds to 12 A.M. and 23 corresponds to 11 P.M.

Syntax  Hour(timeExpr)

Minute

Returns the number (between 0 and 59) corresponding to the minute for a specified time.

Syntax  Minute(timeExpr)

Month

Returns a number (between 1 and 12) corresponding to the month for a specified date.

Syntax  Month(dateExpr)

Month_Of_Quarter

Returns the number (between 1 and 3) corresponding to the month in the quarter for a specified date.

Syntax  Month_Of_Quarter(dateExpr)

MonthName

Returns the name of the month for a specified date.

Syntax  MonthName(dateExpr)

Friday, August 2, 2013

Export or Import Oracle Database

To Import


  • For full database import open Command Prompt
> imp USERNAME/PASSWORD@SERVICENAME file='path' FULL='Y'

Example: imp scott/tiger@orcl file='D:\sales.dmp' full='Y'


  • For importing a specific schema open command prompt 
> impdp USERNAME/PASSWORD@SERVICENAME schemas=SCHEMA_NAME directory=DIRECTORY_NAME dumpfile=FILE_NAME logfile=LOGFILE.log


Example: impdp cmro/cmro@orcl schemas=CMRO directory=temp_dir dumpfile=cmro.dmp logfile=cmroexpdp.log

To Export


  • For full database export open Command Prompt

> exp USERNAME/PASSWORD@SERVICENAME file='path' FULL='Y'

Example: exp scott/tiger@orcl file='D:\sales.dmp' full='Y'


  • For exporting a specific schema open command prompt 
> expdp USERNAME/PASSWORD@SERVICENAME schemas=SCHEMA_NAME directory=DIRECTORY_NAME dumpfile=FILE_NAME logfile=LOGFILE.log


Example: expdp cmro/cmro@orcl schemas=CMRO directory=temp_dir dumpfile=cmro.dmp logfile=cmroexpdp.log


To know how to create a database directory see this


Supplier Dump File free Download

Oracle Supplier2 Schema .dmp file free download

To Download  Click Here

Note: Don't install any apps.First click will open a new tab close it. On the first page it will ask verification code enter and download

Quota.xls file for practicing activity guide

To Download Click Here





Follow the post to know how to import them to a DB scheme.