OBIEE – Scripted Testing

It is possible to run a pre-defined report against the BI Server via command line and read the output.  The obvious benefit of this is that it allows us to create a suite of tests that could be ran at the touch of a button.

Input XML File

A single report is defined in OBIEE as XML; that XML is available in the Advanced tab when defining a request in Answers. 

A report has two files associated to it in the Catalog; one of the files will contain this XML and the other file, an ATR file, is a binary file containing the permissioning for the object.  For this blog we are interested only in the XML File; and that is all we need. We could also use the BI SQL tranlsation found in the same screen, however, I have found this less reliable.

Executing a Report

Once a report exists as an XML file then we can run it against the BI Server using the NQCMD command and the parameters below.  The executable is stored in the directory OracleBI/server/Bin.

  • d datasource – set this as AnalyticsWeb
  • u username – such as Administrator
  • p password – such as SADMIN
  • s source file – this would be your XML file
  • o output file – the results will be recorded in this file
  • utf16 – defines the coding standard to use – I would use UTF16

An example of the command as I have used it is below:

nqcmd –d AnalyticsWeb –u Administrator –p SADMIN –utf16 –s test1.xml –o test1.txt

The Output Text File

The results can be displayed to screen and written to a text file.  They will display the BI SQL for the report, which will be followed by the report results (note: there is little formatting and column headings will be referred to as saw1, saw2 etc).

In Summary

In previous projects I have scripted the running of a set of test reports stored in a test directory.  Output files have then been interrogated automatically seeking a pass or fail.  The complexity and flexibility of these scripted tests is really upto you.  It can significantly reduce the time taken for testing cycles.

Posted in Scripting, Testing, obiee | Leave a comment

OBIEE – Report Selection Prompt

I was asked yesterday how to create View Selector type functionality that will allow the user to select between reports, rather than just views of the same report. I have a feeling this information must already be available, but I said that I’d provide instructions on how to achieve this and may as well add it to my blog. 

I will go through the steps with screenshots. We want to create 2 reports, Option 1 and Option 2; we need to create a third report that will return either true or false (results or no results). Both reports, Option 1 and Option 2 will be placed on the Dashboard, both in their own Sections; and both sections with Guided Navigation making use of the conditional request. We create a Dashboard prompt giving the options of Option 1 and Option 2; and add a filter to the conditional report so that it filters by the value selected in the prompt. Essentially if Option 1 is selected in the prompt then Report 1 will be displayed; and if Option 2 is selected then Report 2 will be displayed. Reading through this sounds very complex, but it isn’t really – if you haven’t understood then follow the steps below. 

Create the Dashboard Prompt 

The Dashboard Prompt will display a list of the Reports available; we can enter anything that we like for each option.  To achieve this we must use SQL to generate the Show Values.  OBI forces us to select an existing column to populate the prompt, but we get around this by using the expresssion CASE WHEN 1=2; the expression will never result to true and will always show the result of the else statement, our option.  We create a SQL statement for each option we would like in the Prompt and union the statements together (in the order that we would like them to appear). 

Note: The Column used should match the values you would like to generate 

Prompt Show SQL

Prompt Show SQL

For the SQL above, obviously change the references to “column”, “table” and “Business Model”.  Once happy with your SQL I would usually select the Preview Button to check my code. 

Test Prompt Show SQL

Test Prompt Show SQL

For this functionality you would usually not want an ‘All Choices’ option; uncheck its inclusion.  We should also choose to default to a Specific Value to restrict the list to only valid options.  Click on the elipses button and type your preferred default value from the last - no need for quotes, just the text itself.  I would usually verify that the default value is working by viewing the preview again. 

Updated Prompt

Updated Prompt

The only remaining task is to populate a Presentation Variable using the Set Presentation Variable Drop Down.  I have created a variable pVar_ViewOption.  You will also probably want to relabel the prompt to something more meaningful and then you can save it. 

Set Presentation Variable

Set Presentation Variable

Create a Conditional Report 

We need to create a conditional report; the report will filter by the presentation variable created.  We will design the report to return values when one Prompt option is selected and return no values otherwise.  Essentially the report will return true or false, based upon the option selected in the prompt. 

We need only a single column in the report; which should be the column referred to by the prompt.  Similar to the expression used in the prompt, we use a CASE statement to always return the relevant option; in this case the preffered option.

Conditional Column Expression

Conditional Column Expression

We now add the filter to the conditional report to filter this column by the Presentation Variable.   If the option displayed by the column is selected then the report returns results; otherwise it returns no results.

Conditional Filter

Conditional Filter

The Conditional Report is complete.  We also need to create the reports to be displayed with each option.  For this example I’ve created one for each of the 2 options.  So thats 3 reports in total and a prompt.  The screenshot below shows these object in My Folder.

My Folder

My Folder

Configure the condition on a Dashboard

Create a section for the prompt and another for each report. 

Dashboard Layout

Dashboard Layout

We need to use Guided Navigation on each of the Report Sections; we will only show each section based upon the results returned by the Conditional Request we have created.  The Guided Navigation setup for Report Option 1 is given below; notice that it returns a report on the condition the conditional report returns results (ie the prompt selection is our preferred option).

Report Option 1 Guided Navigation

Report Option 1 Guided Navigation

Report 1 - Conditional Navigation

Report 1 - Conditional Navigation

We need to set Guided Navigation for the second report to show when our conditional report returns no results, as below.

Report 2 - Conditional Navigation

Report 2 - Conditional Navigation

And thats the process complete.  When we save our Dashboard and view the page our prompt is shown and defaults to the preferred option; the guided navigation kicks in to display the first report and not the second.

Test One

Test One

And then when we select the other option in our prompt the guided navigation kicks in to display only Report Option 2 section, and not our other Report Section.

Report Two Test

Report Two Test

It is worth noting that behind the scenes all three reports will be ran by the BI Server. I wouldn’t be concerned unless the approach causes too much load on the server.  However, this approach should not be used to improve performance; it doesn’t work like that unfortunately.

Posted in Presentation Services, obiee | Leave a comment

OBIEE – Performance

I don’t think that I’ve been involved in a project yet that did not meet performance hurdles.  We have always overcome them, but do tend to be found towards the end of the project when things are already stressfull enough.  I have decided to blog about the subject and hopefully help some people.

Performance is a large issue to cover; I guess that I will create quite a few blogs that will hopefully stitch together nicely.  This is really just an introduction to the text.

What can we tune

When you come across obiee Performance issues then there are 4 main areas that you may look at to try and improve performance.

  • SQL Tuning
  • Database Tuning
  • System Tuning
  • Network Tuning

Of these areas it is most likely that you will spend your time in the first area, SQL tuning, and that is area that I will cover.  The BI Server is really an engine that uses the definitions given in the RPD to translate user Requests into SQL, submit them to the relevant datasource(s) and return the result.  The definitions determine the SQL ultimately created; we use the definitions in the RPD file to ultimately determine the SQL generated.

Where do we Start

Because tuning is such a big subject when we get hit with a problem it can be quite overwhelming to resolve it; when the issue is down to SQL Performance then we can follow a 3 step process.  Actually, the process is similar regardless, but we will only be looking at SQL Performance.

1 - Isolate the Problem to a Single SQL Statement

To make the problem manageable then we need to reduce the issue to its most basic form; for example remove tables and columns in the query to only those causing the issue.  It may be that there is an issue with the join to one dimension from the fact and another issue to another dimension; treat them differently, they may well be different issues.  They may be the same issue, but breaking the issue down will make it more manageable and help to understand the overall problem.

To isolate the problem, the first thing that we do must be to derive the SQL submitted by the BI Server. We have a blog on the obiee query log, which will help if you don’t know how to do this. If you still have difficulties finding a query then it could be down to caching; we have a blog on purging obiee server cache, which would help with this issue.

2 – Analyze the SQL to determine the cause of the problem

Once you actually locate and analyze the problem you will usually find that the problem itself is quite easy to fix; the difficult, or at least time consuming bit, is in the analysis.

To analyse the SQL we need to extract it from the query log and then use a tool such as Oracle SQL Developer, or Toad, to submit it to the plan table and then read the explain plan from the plan table – see my blog on the obiee explain plan.

3 – Fix the Problem

As suggested earlier, it is very rare that there is not a solution to a performance problem, although the fix may vary in its complexity.

Every problem is unique, but hopefully some of the problems that I mention may suggest some solutions to help you.

Posted in Uncategorized | Leave a comment

OBIEE – Explain Plan

To analyse the SQL generated by the BI Server you will most likely use the Explain Plan; this blog hopes to increase your understanding and ultimately help resolve performance issues.

What is an Explain Plan

An execution plan, sometimes called a row source tree, is logically a tree of row source operators, where each operator is just a function written in C.  The functions are mutually exclusive; they have no knowledge of one another.  Some operators are hidden, such as the STATISTICS operator, and are not visible in the Explain Plan.  Some operators also have options, affecting their behaviour; such as the INDEX operation which has options such as UNIQUE, RANGE SCAN, SKIP and SCAN, etc.

We can run and display an Explain Plan to help us understand which functions are being chosen by the Oracle Optimizer.  Through experience you will learn that some functions do certain jobs better than others; we can manipulate the SQL or DB settings to ensure the Optimizer chooses the better function. 

Importantly, the Explain Plan contains the following information regarding your query.

  • Ordering of the tables referenced
  • Access method for each table
  • Join method for each join operation
  • Data operations, such as filter, sort or aggregation

And in addition:

  • Optimization (Cost and Cardinality)
  • Partitioning
  • Parallel Execution

It is worth bearing in mind when looking at obiee queries that the BI server harbours its own Execution Plan, which may be the same or different to that of the database.  We have a blog on obiee cursor sharing; to help overcome this issue.

Running an Explain Plan

A table exists, the Plan Table; it is set up automatically, that stores the Explain Plans for all users.  To submit a query to the table we must precede the query with the command EXPLAIN PLAN FOR, as in the example below.  More information is available in abundance online for those interested.

Submitting a query to the Plan Table

Submitting a query to the Plan Table

Displaying the Explain Plan

 Once we have asked for an Explain Plan to be made available through through the Plan Table.  We need to display to query to read it.  The command below is one way to display the contents of the Plan Table.  The command below will get you by, but there are more options available; again information available all over the Interent.
 
 
 
 
 

Displaying Plan Table

Displaying Plan Table

Understanding the Plan Table Output
 
 More to follow …
 
 
 
 
 

 

Posted in Uncategorized | Leave a comment

OBIEE – Query Log

The obiee query log, NQQuery.log, exists in the directory …/OracleBI/server/Log.  As the name suggests it records the queries requested from the BI Server.  The initials NQ remind us of obiee’s history, being originally created by a company named NQuire; these clues are littered throughout the application. 

The Logging Level 

The contents of the log file are, or at least the level of detail is determined by a Repository Variable, LOGLEVEL.  The variable can accept values from 0 to 5, 5 being the most verbose.  As a general rule I set the variable to 0 in production, effectively disabling loggin and improving performance; 2 in development, setting to 3 on occassion when 2 is not enough to resolve the issue. 

Setting as a System-Wide Session Variable: 

We can set the logging level globally for all users.  We can set this in the RPD using theAdministration Tool and this logging level will take precendence of other logging settings. 

  • Select to manage Variables from the Manage Menu
  • In Variable Manager Select New, Session, Variable from the Action menu
  • Give the Variable the name of LOGLEVEL, a value of 2 and click OK
  • Close Variable Manager

Setting with the User Object for a particular user: 

We can also set the LOGLEVEL by user, however, this value will be overridden by the Session Variable if it has been created.    To set the Logging Level for a specific user, follow these steps. 

  • Select to manage Security from the Manage Menu
  • In Security Manager Select the Users Object Type from the left pane
  • The right pane lists the user objects, open the properties for an a user object
  • Give the Logging Level a vlue 0 to 5 and click OK
  • Close Security Manager

Setting for a specific Request: 

You can set the LOGLEVEL variable for a specific request.  In this example you will update the session variable LOGLEVEL before the request is run and, as such, this will take precedence over the Session Variable set in the RPD. 

  • Select to Modify a request or create  a new one
  • Navigate to the Advanced Tab
  • In the Prefix Text Box type SET VARIABLE LOGLEVEL=2;
  • Now when you navigate to the results tab an entry will be made to the log file
  • Save the changed request if you would like always to be the case

In the above example there is no space either side of the equals sign; the statement must end in a semi colon and, again, there is no space either side of it. 

Viewing the Log File 

There are a couple of ways to view the query log.  All query logging is recorded in the Query Log File, NQQuery.log; we can view this file using a text editor if we have access to the OS.  OBIEE uses a log viewer utility nQLogViewer to structure this log file into a more useful format called the Session Monitor; we can use the Session Monitor online if we have administrative access.  And finally we can use the nQLogViewer utility ourselves to view specific information, but again we require OS access. 

Using the Session Monitor: 

  • Select Administration from the Settings Menu
  • From the Administration Window select to Manage Sessions
  • The Session Monitor will open

The Session Monitor is split into two tables, Sessions and Cursor Cache. Sessions lists the users currently logged on, or with a thread still running; and the Cursor Cache table displays the queries shown in the log file, NQQuery.log. 

Session Monitor Sessions 

The session records show sessions by user ID and other details such as the client machine name, IP address, browser details, timestamp of login and timestamp of last request. 

And the Query records show each request by ID; each record detailing the user ID, the status of the query, how long it has taken to run, when it was run, the query itself, its location in the catalog (if appropriate) and the number of records returned.  In the Action column you can select to view the log in more detail. 

Session Monitor Query Record

Session Monitor Query Record

 Using the Viewer Utlity: 

We can use the utility nQLogViewer to view log records;  as stated above, each entry in the query log is tagged with the user ID of the user who issued the query, the session ID of the session in which the query was initiated, and the request ID of the query; and we can use these details to restrict the utility to a spcific query. 

 To use the nQLogViewer utility we must open a command window in either Linux or Windows.  Navigate to …/OracleBI/server/Bin.  Use the command with the syntax below.

nqlogviewer [-u<user_ID>] [-f<log_input_filename>]
          [-o<output_result_filename>]
          [-s<session_ID>] [-r<request_ID>]

I would like to note that the request ID is generated in a circular manner; when IDs run out then new requests will re-use existing IDs.  This may explain why different queries can sometimes display in a single log record.

Interpreting Log Records

Whether looking at the Query log directly, or using the Viewer Utility or via the Session Monitor the Log Record is the same; they all come from same log file.  A log record can be broken down into sections; these sections are described brielfy below. 

The log will start with the user ID for the requesting user (followed by the user Account code in hex) and the timestamp for running the request.

SQL Request:

This section provides the Application SQL produced in the Presentation Layer; it does not define relationships, just the columns used.  It can be used to rerun the exact query in the Answer part of the application; although it is less reliable than using the request xml (not available in the log).  It will also show additional attributes such as Pre and Post SQL and the path or location of a saved request.

General Query Information:

This section describes the repository, business model and catalog from which the report has been run; usually useful in putting together query statistics.  I will providing a later log that goes into more detail on this.

Logical Request:

Displays the columns used in the report from the Logical Layer; this section will be displayed when the Log Level is set to 2 or above.

Execution Plan:

When we set the Log Level to 2 or above then we also get to see the Execution Plan.

Database Query:

Identify this section from the initial text Sending query to the database named <data_source_name>; the data_source_name is the name of the data source to which the Oracle BI Server is connecting. If the server is connecting to Multiple database each query will have an entry in the log.

This is the section of the log that you are most likely to be interested in and is the most useful.  It provides the actual SQL generated and executed against the database.  It can be used to verify that the application is behaving as required; especially useful when troubleshooting; and also to support performance tuning. 

I would like to point out that the SQL that you read at times may not refelct the SQL that is actually executed on the database.  You may notice sometimes that the SQL in the log executes very well, but the OBIEE query seems to perform poorly.  This is due to this unexpected difference.  I have blogged about this particular risk to OBIEE Performance.

Query Status:

Essentially the status section will tell you whether the query has succeeded or failed.  You will usually know this before looking at the log, but I guess its worth having it in there.

Log Retention

In terms of configuring the query log we can use the parameter USER_LOG_FILE_SIZE to set the limit of the Query Log.  When the size of the log file grows to half of that value it will be renamed to NQQuery.log.old and fresh queries will be logged to the recreated file NQQuery.log.  Other than the size of the file system there are no further limitations to the size of the log file.  An example of the NQSConfig.INI file is given in the screenshot below.

Query Log Sizing in the NQSConfig.INI

Query Log Sizing in the NQSConfig.INI

Happy Logging and Happy Christmas!

Posted in Logs, Presentation Services, obiee | Leave a comment