mpjbt icon indicating copy to clipboard operation
mpjbt copied to clipboard

Benchmarking JSONb

Open davidglavas opened this issue 6 years ago • 1 comments

Is there a way to benchmark Postgres JSONb implementation as directly as possible? I mean measuring the serialization/deserialization time for some json documents, as well as measuring the time to access specific values?

davidglavas avatar Nov 09 '19 14:11 davidglavas

Hi @davidglavas

We built mpjbt to perform a as-close-as-reasonably-possible-for-real-life-end-users comparison of MongoDB and Postgres, but it could be used for benchmarking just the Postgres implementation - I hadn't considered the use case but it makes sense!

I actually added JSON (un)marshalling into the Postgres layer even though mpjbt does nothing with the data - this was to keep the comparison somewhat valid, as the mgo driver handles the bson marshalling natively, so it seemed only fair to perform the same decoding work for Postgres.

You can check out an example of this where rawData is decoded into a data local variable and... nothing. It's never used again. It should be trivial to comment these out and eliminate the marshal/unmarshal work in the Postgres layer, or to add additional timers to measure the cost, although you'll be benchmarking the Go implementation of JSON serialisation, which is probably not what you want?

Let me know if this is helps at all :)

Dom

domodwyer avatar Nov 12 '19 20:11 domodwyer