package main
import (
"github.com/dgraph-io/badger"
"log"
"time"
"strconv"
"math/rand"
)
func main() {
opts := badger.DefaultOptions
opts.Dir = "/tmp/insertdgarph"
opts.ValueDir = "/tmp/insertdgarph"
db, err := badger.Open(opts)
if err != nil {
log.Fatal(err)
}
defer db.Close()
start:=(time.Now().Unix())
var total=1000000
var sst string
for i := 0; i < 57; i++ {
sst+="v"
}
addcount:=0
for i:=0;i<total;i++{
err:=db.Update(func(txn *badger.Txn) error {
return txn.Set([]byte(strconv.Itoa(rand.Intn(total))+"333333333"),[]byte(strconv.Itoa(rand.Intn(total))+sst))
})
if err!=nil {
println(err.Error())
}
addcount++
println(addcount);
}
println(addcount)
stop:= time.Now().Unix()
println(stop-start)
}
a simple demo from badger readme. the speed is really too slow 100 /s
do you have any idea?
the api is really not user friendly . I still confused about what the differents between managedb and db .
really need to improve
I also meet this “Invalid API request. Not allowed to perform this action using ManagedDB” for several time when I use the managedb api ? is hart to check source code, who can help me ?