Monday, September 19, 2011

Database Stats

Has it every happened to you that a given database table has thousands or millions or rows but dba_tables shows 0 rows once you generated the statistics on the table?
Does it ring a bell?

Here is a simple scenario to test.

Like it happens it most data conversions, records get inserted into a staging table from a flat file. However, if we generate statistics on this table before a commit happens, the statistics will get generated but it would show 0 rows.

Hence, we should generate database statistics only after commit has been issued on the table after massive data inserts/deletes/updates.

So, go back to your code and review the position of commit and the command to generate the statistics. Commit should happen prior to generating statistics.

Have a question? Please leave a comment and I would be glad to answer.

No comments:

Post a Comment