SQL Execution Plans in Javascript
Various companies, frameworks, and libraries have built functionality resembling relational databases to serve various goals: tighter language integration (R, pandas, linq), niche data applications (solr, mapping software), scaling machines or memories (hadoop, datomic, memcached), etc. The core power of SQL is that it allows you to describe what you want, allowing the machine to pick how to get it.
The general process used by Oracle is as follows:
Query -> Parse Tree -> Generate set of plans -> Scoring each plan -> Pick a plan -> Execution -> Output
An alternate path is to generate an execution plan using heuristics – an easier approach, and the obvious choice for many applications.
http://garysieling.com/blog/sql-execution-plans-in-javascript