Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle fake histograms

For a CHAR datatype column, when gather_table_stats was run, the endpoint_actual_value had the char values like 'JUMBO BOX', 'JUMBO CAR', etc. in user_tab_histograms table.

I am trying to write (fake) statistics as part of an experiment and I am using prepare_column_values and set_column_stats to create the histogram details, but I am not able to specify the endpoint_actual_value.

EDIT 1 : Version : Oracle 11g Express Edition

EDIT 2 : I update the statistics the following way:

DECLARE
 m_distcnt NUMBER := 3;       -- num_distinct
 m_density NUMBER := 1/1000;  -- density
 m_nullcnt NUMBER := 0;       -- num_nulls
 m_avgclen NUMBER := 10;       -- avg_col_len
 srec      dbms_stats.statrec;
 c_array   dbms_stats.chararray;
BEGIN
  srec.epc := 3;
  c_array := dbms_stats.chararray('HELLO', 'WORLD', 'FIRST');
  srec.bkvals := dbms_stats.numarray(20, 180, 800);

  dbms_stats.prepare_column_values(srec, c_array);

  dbms_stats.set_column_stats(USER, 'FBHIST_DEMO', 'TESTCOL', 
  distcnt => m_distcnt,
  density => m_density,
  nullcnt => m_nullcnt,
  srec    => srec,
  avgclen => m_avgclen);
END;
/

Any suggestions? Thanks!

like image 450
user2761431 Avatar asked May 08 '15 17:05

user2761431


1 Answers

maybe create your own fake_histogram table(s) and then fill in your fake values - then UNION these to the proper ones. then you don't have to try to fool the system

like image 199
Randy Avatar answered Oct 17 '22 09:10

Randy