Help:difference between LAST_ANALYZED of dba_tables and STATS_UPDATE_TIME column of dba_tab_stats_hi [message #662133] |
Tue, 18 April 2017 11:21 |
|
abhi7394
Messages: 6 Registered: April 2017
|
Junior Member |
|
|
Hello Everyone,
the scenerio is like below. Every night after 23.00 stats on one table is calculated using one unix script which has below command. Table is partition table with 4 partitions.
v_part := 'DAT_'||to_char(sysdate,'YYYYMMDD');
dbms_stats.gather_table_stats(ownname => null, tabname => 'T_FAC_STOCK_S24', partname => v_part, estimate_percent => dbms_stats.auto_sample_size, degree => 4, force => true);
In the morning at 11.00 on April 18th when i checked the LAST_ANALYZED column of dba_tables it is showing below.
OWNER TABLE_NAME LAST_ANALYZED
------------------------------ ------------------------------ -------------------
ODSFE3 T_FAC_STOCK_S24 17-04-2017 00:10:54
According to above output stats were not calculated on the script run of 17 April 23:00 . But then i checked dba_tab_stats_history and i got below output.
OWNER TABLE_NAME PARTITION_NAME STATS_UPDATE_TIME
------------------------------ ------------------------------ ------------------------------ ---------------------------------------------------------------------------
ODSFE3 T_FAC_STOCK_S24 15-APR-17 01.00.54.360524 AM +02:00
ODSFE3 T_FAC_STOCK_S24 DAT_20170414 15-APR-17 08.30.16.958906 AM +02:00
ODSFE3 T_FAC_STOCK_S24 DAT_20170414 15-APR-17 03.38.16.819252 PM +02:00
ODSFE3 T_FAC_STOCK_S24 15-APR-17 03.38.16.819252 PM +02:00
ODSFE3 T_FAC_STOCK_S24 DAT_20170415 16-APR-17 12.15.09.720862 AM +02:00
ODSFE3 T_FAC_STOCK_S24 16-APR-17 12.15.09.720862 AM +02:00
ODSFE3 T_FAC_STOCK_S24 16-APR-17 12.40.10.563678 PM +02:00
ODSFE3 T_FAC_STOCK_S24 DAT_20170416 17-APR-17 12.10.54.320661 AM +02:00
ODSFE3 T_FAC_STOCK_S24 17-APR-17 12.10.54.320661 AM +02:00
ODSFE3 T_FAC_STOCK_S24 DAT_20170417 18-APR-17 12.25.22.288880 AM +02:00
ODSFE3 T_FAC_STOCK_S24 18-APR-17 12.25.22.288880 AM +02:00
OWNER TABLE_NAME PARTITION_NAME STATS_UPDATE_TIME
------------------------------ ------------------------------ ------------------------------ ---------------------------------------------------------------------------
ODSFE3 T_FAC_STOCK_S24 DAT_20170417 18-APR-17 01.00.39.981961 AM +02:00
ODSFE3 T_FAC_STOCK_S24 18-APR-17 01.00.39.981961 AM +02:00
Now i need your expertise in this situation. I want to understand should there be a difference between these 2 columns , if yes then why and if no then what i am doing wrong here.
Thanks
Abhishek
|
|
|
|
|
|
Re: Help:difference between LAST_ANALYZED of dba_tables and STATS_UPDATE_TIME column of dba_tab_stats_hi [message #662138 is a reply to message #662137] |
Tue, 18 April 2017 12:22 |
|
abhi7394
Messages: 6 Registered: April 2017
|
Junior Member |
|
|
Hello Everyone,
Sorry for posting without proper format. Thanks for letting me know. I am posting it again.
the scenerio is like below. Every night after 23.00 stats on one table is calculated using one unix script which has below command. Table is partition table with 4 partitions.
DECLARE
v_part VARCHAR2(50);
v_nb PLS_INTEGER;
BEGIN
IF To_number(To_char(SYSDATE, 'HH24')) >= 22 THEN
-- entre 22h et 00h on calcule les stats pour la partition de la date courante :
-- T_FAC_STOCK_S24 : si exécuté avant 00h
v_part := 'DAT_'
||To_char(SYSDATE, 'YYYYMMDD');
ELSE
-- entre 00h et 22h on calcule les stats pour la partition de J-1
-- T_FAC_STOCK_S24 : si exécuté après 00h
v_part := 'DAT_'
||To_char(SYSDATE - 1, 'YYYYMMDD');
END IF;
SELECT Count(*)
INTO v_nb
FROM user_tab_partitions
WHERE table_name = '${STAT_NOM_TABLE}'
AND partition_name = v_part;
IF v_nb > 0 THEN
dbms_output.Put_line('Analyse la table ${STAT_NOM_TABLE}, pour la partition ' || v_part);
dbms_stats.Gather_table_stats(ownname => NULL, tabname => '${STAT_NOM_TABLE}', partname => v_part, estimate_percent => dbms_stats.auto_sample_size, degree => 4, FORCE => TRUE);
ELSE
dbms_output.Put_line('Analyse la table ${STAT_NOM_TABLE}');
dbms_stats.Gather_table_stats(ownname => NULL, tabname => '${STAT_NOM_TABLE}', estimate_percent => dbms_stats.auto_sample_size, degree => 4, FORCE =>TRUE);
END IF;
END;
/
In the morning at 11.00 Am 18th April when i checked the LAST_ANALYZED column of dba_tables it is showing below.
OWNER TABLE_NAME LAST_ANALYZED
------------ ----------------- -------------------
ODSFE3 T_FAC_STOCK_S24 17-04-2017 00:10:54
According to above output stats were not calculated on the script run of 17 April 23:00 . But then i checked dba_tab_stats_history and i got below output.
OWNER TABLE_NAME PARTITION_NAME STATS_UPDATE_TIME
----------- ------------- ------------------------- ------------------------------
ODSFE3 T_FAC_STOCK_S24 15-APR-17 01.00.54.360524 AM +02:00
ODSFE3 T_FAC_STOCK_S24 DAT_20170414 15-APR-17 08.30.16.958906 AM +02:00
ODSFE3 T_FAC_STOCK_S24 DAT_20170414 15-APR-17 03.38.16.819252 PM +02:00
ODSFE3 T_FAC_STOCK_S24 15-APR-17 03.38.16.819252 PM +02:00
ODSFE3 T_FAC_STOCK_S24 DAT_20170415 16-APR-17 12.15.09.720862 AM +02:00
ODSFE3 T_FAC_STOCK_S24 16-APR-17 12.15.09.720862 AM +02:00
ODSFE3 T_FAC_STOCK_S24 16-APR-17 12.40.10.563678 PM +02:00
ODSFE3 T_FAC_STOCK_S24 DAT_20170416 17-APR-17 12.10.54.320661 AM +02:00
ODSFE3 T_FAC_STOCK_S24 17-APR-17 12.10.54.320661 AM +02:00
ODSFE3 T_FAC_STOCK_S24 DAT_20170417 18-APR-17 12.25.22.288880 AM +02:00
ODSFE3 T_FAC_STOCK_S24 18-APR-17 12.25.22.288880 AM +02:00
ODSFE3 T_FAC_STOCK_S24 DAT_20170417 18-APR-17 01.00.39.981961 AM +02:00
ODSFE3 T_FAC_STOCK_S24 18-APR-17 01.00.39.981961 AM +02:00
Now i need your expertise in this situation. I want to understand should there be a difference between these LAST_ANALYZED of dba_tables and STATS_UPDATE_TIME column of dba_tab_stats_history columns , if yes then why and if no then what i am doing wrong here.
Thanks
Abhishek
|
|
|
|
|
|
|
|
|
|
Re: Help:difference between LAST_ANALYZED of dba_tables and STATS_UPDATE_TIME column of dba_tab_stats_hi [message #662147 is a reply to message #662145] |
Tue, 18 April 2017 14:30 |
|
abhi7394
Messages: 6 Registered: April 2017
|
Junior Member |
|
|
Hello BlackSwan,
Ok lets leave last_analyzed for now. I have another doubt.
I am sorry i was not clear with data. in this table there are high numbers of rows insertion and deletion. so apart from column values , row count also changes.
As you said 10% of rows need to changed before new statistics, yes i agree with that and i have seen data modifications are more than 10%.The partition of SYSDATE will be created on SYSDATE 22:00. After that rows are inserted into it till SYSDATE+1. for example partition of 17th April will be created on 17th April 23.00 and data will be inserted and deleted from it till 18th April 22.00.As it is more than 10% oracle will gather the stats and update it but it is not the case here.
second if we calculate stats manually even when data is changed less than 10%, will oracle gather the stats or not. In automatic stats gathering it will not gather but what about manual.?
Thanks
Abhishek
|
|
|