Focal Point
SQL ANALYZE vs dbms_stats

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/1381057331/m/103109825

September 16, 2010, 01:29 PM
BobSh
SQL ANALYZE vs dbms_stats
We have Oracle as our RDBMS. In the past we've used SQL ANALYZE to analyze the tables. We had been told by our DBAs that using dbms_stats was more efficient but we weren't able to get it working. IBI helped us to get the correct syntax so I wanted to pass it along for others.
Note that the dbms_stats statement and options need to be on 1 line. I used <> to indicate where you would need to replace with your information. In our test the ANALYZE took 28 minutes and the dbms_stats only 17 minutes.

SQL SQLORA SET SERVER <database>;
END
-RUN

SQL SQLORA
ex sys.dbms_stats.gather_table_stats ownname => '<table owner>', tabname =>'<table name>', estimate_percent => 10, method_opt => 'for all indexed columns',cascade => TRUE, degree =>6;
END

This message has been edited. Last edited by: Kerry,


WebFOCUS 7.7.05M, gen 144, Windows 2008 Server R2 64-bit, Tomcat 6.0.33, IIS 7.0, SQL Server, Excel 2013, PDF, HTML, FOCUS files.
September 19, 2010, 02:19 AM
Dan Satchell
Bob, thanks much for the post and for sharing this performance enhancing information. Do you run dbms_stats after every table load, or only after loads/updates for tables of a certain size?

This message has been edited. Last edited by: Dan Satchell,


WebFOCUS 7.7.05
October 27, 2010, 04:05 PM
BobSh
Hey Dan - good to hear from you. Yes, we do it after each of our tables are updated each night. Not the very small tables but any table of significant size. It usually runs quickly.
Bob


WebFOCUS 7.7.05M, gen 144, Windows 2008 Server R2 64-bit, Tomcat 6.0.33, IIS 7.0, SQL Server, Excel 2013, PDF, HTML, FOCUS files.