Bizarre tables: starting with MD* . Let's drop some.

What are these strange tables starting with MD*? 

I’ve moved my blog from https://insanedba.blogspot.com to https://dincosman.com Please update your bookmarks and follow/subscribe at the new address for all the latest updates and content. More up-to-date content of this post may be available there.

Can I drop them?  I will answer first: 
    Yes, You can drop some of them if your Oracle DB version is 12cR2 or later. 


But which ones?

There were over 3000 tables starting with 'MD*' letters in one of our production database.  I knew that those tables are related with Spatial indexes. But that was a huge amount.

So I took a deep dive into the spatial indexes. 


For each spatial index created, one table named like "MDRT_#" is created also. There is a one to one relationship (except the partitioned ones) between them.

There are also tables named like "MDXT_#, MDXT_#_BKTS, MDXT_#_MBR".  According to the Doc Id 1916251.1, these tables are created for supporting statistics on Spatial Index and after the statistic analyzing is finished, MDXT_#_BKTS and MDXT_#_MBR should be dropped automatically. But somehow, we had lots of them. 

Also Doc Id 2029072.1 states that  "Dropping these temporary tables (MDXT_#_BKTS and MDXT_#_MBR ones) won't cause any database corruption.

With 12.2.0.1.0,  the MDXT tables no longer exist. They are replaced with MDSYS.SDO_INDEX_HISTOGRAM_TABLE table.

So we can drop all tables starting with MDXT_# .

Here is the query to detect which MDRT_# tables are required for integrity and the spatial_indexes they are related with. (Execute with system user.)


Also we can validate the above result with the query below. These tables are the required ones.  (Execute with system user.)


We can drop the orphaned MDRT_# tables with executing the query output. (Execute with system user.)


We had got rid of over 2500 tables. 

Also if you  ever need to change the tablespace of these "MDRT_#" tables. You can change them with the command below.


Hope it helps.

Comments

Popular posts from this blog

Oracle Grid Release Update by using Ansible Playbooks

Oracle Database Release Update by Using Ansible Playbooks

How to Upgrade PostgreSQL, PostGIS and Patroni in Air-Gapped Environments