You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We've also used UInt64 type for the hits column, which takes 8 bytes, but has a relatively small max value:
42
+
We've also used a UInt64 type for the `hits` column, which takes 8 bytes, but has a relatively small max value:
43
43
44
44
```sql
45
45
SELECTmax(hits)
@@ -59,23 +59,23 @@ ALTER TABLE wikistat
59
59
MODIFY COLUMN `hits` UInt32;
60
60
```
61
61
62
-
This will reduce the size of this column in memory by at least 2 times. Note that the size on disk will remain unchanged due to compression. But be careful, pick data types that are not too small!
62
+
This will reduce the size of this column in memory by at least a factor of two. Note that the size on disk will remain unchanged due to compression. But be careful, pick data types that are not too small!
When we deal with sequential data, like time-series, we can further improve storage efficiency by using special codecs.
66
+
When we deal with sequential data, like time-series, we can further improve storage efficiency by using special codecs.
67
67
The general idea is to store changes between values instead of absolute values themselves, which results in much less space needed when dealing with slowly changing data:
68
68
69
69
```sql
70
70
ALTERTABLE wikistat
71
71
MODIFY COLUMN `time` CODEC(Delta, ZSTD);
72
72
```
73
73
74
-
We've used the Delta codec for time column, which is a good fit for timeseries data.
74
+
We've used the Delta codec for the `time` column, which is a good fit for time-series data.
75
75
76
-
The right ordering key can also save disk space.
76
+
The right ordering key can also save disk space.
77
77
Since we usually want to filter by a path, we will add `path` to the sorting key.
78
-
This requires recreation of the table.
78
+
This requires recreation of the table.
79
79
80
80
Below we can see the `CREATE` command for our initial table and the optimized table:
0 commit comments