Thursday, August 6, 2009

How do you know whether the index is analyzed or not in a table ...?

Many of times we create indexes and forget to analyze them. Here is a simple way to find out whether your indexes or tables have been analyzed alteast once or not ...

- To find if a table is analyzed, check the "AVG_ROW_LEN" column of the USER_TABLES table. If it is non-zero, the 'analyze' or 'dbms_stats' command has been run at least once on this table.

- To find if an index is analyzed, check the "COLUMN_LENGTH " column of the USER_IND_COLUMNS table. If it is non-zero, the 'analyze' or 'dbms_stats' command has been run at least once on this index.

But why do we need to analyze the indexes or tables ??
Because oracle uses the cost based optimizer to give the best performance in most of the cases. And the cost based optimizer needs data to decide the access plan, and this data is generated by the analyze command or the newer dbms_stats package.

So always analyze or dbms_stats the table and indexes.
If you analyze a table, then its current indexes are automatically analyzed too. If you analyze a index, then the table is not analyzed.

Monday, August 3, 2009

JBoss still uses old .class files even after replacing them with new class files....

Was facing an issue with jboss when i tried to redeploy an ear by replacing few .class files with new compiled .class files (the class files are mostly interfaces containing constants defined in it). But the jboss failed to pickup the new .class files, rather it was referring to the old class files still.

I tried every possibility like redeploying the ear, clearing the cache of jboss, etc but it didn't helped out. But if updating the class which is 'implementing' the interface, it would then refer to new .class files.

The possible reasons could be
- Jboss compiler is possibly failing to recognize the changed interfaces as the implemented class is not been updated.
- The Jboss is not cleaning it weekly hashmapped reference of the classes.

But the point what i learned is that defining constants in an interface is a bad practice as you can end up in such trouble. Interfaces are meant to expose the method definitions.