Andrey,
In general case we do not store any values in the index. Essentially index
is a sequence of so-called "links" (i.e. pointers) to real data rows,
sorted in accordance with indexed column. When two rows have the same
indexed value, we need to sort them somehow still. This is where key and
possibly affinity key are used for additional comparisons. This is typical
index implementation for many databases.
Sometimes we store ("inline") real values in the index for performance
reasons as it may dramatically speedup index search at the cost of
additional memory/disk space. In this case it is possible that some part of
key/affinity key is inlined as well.
On Thu, Oct 26, 2017 at 4:39 AM, Andrey Kornev <
[hidden email]>
wrote:
> Hello,
>
> Ignite adds the cache key and optionally the affinity key (if defined) as
> two last columns of all user-defined indexes (line 301 in
> H2TableDescriptor). For example, given a user index salary_idx including a
> single field "salary", the actual index is going to look like this:
>
> CREATE INDEX "SALARY_IDX" ON "mycache"."PERSON" ("SALARY" ASC, "_KEY" ASC)
>
> I'm wondering what is the purpose of doing so. Could someone knowledgeable
> (Vladimir O., for example) share their insights?
>
> Thanks
> Andrey
>