For Oracle support & training call (800) 766-1884
Free Oracle Tips

Home
Oracle Tips
Oracle Code Depot
Oracle Monitoring
Oracle Consulting
Oracle Training
Oracle News
Oracle Forum
Oracle Support





 

Free Oracle Tips

image

 
HTML Text

Free Oracle App Server Tips

image

 
HTML Text


Privacy Policy

Redneck

Dress Code

Oracle tuning

Oracle training

Oracle support

Remote Oracle


 

   
  SQL Server Tips by Burleson

The Small Problem with View Merge

A sophisticated DBMS performs these additional steps after or during the view merge:

  • Eliminate redundant conditions caused by the replacements.

  • Invoke the optimizer once for each iteration of the loop.

All three of our DBMSs are sophisticated. But here's an example of a problematic view and query:

CREATE TABLE Table1 (column1 INT PRIMARY KEY, column2 INT)
CREATE TABLE Table2 (column1 INT REFERENCES Table1, column2 INT)
CREATE VIEW View1 AS
SELECT Table1.column1 AS column1, Table2.column2 AS column2
FROM Table1, Table2
WHERE Table2.column1 = Table1.column1
SELECT DISTINCT column1 FROM View1 <-- this is slow
SELECT DISTINCT column1 FROM Table2 <-- this is fast

— Source: SQL Performance Tuning, page 209.

The selection from the view will return precisely the same result as the selection from the table, but Trudy Pelzer and I tested the example on seven different DBMSs (for our book SQL Performance Tuning, see the References), and in every case the selection-from-the-table was faster. This indicates that the optimizer isn't always ready for the inefficient queries that the Query Rewriter can produce.

Ultimately, the small problem is that the "view merge" is a mechanical simpleton that can produce code that humans would immediately see as silly. But the view-merge process itself is so simple that it should be almost instantaneous. (I say "almost" because there are lookups to be done in the system catalog.)


This is a book excerpt from:

Advanced SQL Database Programmer Handbook

Donald K. Burleson, Joe Celko, John Paul Cook, Peter Gulutzan

ISBN: 0-9744355-2-X

http://www.rampant-books.com/ebook_dbazine_SQL_prog.htm
 

  
 

 
 
 
 
Oracle performance tuning software
 
 

 

 
 
 
Oracle performance Tuning 10g reference poster
 
 
 
Oracle training in Linux commands
 
Oracle training Excel
 
Oracle training & performance tuning books
 

 

Fast-Track Oracle Support
PO Box 511
Kittrell, NC 27544


Email BC:

 

Hit Counter