问题描述
我的问题通常是如何确定大小以设置sizecreate cluster语句中的值。特别是对于父表,400字节宽,有1500万行,而子表120字节宽,有4000万行。可能有任何数量的孩子,但平均少于4,中位数为2。
应该做什么????在下面的代码中是,或者更好的是,达到最优值的步骤是什么?
谢谢
应该做什么????在下面的代码中是,或者更好的是,达到最优值的步骤是什么?
create cluster tr_cluster ( region number(2),customer number(10),invoice number(10)) size ???? ; create index tr_cluster_idx on cluster tr_cluster; /* 15000000 rows ave length 410 bytes */ create table invoices(region number(2),customer number(10),invoice number(10), other_data char(400)); /* 42000000 rows ave length 102 bytes , avgerage number of lines is 3.8, median number of lines is 2 */ create table invoice_lines(region number(2),customer number(10),invoice number(10), line integer, line_data char(100));
谢谢
专家解答
从文档中:
SIZE
Specify the amount of space in bytes reserved to store all rows with the same cluster key value or the same hash value. This space determines the maximum number of cluster or hash values stored in a data block. If SIZE is not a divisor of the data block size, then Oracle Database uses the next largest divisor. If SIZE is larger than the data block size, then the database uses the operating system block size, reserving at least one data block for each cluster or hash value.
因此,从本质上讲,对于给定的群集密钥,* 所有 * 行将占用多少空间。根据您的业务需求,您需要在这里保持平衡,例如
1) 选择一个真正的 * 大 * 大小 (假设您省略了它,因此每个块一个群集密钥)
然后你得到绝对最好的并发,因为没有两个键会坐在同一个块。* 但是 * 您现在还有一个更大的表-因此,对数据的任何扫描 (例如 “本月发票”) 都将花费更长的时间。你可能浪费了RAM,因为这些块中的每一个都是空的。
2) 选择一个真正的 * 小 * 尺寸
您的表在磁盘上占用的空间更少-因此更好地进行扫描,并且当这些块在缓冲区缓存中时,您可以最佳利用这些块。* 但是 * 您有更多的机会群集密钥不适合其指定的块,因此有更多的竞争机会。
因此,它就像Goldilocks :-) 您选择的大小是您的业务需求的平衡,即插入的数量/频率,群集密钥的访问量与通过其他方式 (日期范围等) 的访问量。
当然,一个合理的起点是填充每个块,因此像1*410 3*102这样的事情将成为可能。
SIZE
Specify the amount of space in bytes reserved to store all rows with the same cluster key value or the same hash value. This space determines the maximum number of cluster or hash values stored in a data block. If SIZE is not a divisor of the data block size, then Oracle Database uses the next largest divisor. If SIZE is larger than the data block size, then the database uses the operating system block size, reserving at least one data block for each cluster or hash value.
因此,从本质上讲,对于给定的群集密钥,* 所有 * 行将占用多少空间。根据您的业务需求,您需要在这里保持平衡,例如
1) 选择一个真正的 * 大 * 大小 (假设您省略了它,因此每个块一个群集密钥)
然后你得到绝对最好的并发,因为没有两个键会坐在同一个块。* 但是 * 您现在还有一个更大的表-因此,对数据的任何扫描 (例如 “本月发票”) 都将花费更长的时间。你可能浪费了RAM,因为这些块中的每一个都是空的。
2) 选择一个真正的 * 小 * 尺寸
您的表在磁盘上占用的空间更少-因此更好地进行扫描,并且当这些块在缓冲区缓存中时,您可以最佳利用这些块。* 但是 * 您有更多的机会群集密钥不适合其指定的块,因此有更多的竞争机会。
因此,它就像Goldilocks :-) 您选择的大小是您的业务需求的平衡,即插入的数量/频率,群集密钥的访问量与通过其他方式 (日期范围等) 的访问量。
当然,一个合理的起点是填充每个块,因此像1*410 3*102这样的事情将成为可能。
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




