I have a table (Key tinyint, Value bigint). There are a billion rows for each distinct Key value and only about 100 distinct Key values.
Is there a way to not have to store Key in the every row without breaking this up into multiple tables?
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It only takes a minute to sign up.
Sign up to join this communityTry leaving it how it is, but using columnstore, perhaps. The effectiveness will depend on the style of usage, but you may find it compresses a lot better, having a useful impact.
You could combine the Key
and Value
into a dense binary encoding. You'd be better off doing this in the application, most likely. Define the table's column to be binary()
of just the right length to hold the packed values. 3 digits (key) + 10 digits (value) gives about 7 bytes for the column (rounding up), down from the 9 bytes needed for a tinyint
and bigint
. With the Key
as the high values the rows will be in the same clustered sequence as currently.
I've little experience dealing with binary columns so indexing, clustering, partitioning and defining good predicates for lookups may prove .. "challenging".
bigint
value? What kind of queries do you do against this data? Purely aggregation? Or are there other columns too?