Subscribe to Posts by Email

Subscriber Count

    701

Disclaimer

All information is offered in good faith and in the hope that it may be of use for educational purpose and for Database community purpose, but is not guaranteed to be correct, up to date or suitable for any particular purpose. db.geeksinsight.com accepts no liability in respect of this information or its use. This site is independent of and does not represent Oracle Corporation in any way. Oracle does not officially sponsor, approve, or endorse this site or its content and if notify any such I am happy to remove. Product and company names mentioned in this website may be the trademarks of their respective owners and published here for informational purpose only. This is my personal blog. The views expressed on these pages are mine and learnt from other blogs and bloggers and to enhance and support the DBA community and this web blog does not represent the thoughts, intentions, plans or strategies of my current employer nor the Oracle and its affiliates or any other companies. And this website does not offer or take profit for providing these content and this is purely non-profit and for educational purpose only. If you see any issues with Content and copy write issues, I am happy to remove if you notify me. Contact Geek DBA Team, via geeksinsights@gmail.com

Pages

12c Database : Statistics Enhancements : CTAS and Insert as select now comes up with statistics

From 12c Onwards, Oracle statistics gathering has been improvised and after bulk load operations the statistics will be gather automatically. Earlier, Create as select , or Insert as select operations required manual statistics gathering, where in this has been removed now. The following bulk operations is supportive for automatic statistics gather on fly.

	CREATE TABLE AS SELECT
	
	INSERT INTO ... SELECT into an empty table using a direct path insert
	
	INSERT INTO ... SELECT into a non-empty table, partition, or subpartition

However there are Restrictions for those object that:-

	The objects must not belong to SYS.
	It is in an Oracle-owned schema such as SYS.
	It is a nested table.
	It is an index-organized table (IOT).
	It is an external table.
	It is a global temporary table defined as ON COMMIT DELETE ROWS.
	It has virtual columns.
	It has a PUBLISH preference set to FALSE.
	It is partitioned, INCREMENTAL is set to true, and extended syntax is not used.

Let's do a quick test.

	SQL> conn test/test@pdb12c
	Connected.
	SQL> create table t4 as select * from dba_objects;

	Table created.



	SQL> select table_name,num_rows,last_analyzed from dba_tables where table_name='T4';

	TABLE_NAME             NUM_ROWS LAST_ANAL
	-------------------- ---------- ---------
	T4                        90776 15-SEP-13

As You see, the last analyzed column is updated and num_rows also, In addition to that, now dba_tab_col_statistics has a new column "notes" where the value updated for this type is stats_on_load

	SQL>  select column_name,table_name,notes from dba_tab_col_statistics where table_name='T4';

	COLUMN_NAME                              TABLE_NAME           NOTES
	---------------------------------------- -------------------- -----------------------------------------
	ORACLE_MAINTAINED                        T4                   STATS_ON_LOAD
	EDITIONABLE                              T4                   STATS_ON_LOAD
	SHARING                                  T4                   STATS_ON_LOAD
	EDITION_NAME                             T4                   STATS_ON_LOAD
	NAMESPACE                                T4                   STATS_ON_LOAD
	SECONDARY                                T4                   STATS_ON_LOAD
	GENERATED                                T4                   STATS_ON_LOAD
	TEMPORARY                                T4                   STATS_ON_LOAD
	STATUS                                   T4                   STATS_ON_LOAD
	TIMESTAMP                                T4                   STATS_ON_LOAD
	LAST_DDL_TIME                            T4                   STATS_ON_LOAD

	COLUMN_NAME                              TABLE_NAME           NOTES
	---------------------------------------- -------------------- -----------------------------------------
	CREATED                                  T4                   STATS_ON_LOAD
	OBJECT_TYPE                              T4                   STATS_ON_LOAD
	DATA_OBJECT_ID                           T4                   STATS_ON_LOAD
	OBJECT_ID                                T4                   STATS_ON_LOAD
	SUBOBJECT_NAME                           T4                   STATS_ON_LOAD
	OBJECT_NAME                              T4                   STATS_ON_LOAD
	OWNER                                    T4                   STATS_ON_LOAD

	18 rows selected.

This feature is extremely helpful where lot of bulk load operations performed and required manual statistics collection.

-Thanks Geek DBA

Comments are closed.