CLUSTERING_FACTOR

 我们知道clustering_factor是通过oracle的索引得到表数据块的一个因子,实际上表示index列的排列顺序和表中index这个列的排列顺序的关系,在极端的情况下:
1、clustering_factor=表中记录的数目,这表明表中index这个列的存储是随机的。
比如:
SQL> create table t1 as select * from all_objects order by object_name;
表已创建。
SQL> create index t1_i1 on t1(object_id);
索引已创建。
SQL> exec dbms_stats.gather_table_stats(USER,'T1',cascade=>true);
PL/SQL 过程已成功完成。
SQL> SELECT num_rows,blocks FROM user_tables where table_name='T1' ;
NUM_ROWS         BLOCKS
----------         --------------
     41742                  578

SQL> SELECT clustering_factor from user_indexes where index_name='T1_I1';
CLUSTERING_FACTOR
-----------------
            21402  
(可以这样理解,如果我们要通过index的顺序读完这个表的所有数据块,那么需要查看21402个数据块,你也许觉得奇怪
   这个表一共才578个数据块,怎么会需要读21402个块呢? 这是因为由于数据的存放顺序是按object_name来
存放的,通过index通过object_id的顺序来读取表必然导致oracle多次重复读取一个块,而oracle并不会保留它曾经读过的块
的记录,当然在oracle9i中的perfetch功能一定程度上减轻了这个问题)
表数据库的存放顺序是按object_name来排序的,而index是按object_id来排序的,这种情况下,t1_i1的clustering_factor应该接近
表 t1的记录条数。
2、clustering_factor=表中数据块的个数
比如:
SQL> create table t1 as select * from all_objects order by object_id;
表已创建。
SQL> SELECT COUNT(*) FROM T1;
COUNT(*)
----------
     41744
SQL> create index t1_i1 on t1(object_id);
索引已创建。
SQL> exec dbms_stats.gather_table_stats(USER,'T1',cascade=>true);
PL/SQL 过程已成功完成。
SQL> SELECT clustering_factor from user_indexes where index_name='T1_I1';
CLUSTERING_FACTOR
-----------------
              578
SQL> select blocks from user_tables where table_name='T1';
    BLOCKS
----------
       578
SQL>
表数据库的存放顺序是按object_id来排序的,而index是按object_id来排序的,这种情况下,t1_i1的clustering_factor应该和表占用空间的块数相当(这个例子恰好相等)。
关于clustering_factor的几个神话
1、通过索引的重建可以减少clustering_factor,这是错误的因为重建index不能改变表中数据存放的顺序,因此也不能改变
    clustering_factor。
2、高的clustering_factor意胃这index中的碎片很高,或者有很多的空的叶子块。
3、删除后再创建index可以降低clustering_factor。
需要注意的是clustering_factor主要影响index range scan和对于 index equal的查询影响相对小些。高的clustering_factor对于执行计划来说是绝对不好的,但是我们知道一个表中不可能所有的index clustering_factor都低,因为表的存放顺序是一定的。
 
--------------------------------转载.....

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/24217871/viewspace-677689/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/24217871/viewspace-677689/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
PCA_Plot_3=function (data,Annotation,VAR,Color) { # logcountdata row:genes,column: samples pca <- prcomp(data) pca_out<-as.data.frame(pca$x) df_out<- pca_out %>%tibble::rownames_to_column(var=VAR) %>% left_join(., Annotation) #df_out<- merge (pca_out,Annotation,by.x=0,by.y=0) # label_color<- factor(df_out[,group]) ggplot(df_out,aes_string(x="PC1",y="PC2")) +geom_point(aes_string(colour = Color)) } Deseq2_Deseq_function_2=function (Countdata,Coldata) { dds_fil <- DESeq2:: DESeqDataSetFromMatrix(countData =Countdata, colData = Coldata, design = ~Group) dds_fil_Deg<- DESeq2::DESeq(dds_fil) return(dds_fil_Deg) } pheatmap_singscore=function (pathways,data,Annotation) { Gene_select_anno= data[,colnames(data) %in% pathways] %>%t()%>%.[,rownames(Annotation)] # return(Gene_select_anno) # Anno_expression_data=Gene_select_anno[,c("SYMBOL",Group_select)] %>% as.data.frame() %>% distinct() %>% na.omit() # rownames(Anno_expression_data)=Anno_expression_data[,"SYMBOL"] # Annotation=group_anno["Gene_type"] # input= Anno_expression_data[,Group_select] # F2_pheatmap <- pheatmap::pheatmap(input, cellwigermline calling GATKdth = 10, cellheight = 12, scale = "row", # treeheight_row = 5, # show_rownames = T,show_colnames = T, # annotation_col= Annotation, # # annotation_row=Annotation, # annotation_legend=Label_def, # cluster_rows = T, cluster_cols = F,clustering_distance_rows = "euclidean") pheatmap::pheatmap(Gene_select_anno, cellwigermline=5, cellheight = 10,cellwidth = 10, scale = "row", treeheight_row = 5, show_rownames = T,show_colnames = F, annotation_col= Annotation, # annotation_row=Annotation, #annotation_legend=Label_def, cluster_rows = T, cluster_cols = F,clustering_distance_rows = "euclidean") } matrix.please<-function(x) { m<-as.matrix(x[,-1]) rownames(m)<-x[,1] m } 这是r语言的代码,告诉我每一条代码的作用和意义
最新发布
07-13

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值