This library isn't "experimental" only in the sense that I'm trying out new code to see where it leads -- MongoScript is a thought experiment more than a production helper, for one simple reason. As the MongoDB server-side code execution puts it:
You understand all that, you just want to hack some server-side code for the fun of it? Let's get to it!
- Multiquery: execute multiple find queries in one call. (See Performance below.)
- Easy maintenance: why transfer records and updates back forth between your web server and your database, when you can do everything at localhost speed?
(more ideas/explanation coming soon)
When run locally, it doesn't make a significant difference:
# Macbook Pro running Ruby and MongoDB locally # 100 run average Traditional execution took 0.38300072999999996 Multiquery execution took 0.37415497999999997
But check out what happens if the web server and the database aren't on the same machine:
# Test web and MongoDB servers in the same EC2 location # 100 run average Traditional execution took 0.02256884963 Multiquery execution took 0.01187204267
The results hold up over multiple runs, and I suspect would be even stronger with writes.
A more detailed readme, with usage instructions and so on.
Since this is currently experimental/for fun, I'm relying on ActiveSupport for HashWithIndifferentAccess and Concern. I acknowledge this restricts the gem to projects where ActiveSupport is an option, but should be easy enough to rip out if someone wants to use this seriously. (The hardest part would be removing underscore, used in execution.rb.)