Skip to content

Commit 7d7cc28

Browse files
committed
db: fix bug in scaling compression stats for virtual tables
A copy/pasta. I found this while working on a separate change that makes the API around table stats much less fragile.
1 parent c969279 commit 7d7cc28

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

table_stats.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ func (d *DB) loadTableStats(
330330
panic(errors.AssertionFailedf("pebble: error parsing compression stats %q for table %s: %v", loadedProps.CompressionStats, meta.TableNum, err))
331331
}
332332
if meta.Virtual {
333-
meta.Stats.CompressionStats.Scale(meta.Size, meta.TableBacking.Size)
333+
stats.CompressionStats.Scale(meta.Size, meta.TableBacking.Size)
334334
}
335335
}
336336

testdata/table_stats

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,8 @@ point-deletions-bytes-estimate: 3942
982982
range-deletions-bytes-estimate: 0
983983
compression: None:36,Snappy:73/84
984984

985+
# Use a small block-size so that excising the table results in virtual tables
986+
# which cover significantly fewer blocks.
985987
define format-major-version=25 block-size=100 value-separation=off
986988
----
987989

@@ -1027,6 +1029,8 @@ L6:
10271029
000006:[c1#16,SET-c1#16,SET]
10281030
000008(000005):[e#14,SET-e#14,SET]
10291031

1032+
# These excised pieces should show a fraction of the compression stat sizes
1033+
# compared to the original table.
10301034
wait-pending-table-stats
10311035
000007
10321036
----
@@ -1035,7 +1039,7 @@ num-deletions: 0
10351039
num-range-key-sets: 0
10361040
point-deletions-bytes-estimate: 0
10371041
range-deletions-bytes-estimate: 0
1038-
compression: None:20986
1042+
compression: None:4060
10391043

10401044
wait-pending-table-stats
10411045
000008
@@ -1045,4 +1049,4 @@ num-deletions: 0
10451049
num-range-key-sets: 0
10461050
point-deletions-bytes-estimate: 0
10471051
range-deletions-bytes-estimate: 0
1048-
compression: None:20986
1052+
compression: None:4060

0 commit comments

Comments
 (0)