-
Notifications
You must be signed in to change notification settings - Fork 573
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Performance Benchmarking for JSON type serialization, Object vs String #1474
Comments
I've added some benchmarks for all JSON patterns (paths, structs, strings) in #1490 Benchmark Results TL;DRInserting JSON
Reading JSON
For more details see below, along with the examples in the Breakdown of ResultsInsertionThe fastest method of insertion depends on the source of your data in your application. If your JSON data is already in
If your data is NOT in already in a
If your data is in a Based on the test struct, the
Reading / Scanning rowsThere is a server-side bug preventing the client from receiving JSON strings from the server, so we can't test the performance for those. If your end goal is to pass the JSON data along in If you wish to read the JSON object by paths, then you should use the
If you're trying to read the entire JSON into a struct, then you should simply scan into your struct. You can still use
But this may not always be the fastest for reading structs. You could consider instead receiving strings from the server and then using Converting back to a stringIf your JSON data is in
Notice that the fastest is by simply using ConclusionThese tests aren't perfect, but it's a good overview for how things perform now and how you should consider writing, reading, and handling JSON data within your Go application. Raw output for the benchmarks has been pasted below: Raw Output
|
The JSON type implemented in #1455 has multiple ways of serializing JSON data. The original format is object based, with paths defined along with native column data. The other is simply a
String
payload for the server to parse as JSON. Objects can be defined via a key/value map, or by providing a struct.We need to test and compare the performance of these methods for reading/writing data. In some cases it may be faster to call
json.Marshal
with string format than it would be to have a struct with object format. This also leads to less control over how the data types are inferred on the server.The text was updated successfully, but these errors were encountered: