> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kinetica.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Record Distribution Functions

Record distribution functions provide a means to locate any database record
within the memory processing hierarchy; and through aggregating the results,
determine the distribution of records across the cluster.

> [accordion] KI\_CHUNK()
>
> Returns the index of the chunk within the rank/TOM containing this record.
> This value may change as data is added or deleted from a table.

> [accordion] KI\_CHUNK\_ID()
>
> Returns the ID of the chunk within the rank/TOM containing this record.
> This value should remain the same even after system restarts.

> [accordion] KI\_CHUNK\_MAX(col)
>
> Returns the maximum value for the specified column in its chunk.
> If the data has changed, this value may be higher than any actual values.

> [accordion] KI\_CHUNK\_MIN(col)
>
> Returns the minimum value for the specified column in its chunk.
> If the data has changed, this value may be lower than any actual values.

> [accordion] KI\_CHUNK\_OFFSET()
>
> Returns the index of the record within the chunk.

> [accordion] KI\_PARTITION()
>
> Returns the index of the partition within the rank/TOM containing this record, for
> [partitioned](https://docs.kinetica.com/content/concepts/tables.md#partitioning) tables.

> [accordion] KI\_RANK()
>
> Returns the index of the rank containing this record.

> [accordion] KI\_TOM()
>
> Returns the index of the TOM within the rank containing this record.

For example, the following query can be used to determine the distribution of
records of the `example.stocks` table across the nodes of the cluster.

```sql Non-Partitioned Distribution theme={null}
SELECT
	KI_RANK() AS "Rank",
	COUNT(*) AS "TotalRecords"
FROM example.stocks
GROUP BY 1
ORDER BY 1
```

```sql Partitioned Distribution theme={null}
SELECT
	KI_RANK() AS "Rank",
	KI_PARTITION() AS "Partition",
	COUNT(*) AS "TotalRecords"
FROM example.stocks
GROUP BY 1, 2
ORDER BY 1, 2
```

```sql Multi-TOM Distribution theme={null}
SELECT
	KI_RANK() AS "Rank",
	KI_TOM() AS "TOM",
	COUNT(*) AS "TotalRecords"
FROM example.stocks
GROUP BY 1, 2
ORDER BY 1, 2
```

```sql Chunk-Level Distribution theme={null}
SELECT
	KI_RANK() AS "Rank",
	KI_CHUNK() AS "Chunk",
	COUNT(*) AS "TotalRecords"
FROM example.stocks
GROUP BY 1, 2
ORDER BY 1, 2
```

For partitioned tables, `KI_PARTITION()` can be added to the query to also
the distribution across partitions, and for clusters with more than 1 TOM per
rank (1 TOM/rank is the default), `KI_TOM()` can be added.  To see chunk-level
distribution, use `KI_CHUNK()`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.