Legal | Privacy

Using the SQLAccess Advisor to Recommend Materialized Views and Indexes

This module describes how you can use the SQL Access Advisor to get materialized views and index recommendations to optimize performance.

This module will discuss the following topics:

Overview
Prerequisites
Preparing the Environment
Using the SQL Cache to Get Recommendations
Reviewing and Implementing the Recommendations

Place the cursor on this icon to display all screenshots. You can also place the cursor on each icon to see only the screenshot associated with it.

Back to List

The SQLAccess Advisor provides a number of procedures which can be called to help decide which materialized views and indexes to create and drop. It makes this decision using either a hypothetical workload, which it bases on your schema, or from an actual workload which can be provided by the user, from Oracle Trace or from the contents of the SQL cache.

Workloads may also be filtered according to different criteria, such as only use queries containing these tables or queries which have a priority between this range.

Before starting this module, you should have:

1.

Completed the Configuring Linux for the Installation of Oracle Database 10g lesson

2.

Completed the Installing the Oracle Database 10g on Linux lesson

3.

Download and unzip saa.zip into your working directory (i.e. /home/oracle/wkdir)

Back to List

To prepare the environment for using the SQLAccess Advisor, you perform the steps below. Materialized views and indexes can be present when the advisor is run, but for the purposes of this example they are removed so that you can see what the advisor will recommend. You need to also setup the cache so that the SQLAccess Advisor can generate some recommendations. Perform the following:

1.

Open a terminal window and execute the following commands to clean up your environment:

sqlplus system/<password>
@prepare_for_advisor

The prepare_for_advisor.sql script contains the following:

DROP MATERIALIZED VIEW all_cust_sales_mv;
DROP MATERIALIZED VIEW costs_mv;
DROP MATERIALIZED VIEW costs_pm_mv;
DROP MATERIALIZED VIEW cust_sales_mv;
DROP MATERIALIZED VIEW some_cust_sales_mv;
DROP MATERIALIZED VIEW cust_id_sales_aggr;
DROP MATERIALIZED VIEW sales_cube_mv;
DROP MATERIALIZED VIEW sales_gby_mv;
DROP MATERIALIZED VIEW CUST_TOTAL_SALES_MV;
DROP MATERIALIZED VIEW CUST_SALES_TIME_MV;

Move your mouse over this icon to see the image

 

5.

Now you need to create the cache. Execute the following commands:

@advisor_cache_setup

The advisor_cache_setup.sql script contains the following:

alter system flush shared_pool;
grant advisor to sh;
connect sh/sh;
SELECT c.cust_last_name, sum(s.amount_sold) AS dollars,
sum(s.quantity_sold) as quantity
FROM sales s , customers c, products p
WHERE c.cust_id = s.cust_id
AND s.prod_id = p.prod_id
AND c.cust_state_province IN ('Dublin','Galway')
GROUP BY c.cust_last_name;
SELECT c.cust_id, SUM(amount_sold) AS dollar_sales
FROM sales s, customers c WHERE s.cust_id= c.cust_id GROUP BY c.cust_id;
select sum(unit_cost) from costs group by prod_id;

Move your mouse over this icon to see the image

 

Back to List

You will use the SQL Cache you just setup to get some recommendations from the SQL Access Advisor. Perform the following:

1.

Open your browser and enter the following URL:

http://<hostname>:5500/em

Enter sys/<password> as SYSDBA and click Login.

Move your mouse over this icon to see the image

 

2.

Scroll to the bottom of the Home page and click on Advisor Central under Related Links.

Move your mouse over this icon to see the image

 

3.

Click on the SQL Access Advisor link.

Move your mouse over this icon to see the image

 

4.

Make sure Current and Recent SQL Activity is checked and click on Show Advanced Options.

Move your mouse over this icon to see the image

 

5.

Scroll down. Under Filter Options, select Filter workload based on these options and check the filter Only SQL statements executed by the following users. Then enter SH in the Users field and click Next.

Move your mouse over this icon to see the image

 

6.

Click Both Materialized Views and Indexes and click Next.

Move your mouse over this icon to see the image

 

7.

Enter the task name OBE<Today's Date>, select Standard for the Schedule Type and click Next.

Move your mouse over this icon to see the image

 

8.

At the summary window, click Submit.

Move your mouse over this icon to see the image

 

Back to List

Now you can look at the results and implement them if you wish. Perform the following:

1.

Make sure your job is selected and click View Result.

Move your mouse over this icon to see the image

 

2.

Click on the Recommendation ID 1 to see the details of the Recommendations.

Move your mouse over this icon to see the image

 

3.

Here you can customize the Object Name, Schema and Tablespace to implement the recommendations. Scroll down and change the Schema Name for the Create Materialized View to SH and click OK.

Move your mouse over this icon to see the image

 

4.

To see the SQL Script that will be executed when you schedule the implementation, click Show SQL.

Move your mouse over this icon to see the image

 

5.

Scroll down to the bottom and you will see the statements to create the materialized view with the change you just made. Click OK.

Move your mouse over this icon to see the image

 

6.

To implement the recommendations, click Schedule Implementation.

Move your mouse over this icon to see the image

 

7.

Enter OBEIMPL<today's date> for the Job Name and click Submit.

Move your mouse over this icon to see the image

 

8.

Your implementation job was created and is now running. Click the Run History tab.

Move your mouse over this icon to see the image

 

9.

Make sure your job is selected and click View.

Move your mouse over this icon to see the image

 

10.

Review the summary and click your database breadcrumb.

Move your mouse over this icon to see the image

 

11.

Click Materialized Views from the Administration tab.

Move your mouse over this icon to see the image

 

12.

Enter SH in the schema field and click Go.

Move your mouse over this icon to see the image

 

13.

Notice that the newly created Materialized View appears in the list.

Move your mouse over this icon to see the image

 

Place the cursor on this icon to hide all screenshots.

 

E-mail this page
Printer View Printer View
Oracle Is The Information Company About Oracle | Oracle RSS Feeds | Careers | Contact Us | Site Maps | Legal Notices | Terms of Use | Privacy