From:Steve Adams
Date:06-Apr-2001 20:35
Subject:   Histogram helper

Good idea, but unfortunately the table statistics and the basic column statistics (called single-bucket histograms) that are available if you only analyze the table are not sufficient to determine whether the distribution of values for any column is uniform or skewed. That means that we cannot do this with a data dictionary query; we will have to scan the table.

Based on your suggestion I have written consider_histogram.sql that will scan a table and do the analysis for a single column only. The fact that it has to do a full scan each time you run it will probably make you use it selectively on columns that are subject to literal predicates in expensive queries. In my opinion, that's probably a good thing. Enjoy!

I just experienced an incredibly DRAMATIC performance boost with a well-placed histogram! Now I'm hungry for "Histogram Helper." I'd like to analyze the database and identify other possible candidates for histograms. (Then maybe review the code after that. I'm using CHOOSE optimization with automatic statistics gathering on all tables and indexes.)