非关键字段的数据库索引
Database indexing on non-key field
我有一个关于 this answer 的问题。
我还发布了这个问题作为对该答案的评论,但没有得到任何回复。
它声明在非键字段上建立索引的情况下,架构将是:
Field name Data type Size on disk
firstName Char(50) 50 bytes
(record pointer) Special 4 bytes
我的问题是为什么需要再次存储firstName
?指针还不够吗?我们只需要简单地更改排序比较函数以在 (*pointer).firstName
上进行比较,而不是在 firstName
上进行比较。
引用@wildplasser 给出的 答案:
In theory, it is not needed: the char(50) field could be pulled from
the basetable. In practice, this would cause both the basetable and
the index to be pulled fron disk, costing more IO bandwith and
bufferspace.
我有一个关于 this answer 的问题。
我还发布了这个问题作为对该答案的评论,但没有得到任何回复。
它声明在非键字段上建立索引的情况下,架构将是:
Field name Data type Size on disk firstName Char(50) 50 bytes (record pointer) Special 4 bytes
我的问题是为什么需要再次存储firstName
?指针还不够吗?我们只需要简单地更改排序比较函数以在 (*pointer).firstName
上进行比较,而不是在 firstName
上进行比较。
引用@wildplasser 给出的
In theory, it is not needed: the char(50) field could be pulled from the basetable. In practice, this would cause both the basetable and the index to be pulled fron disk, costing more IO bandwith and bufferspace.