Wednesday, January 13, 2016

Monitor number of now changed for mview base table

One programer has interested on number of rows changed for a mview base table, thus he suggested to query x$knstmvr table , which may be found in http://avdeo.com/tag/materialized-view/.  As such, I have concern on accessing to the SYS x$ view.

Initially, I thought to use DBA_TAB_MODIFICATIONS, but it requires to run dbms_stats.flush_database_monitoring_info and gather table statistics of rest the counter, and time co-related to mview refresh.


 For performance reasons, the Oracle Database does not populate this view immediately when the actual modifications occur. Run the FLUSH_DATABASE_MONITORING_INFO procedure in the DIMS_STATS PL/SQL package to populate this view with the latest information. 


Confirmed from https://docs.oracle.com/cd/E26401_01/doc.122/e48791/T578797T589127.htm#T578863, that count on MLOG$_ is an easier way to achieve the purpose. 

MLOG$ Table

An MLOG$ table is the Snapshot Log table created against a base table. A row is inserted into the table each time a change (insert/update/delete) is made to the base table.
When a snapshot is refreshed in fast (incremental) mode, it reads the rows in the MLOG$ table and uses this information to get the updated information from the base table into the snapshot for further processing.
Standard RDBMS functionality manages rows inserted into the MLOG tables. When a snapshot is refreshed in either fast or complete mode, then the RDBMS will delete rows from the MLOG table. However, if multiple snapshots reference the same MLOG, then all the snapshots must be refreshed before the RDBMS can remove any rows from the MLOG table.
The RDBMS creates snapshot logs on the base table and automatically names them using MLOG$_[20 characters of the table name]. For example:
MRP_FORECAST_DATES (18 char) creates MLOG$_MRP_FORECAST_DATES BOM_DEPARTMENT_RESOURCES (24 char) creates MLOG$_BOM_DEPARTMENT_RESOU
In case of a tie, the RDBMS adds a number to the MLOG name. For example:
WSM_COPY_OP_RESOURCES creates MLOG$_WSM_COPY_OP_RESOURCE WSM_COPY_OP_RESOURCE_INSTANCES creates MLOG$_WSM_COPY_OP_RESOURCE1



SQL> select count(*) from mlog$_bonus; 
COUNT(*)
----------
0

from http://www.dba-oracle.com/t_mlog_dollar_tables.htm is a real case.

Moreover, questions to programer:
What is the purpose of getting this number?
What actions should be taken if the amount exceeds certain number? What number should be set as threshold?

Thanks for the challenge.

Monday, January 11, 2016

How to check if a table statistics is locked

LIQY@ORCL1> select table_name from user_tables;

TABLE_NAME
------------------------------
T1

LIQY@ORCL1> select STATTYPE_LOCKED from user_tab_statistics;

STATT
-----


LIQY@ORCL1> exec dbms_stats.lock_table_stats('LIQY','T1');

PL/SQL procedure successfully completed.

LIQY@ORCL1> select STATTYPE_LOCKED from user_tab_statistics;

STATT
-----
ALL

LIQY@ORCL1> exec dbms_stats.UNlock_table_stats('LIQY','T1');

PL/SQL procedure successfully completed.

LIQY@ORCL1> select STATTYPE_LOCKED from user_tab_statistics;

STATT
-----

Wednesday, January 06, 2016

Akeeba backup for Joomla 1.5

Helping to maintain a site using Joomla 1.5. Recently the hosting provider's server was hacked again, cause the site not working for few days.  Pouring oil on the fire by the provider is its poor technical support.
Luckily the site has Akeeba backup installed and takes snapshot on demand, and I found a backup copy of Aug. 

As the content of this site is quite static, I decided to roll back to Aug by using Akeeba kickstart script.

After reading the quick guide, I renamed the not-working www directory to www_bad, and uploaded below files to in the new www root directory, except for
  • the existing configuration.php
  • kickstart.php 
  • en-GB.kickstart.ini as English installation language
  • August's Akeeba backup file

With above and type my domain.com/kickstart.php for the restoration to production site. In few steps and minutes, I got the site working again.

However, pictures of phocagallery were not found.  Compared the directory , and found the image/phocagallery were not backed up in the Akeeba backup file. ( Akeeba backup version is v3.4.3).  Lucily, I didn't delete the old www directory, and it works again after copy the directory  from www_bad/image/phocagallery.


The last step is to rebuild thumnail of phocagallery, as it showed blank in phocagallery, but once clicked, the picture is still shown properly.

Cheers and Thanks Akeeba backup & Kickstart.

Say bye-bye to the hosting provider soon.