質問

Let's say we have the following table:

CREATE TABLE T (
 ID INT,
 String1 nvarchar(400),
 String2 nvarchar(400)
)

And a query:

select String1, String2, count(*)
from T
group by String1, String2

If T was indexed by a column-store index, this grouping query would generally be driven by a non-clustered column-store index scan.

If a column-store index stores rows in a column-by-column format, and each column is sorted individually, how can it then provide multiple columns per row at once? This seems to be impossible because the individual columns are sorted in different sort orders. I can't think of any way to merge the individual columns back into a full row containing both columns (String1, String2 in this example).

How does this work internally?

役に立ちましたか?

解決

Each column is stored separately, so the system has to do multiple accesses to the column indexes (one per column selected) and then internally join the results together to return the final query result. This is still quite efficient as the column store indexes dramatically reduce the I/O required, although a large number of columns queried might be slow.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top