Currently, we only support collecting single column partial statistics that must be prefixes of an index. This is because to find our minimum and maximum values without doing a full table scan we need the column to be a prefix of its index and to get these upper and lower bounds, we use the histograms of the most recent full statistic. Since multi-column statistics don't have histograms, deriving the upper and lower bounds here is not as straightforward. One way to do this would be to construct a span that includes the bounds from all of the individual column histograms from the individual latest full statistic for each column to determine the two disjoint span covering the lower extreme and upper extreme.
For example assume we have a table CREATE TABLE (x INT, y INT, z INT, INDEX (x, y), INDEX (y, z)). This would create single column statistics on x, y and z and multi column statistics {x, y} and {y, z}. Assume that from the previous histogram, we determined that the lower and upper bounds and respective span for each individual column was as follows:
{x} --> Lower: 4, Upper: 10 ---> Span: [ - /4) (/10 - ]
{y} --> Lower: 5, Upper: 8 ---> Span: [ - /5) (/8 - ]
{z} --> Lower: 1, Upper: 2 ---> Span: [ - /1) (/2 - ]
We could then construct a span for the multi column statistics in this form:
/x/y --> [ - /4/5), (/10/8 - ]
/y/z --> [ - /5/1), (/8/2 - ]
Jira issue: CRDB-22679
Currently, we only support collecting single column partial statistics that must be prefixes of an index. This is because to find our minimum and maximum values without doing a full table scan we need the column to be a prefix of its index and to get these upper and lower bounds, we use the histograms of the most recent full statistic. Since multi-column statistics don't have histograms, deriving the upper and lower bounds here is not as straightforward. One way to do this would be to construct a span that includes the bounds from all of the individual column histograms from the individual latest full statistic for each column to determine the two disjoint span covering the lower extreme and upper extreme.
For example assume we have a table
CREATE TABLE (x INT, y INT, z INT, INDEX (x, y), INDEX (y, z)). This would create single column statistics on x, y and z and multi column statistics {x, y} and {y, z}. Assume that from the previous histogram, we determined that the lower and upper bounds and respective span for each individual column was as follows:We could then construct a span for the multi column statistics in this form:
Jira issue: CRDB-22679