I’m trying to figure out how much duplication of data is actually in the DB. I’ve been poking around the web but I haven’t stumbled across a page that answers my question.
For this example Go program:
package main
import (
"log"
"github.com/apple/foundationdb/bindings/go/src/fdb"
"github.com/apple/foundationdb/bindings/go/src/fdb/directory"
"github.com/apple/foundationdb/bindings/go/src/fdb/tuple"
"github.com/google/uuid"
)
func main() {
fdb.MustAPIVersion(630)
db := fdb.MustOpenDefault()
ds, err := directory.CreateOrOpen(db, []string{"records"}, nil)
if err != nil {
log.Fatalf("Unable to create/open directory: %s\n", err)
}
field := map[string]string{
"one": "alpha",
"two": "bravo",
"three": "charlie",
"four": "delta",
"five": "echo",
"six": "foxtrot",
"seven": "golf",
}
for i := 0; i < 2; i++ {
id, err := uuid.NewRandom()
if err != nil {
log.Fatalf("Unable to get random ID: %s\n", err)
}
_, _ = db.Transact(func(tr fdb.Transaction) (interface{}, error) {
for key, value := range field {
tr.Set(ds.Pack([]tuple.TupleElement{id.String(), key}), []byte(value))
}
return nil, nil
})
}
}
I get the following from fdbcli
:
fdb> getrange "" "\xFF"
Range limited to 25 keys
`\x15\x12\x02052f6dad-1076-4696-a246-3d7524245dd6\x00\x02five\x00' is `echo'
`\x15\x12\x02052f6dad-1076-4696-a246-3d7524245dd6\x00\x02four\x00' is `delta'
`\x15\x12\x02052f6dad-1076-4696-a246-3d7524245dd6\x00\x02one\x00' is `alpha'
`\x15\x12\x02052f6dad-1076-4696-a246-3d7524245dd6\x00\x02seven\x00' is `golf'
`\x15\x12\x02052f6dad-1076-4696-a246-3d7524245dd6\x00\x02six\x00' is `foxtrot'
`\x15\x12\x02052f6dad-1076-4696-a246-3d7524245dd6\x00\x02three\x00' is `charlie'
`\x15\x12\x02052f6dad-1076-4696-a246-3d7524245dd6\x00\x02two\x00' is `bravo'
`\x15\x12\x02c723601e-ec4c-4e43-a536-6b2e72cfb504\x00\x02five\x00' is `echo'
`\x15\x12\x02c723601e-ec4c-4e43-a536-6b2e72cfb504\x00\x02four\x00' is `delta'
`\x15\x12\x02c723601e-ec4c-4e43-a536-6b2e72cfb504\x00\x02one\x00' is `alpha'
`\x15\x12\x02c723601e-ec4c-4e43-a536-6b2e72cfb504\x00\x02seven\x00' is `golf'
`\x15\x12\x02c723601e-ec4c-4e43-a536-6b2e72cfb504\x00\x02six\x00' is `foxtrot'
`\x15\x12\x02c723601e-ec4c-4e43-a536-6b2e72cfb504\x00\x02three\x00' is `charlie'
`\x15\x12\x02c723601e-ec4c-4e43-a536-6b2e72cfb504\x00\x02two\x00' is `bravo'
`\xfe\x01\x15\x12\x00\x01layer\x00' is `'
`\xfe\x01\xfe\x00\x01hca\x00\x14\x14' is `\x01\x00\x00\x00\x00\x00\x00\x00'
`\xfe\x01\xfe\x00\x01hca\x00\x15\x01\x15\x12' is `'
`\xfe\x01\xfe\x00\x01version\x00' is `\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
`\xfe\x01\xfe\x00\x14\x02records\x00' is `\x15\x12'
I can see a lot of repeated string data here. Is this repeated in the underlying data store?