英文:
Calculating the record size of alternate index for a VSAM ksds file
问题
在IBM文档中,计算AIX KSDS文件记录大小的公式如下:
5 + 替代键长度 + (n * 基础簇的主键长度)
在我的情况下,根据文档,替代键对于n的值是非唯一的,它表示包含相同替代键值的记录数量。所以我的问题是,当有成千上万条记录时,如何找到n的值?
此外,我不明白它所说的"包含相同替代键值的记录数量"是什么意思。例如,如果一个包含6条记录的文件的替代键包含值10,20,20,30,30,30,那么在这种情况下n的值会是多少?
英文:
In the IBM documentation, the formula to calculate the record size of AIX for a KSDS file is given as
>5 + alternate-key length + (n * base cluster's prime-key length)
In my case, the alternate-key is non-unique to the value of n, according to the documentation, would be the number of records that contain the same alternate-key value. So my question is, How to find this value of n when there are thousands of records?
Also, I don't understand what it means by "the number of records that contain the same alternate key value". For example, if the alternate-key for a file with 6 records contains the values 10,20,20,30,30,30 then what would be the value of n in this case?
答案1
得分: 1
在DEFINE AIX命令中,您基本上是在定义交替索引的记录。如果它们是唯一的,那么关系是1:1,因此n = 1。
当关系是非唯一的时候,每个交替索引记录将有与包含非唯一键的记录数量相同的条目。这意味着DFSMS将创建一个交替键记录,并且该记录将包含对所有这些记录的PK的引用。
在您的示例中,让我添加一个PK值。
PK1 - 10<br>
PK2 - 20<br>
PK3 - 20<br>
PK4 - 30<br>
PK5 - 30<br>
PK6 - 30<br>
AIX将具有以下记录:
10 - PK1<br>
20 - PK2, PK3<br>
30 - PK4, PK5, PK6<br>
当添加具有交替键的新PK时,将更新这些记录中的每一个。手册要求您估计非唯一交替键将与多少个PK相关联。
假设
- PK的长度为8字节
- 交替键的长度为2字节
- 您预计可能会有多达10,000个具有相同非唯一交替键的唯一PK
使用IBM的公式,您的记录大小将为:
5 + 2 + (10000 * 8) = 80007,作为最大值。
如果您有数百万条记录,那么您将使用一个较大的数字。请注意,这些值允许访问方法服务根据您对文件内容的估计来管理存储。
没有水晶球,这些都是最佳猜测估计。
下一个问题是如果您低估了会发生什么?在尝试添加记录/更新记录时,您将收到逻辑错误。以下是错误的参考:
这是IBM文档中错误的引用。
英文:
In the DEFINE AIX command you are basically defining the record for the Alternate Index. If they are UNIQUE then the relationship is 1:1 and so n = 1.
When the relationship is non-unique then each alternate-index record will have as many entries as there are records that contain the non-unique key. This means, that DFSMS will create an alternate-key record and that record will contain a reference to the PK of all those records.
In your example let me add a PK Value.
PK1 - 10<br>
PK2 - 20<br>
PK3 - 20<br>
PK4 - 30<br>
PK5 - 30<br>
PK6 - 30<br>
The AIX will have the following records:
10 - PK1<br>
20 - PK2, PK3<br>
30 - PK4, PK5, PK6<br>
Each of those records will be updated when a new PK is added that has the alternate-key. What the manual is asking you for is an estimate of how many PKs will be associated with the non-unique alternate-key.
Assuming that
- the PK is 8 bytes in length
- the alternate-key is 2 bytes in length
- you anticipate that there might be up to 10k unique PKs with the same non-unique alternate-key
Using IBM's formula your record size would be:
5 + 2 + (10000 * 8) = 80007 as the max value.
If you have millions of records then you would use a large number. Note that these values allow Access Method Services to manage storage based on your estimates of what the file will contain.
There is no crystal ball and these are best guess estimates.
The next question is what happens if you underestimate? You will get a logical error when trying to add a record / update it. Here is the error:
Here is a reference to the error in IBM's Documentation
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论