Best Practices
On this page
Here are some best practices to manage performance tradeoffs between transactions and analytics using SingleStore Kai.
Enable JSON key order
SingleStoreDB does not preserve the JSON key order by default.
-
Database level: To preserve JSON key order for a database, run the following command:
db.runCommand({setDefaultCollectionOptions:1,value:{shardKey:null,preserveJSONKeyOrder:true}} -
Collection level: To preserve JSON key order for a specific collection (for example, mycollection), run the following command:
db.createCollection("mycollection",{shardKey:{a:1,b:1},preserveJSONKeyOrder:true}}
Faster Transactions (But Lower Resilience)
SingleStoreDB enables retryWrites
by default, which provides higher resilience against network errors.retryWrites
setting will improve latency for write operations, but the application might need to manually handle errors due to transient network conditions.
"mongodb://<user>:<password>@svc-XXXX.svc.singlestore.com:27017/?retryWrites=false&authMechanism=PLAIN&tls=true&loadBalanced=true"
SingleStoreDB recommends leaving retryWrites
enabled for ingesting data.
Last modified: July 11, 2023