You Asked [url=http://www.oraclepoint.com]iUsmuNFvtOraclePointl6bBNfAqD[/url]
How do you actually create statistics without creating histograms? I know you can supply the auto or the actual number of buckets using the command in dbms_stats.
Is a bucket of 1 the same as no histograms? There is a disagreement (with me and another DBA) on the way to do this.
[url=http://www.oraclepoint.com]OZiX88IgIOraclePointlmy0LIrx3[/url]
thanks.
[url=http://www.oraclepoint.com]53onekFfxOraclePointkgdou4MI2[/url]
and we said... [url=http://www.oraclepoint.com]JRYS3AG2LOraclePointPj9Id2wHW[/url]
ops$tkyte%ORA10GR2> create table t as select * from all_users;
[url=http://www.oraclepoint.com]WN3KxYocJOraclePointhoSYyjwGc[/url]
Table created.
ops$tkyte%ORA10GR2> column column_name format a15
[url=http://www.oraclepoint.com]xMU9c48kXOraclePointzWeMtrE5f[/url]
ops$tkyte%ORA10GR2> exec dbms_stats.gather_table_stats( user, 'T' );
PL/SQL procedure successfully completed.
[url=http://www.oraclepoint.com]di8nGl7eZOraclePointgRg9FtSDL[/url]
ops$tkyte%ORA10GR2> select column_name, count(*) from user_tab_histograms where
table_name = 'T' group by column_name;
[url=http://www.oraclepoint.com]MBvj1IDC2OraclePointvHvRkUOOa[/url]
COLUMN_NAME COUNT(*)
--------------- ----------
[url=http://www.oraclepoint.com]1K6QqNwpSOraclePointg9VrKXctO[/url]
USER_ID 2
CREATED 2
USERNAME 2
[url=http://www.oraclepoint.com]kxRcjYO10OraclePointiEN96Y4LF[/url]
ops$tkyte%ORA10GR2> select * from t where username = 'x';
[url=http://www.oraclepoint.com]G8uZdsvL3OraclePointIomWPanr0[/url]
no rows selected
ops$tkyte%ORA10GR2> select * from t where user_id = -1;
[url=http://www.oraclepoint.com]C71Ce6Pd1OraclePointoXBte0d4d[/url]
no rows selected
[url=http://www.oraclepoint.com]LopEwTqJiOraclePointHxQHzM82r[/url]
ops$tkyte%ORA10GR2> select * from t where created = sysdate;
no rows selected
[url=http://www.oraclepoint.com]3HLsviufCOraclePointu96NKj3OW[/url]
ops$tkyte%ORA10GR2> exec dbms_stats.gather_table_stats( user, 'T' );
[url=http://www.oraclepoint.com]L6fuCSBJIOraclePointNHA60HGs4[/url]
PL/SQL procedure successfully completed.
ops$tkyte%ORA10GR2> select column_name, count(*) from user_tab_histograms where
[url=http://www.oraclepoint.com]odZrNXnaiOraclePointMTwjfsEPv[/url]
table_name = 'T' group by column_name;
COLUMN_NAME COUNT(*)
[url=http://www.oraclepoint.com]XQ6geCgaCOraclePointogviLO84b[/url]
--------------- ----------
USER_ID 2
CREATED 30
[url=http://www.oraclepoint.com]Vg34tLqSqOraclePointYX7KuNFRr[/url]
USERNAME 2
[url=http://www.oraclepoint.com]IxILcp7A2OraclePointL9unTQfN0[/url]
[url=http://www.oraclepoint.com]q4SXSpTdZOraclePointhjrPreX48[/url]
Ok, so by default in 10g, Oracle uses size auto to gather column stats - that is, it looks at predicates you've used and the data in the columns and figures out what histograms to gather
If you don't want that, you can just get endpoints (one bucket - high and low values and number of values - this is useful stuff generally) by doing this:
[url=http://www.oraclepoint.com]C184B7noQOraclePoint5Kd52XMOq[/url]
ops$tkyte%ORA10GR2> exec dbms_stats.gather_table_stats( user, 'T', method_opt=>'for all
columns size 1' );
[url=http://www.oraclepoint.com]2iJRFs9UaOraclePointdsTauKYnM[/url]
PL/SQL procedure successfully completed.
[url=http://www.oraclepoint.com]UR2lMBEG3OraclePointcSHIKpRbv[/url]
ops$tkyte%ORA10GR2> select column_name, count(*) from user_tab_histograms where
table_name = 'T' group by column_name;
[url=http://www.oraclepoint.com]0aGa4ytUjOraclePoint5sNGDe8or[/url]
COLUMN_NAME COUNT(*)
--------------- ----------
USER_ID 2
[url=http://www.oraclepoint.com]9tx1LG9TQOraclePointnlsZlIfBC[/url]
CREATED 2
USERNAME 2
[url=http://www.oraclepoint.com]UuW4oFHvIOraclePointmsxTrgGis[/url]
Now, if you really really didn't want ANY column information, you could do this:
[url=http://www.oraclepoint.com]MgCcJoLjPOraclePointTEQWZBtSq[/url]
ops$tkyte%ORA10GR2> exec dbms_stats.delete_table_stats( user, 'T' );
[url=http://www.oraclepoint.com]yab8CKuV2OraclePointRbZAo6DHF[/url]
PL/SQL procedure successfully completed.
ops$tkyte%ORA10GR2> exec dbms_stats.gather_table_stats( user, 'T', method_opt=>'for
[url=http://www.oraclepoint.com]rSo7lsM9IOraclePointNrb5f2Vd4[/url]
columns ' );
PL/SQL procedure successfully completed.
[url=http://www.oraclepoint.com]fNOWfpwgTOraclePointrjawQtaMV[/url]
ops$tkyte%ORA10GR2> select column_name, count(*) from user_tab_histograms where
table_name = 'T' group by column_name;
[url=http://www.oraclepoint.com]JZTRnAshgOraclePointj40cZNqvt[/url]
no rows selected
[url=http://www.oraclepoint.com]WhPqPyHBEOraclePoint1cRLlqe4T[/url]
Note: The above entry was published at AskTom.