SlideShare a Scribd company logo
Javascript & SQL
within database management system
Javascript & SQL within database management system
Clusterpoint — Building and Growing Database-as-a-Service : A Case Study
Clusterpoint database
2-in-1: DBaaS & on-premises database
Document oriented
Sharded + replicated
Schema less
ACID transactions
Cloud enabled (EU & US sites)
Clusterpoint — Building and Growing Database-as-a-Service : A Case Study
Clusterpoint — Building and Growing Database-as-a-Service : A Case Study
Evolution of Computing Infrastructure
History
Clusterpoint — Building and Growing Database-as-a-Service : A Case Study
1970 1995 2010 20152005
Google discovers that all of web
does not fit in a relational database
Jeff Dean, Sanjay Ghemaway et al
publish papers on MapReduce
and BigTable
Key-Value Store
MapReduce
Mainframes Clusters of Commodity Hardware
Commercially Viable
Technologies are split
between: data storage
and computing
will they merge
?
Clusterpoint — Building and Growing Database-as-a-Service : A Case StudyClusterpoint — Building and Growing Database-as-a-Service : A Case Study
Clusterpoint — Running JavaScript Inside the Database
db.runCommand({
mapreduce: "DenormAggCollection",
query: {
filter1: { '$in': [ 'A', 'B' ] },
filter2: 'C',
filter3: { '$gt': 123 }
},
map: function() { emit(
{ d1: this.Dim1, d2: this.Dim2 },
{ msum: this.measure1, recs: 1, mmin: this.measure1,
mmax: this.measure2 < 100 ? this.measure2 : 0 }
);},
reduce: function(key, vals) {
var ret = { msum: 0, recs: 0, mmin: 0, mmax: 0 };
for(var i = 0; i < vals.length; i++) {
ret.msum += vals[i].msum;
ret.recs += vals[i].recs;
if(vals[i].mmin < ret.mmin) ret.mmin = vals[i].mmin;
if((vals[i].mmax < 100) && (vals[i].mmax > ret.mmax))
ret.mmax = vals[i].mmax;
}
return ret;
},
finalize: function(key, val) {
val.mavg = val.msum / val.recs;
return val;
},
out: 'result1',
verbose: true
});
db.result1.
find({ mmin: { '$gt': 0 } }).
sort({ recs: -1 }).
skip(4).
limit(8);
SELECT
Dim1, Dim2,
SUM(Measure1) AS MSum,
COUNT(*) AS RecordCount,
AVG(Measure2) AS MAvg,
MIN(Measure1) AS MMin
MAX(CASE
WHEN Measure2 < 100
THEN Measure2
END) AS MMax
FROM DenormAggTable
WHERE (Filter1 IN (’A’,’B’))
AND (Filter2 = ‘C’)
AND (Filter3 > 123)
GROUP BY Dim1, Dim2
HAVING (MMin > 0)
ORDER BY RecordCount DESC
LIMIT 4, 8
1
2
3
4
5
1
7
6
1
2
3
4
5
Grouped dimension columns are pulled
out as keys in the map function,
reducing the size of the working set.
Measures must be manually aggregated.
Aggregates depending on record counts
must wait until finalization.
Measures can use procedural logic.
Filters have an ORM/ActiveRecord-
looking style.
6 Aggregate filtering must be applied to
the result set, not in the map/reduce.
7 Ascending: 1; Descending: -1
Revision4,Created2010-03-06
RickOsborne,rickosborne.org
mySQL MongoDB
Clusterpoint — Building and Growing Database-as-a-Service : A Case Study
+
Clusterpoint — Building and Growing Database-as-a-Service : A Case Study
Technology top 2015 (StackOverflow)
Clusterpoint — Building and Growing Database-as-a-Service : A Case Study
Clusterpoint — Running JavaScript Inside the Database
SQL JavaScript
flexible to express
queries
executes in parallel
static
hard to define
expressions
bad with custom
routines
hard to express queries
difficult to execute in
parallel
dynamic
easy to define
expressions
great with custom
routines
Clusterpoint — Running JavaScript Inside the Database
Javascript - V8
Too good to be used only in browsers
Clusterpoint — Running JavaScript Inside the Database
• Chrome
• Node.js
• MongoDB
• Google BigQuery UDF
Clusterpoint — Running JavaScript Inside the Database
Javascript - V8
Produces machine code (IA-32, x64, ARM)
Clusterpoint — Running JavaScript Inside the Database
Clusterpoint — Running JavaScript Inside the Database
Javascript - V8
Performance - Problem
Clusterpoint — Running JavaScript Inside the Database
Compute the 25,000th prime
Clusterpoint — Running JavaScript Inside the Database
Javascript - V8
Performance - Algorithm
Clusterpoint — Running JavaScript Inside the Database
For x = 1 to infinity: if x not divisible by any
member of an initially empty list of primes, add
x to the list until we have 25,000
Clusterpoint — Running JavaScript Inside the Database
Javascript - V8
Performance - Contenders
Clusterpoint — Running JavaScript Inside the Database
Clusterpoint — Running JavaScript Inside the Database
Javascript - V8
Performance - Results (only 17% slower)
Clusterpoint — Running JavaScript Inside the Database
Javascript - V8
Data Binding
Clusterpoint — Running JavaScript Inside the Database
C++ callback V8
if (name == “John”)
{
return “Male”;
}
Accessor

(C++ callback)
string * get_value(string &field_name)
{
if (field_name == “name”)
return new string(“John”);
else
return new string(“Unknown”);
}
Clusterpoint — Building and Growing Database-as-a-Service : A Case Study
JS/SQL
Language structure
SQL-like structure
Arbitrary JavaScript in any clause of the SELECT or
UPDATE statement.
Joins, indexing nested documents
+
Clusterpoint — Building and Growing Database-as-a-Service : A Case Study
SELECT * FROM product
+Clusterpoint — Building and Growing Database-as-a-Service : A Case Study
JS/SQL
Insert statement
INSERT INTO product JSON VALUE {
"name": "Schwinn S29 Full Suspension Mountain Bike",
"image_url": "schwinn_s29.jpeg",
"description": "...",
"color": ["black","red"],
"order_price": 211.16,
"price": 259.16,
"packaging": {
"height": 23,
"width": 25,
"depth": 12,
"weight": 54
},
"availability": "In Stock"
}
+Clusterpoint — Building and Growing Database-as-a-Service : A Case Study
JS/SQL
Update statement
Clusterpoint — Running JavaScript Inside the Database
+
UPDATE product[“id_123”] SET
{
color.push_back(“orange”);
packaging.volume = packaging.height * packaging.width * packaging.depth;
}
JS/SQL
Price buckets
+Clusterpoint — Building and Growing Database-as-a-Service : A Case Study
JS/SQL
Grouping/Aggregation
function PriceBucket(price) {
var boundaries = [0, 1, 5, 10, 50, 100, 200, 500, 1000];
for (var i = 1; i < boundaries.length; i++) {
if (price >= boundaries[i - 1] && price < boundaries[i])
return boundaries[i - 1].toString() + " to " + boundaries[i].toString();
}
return "above " + boundaries[boundaries.length - 1].toString();
}
SELECT PriceBucket(price), COUNT()
FROM product
GROUP BY PriceBucket(price);
+Clusterpoint — Building and Growing Database-as-a-Service : A Case Study
JS/SQL
Javascript & SQL in action
SELECT PriceBucket(price), COUNT()
FROM product
GROUP BY PriceBucket(price);
+Clusterpoint — Building and Growing Database-as-a-Service : A Case Study
doc1 John
AccessorField (price) store JS V8
…. PriceBucket(price) ….doc2 George
doc3 Marry
JS/SQL
Joins
Clusterpoint — Running JavaScript Inside the Database
INSERT INTO product["34A40855"] JSON VALUE {
name: "Schwinn S29 Full Suspension Mountain Bike",
price: 259.16
};
INSERT INTO order JSON VALUE {
product_key: "34A40855",
delivery_address: "My Office"
};
SELECT delivery_address, product[product_key].price
FROM order
WHERE product[product_key].price > 20
+
Sign up
Where:
http://cloud.clusterpoint.com
How Much?
“Zero, none”
10GB free FOREVER !!!
Any Docs?
http://docs.clusterpoint.com
Few fields and you are in
Clusterpoint — Running JavaScript Inside the Database
Clusterpoint — Building and Growing Database-as-a-Service : A Case Study
Thank you!

More Related Content

What's hot (20)

PPTX
Why Power BI is the right tool for you
Marcos Freccia
 
PDF
Designing a modern data warehouse in azure
Antonios Chatzipavlis
 
PPTX
Azure SQL DWH
Shy Engelberg
 
PDF
Data warehouse con azure synapse analytics
Eduardo Castro
 
PPTX
The Developer Data Scientist – Creating New Analytics Driven Applications usi...
Microsoft Tech Community
 
PDF
Azure Databricks – Customer Experiences and Lessons Denzil Ribeiro Madhu Ganta
Databricks
 
PDF
Yahoo's Next Generation User Profile Platform
DataWorks Summit/Hadoop Summit
 
PPTX
Azure Cosmos DB + Gremlin API in Action
Denys Chamberland
 
PPTX
Data Modeling IoT and Time Series data in NoSQL
Basho Technologies
 
PPTX
Azure Synapse Analytics Overview (r1)
James Serra
 
PPTX
Leveraging Azure Databricks to minimize time to insight by combining Batch an...
Microsoft Tech Community
 
PDF
Introducing Azure SQL Data Warehouse
Grant Fritchey
 
PDF
IBM Cloud Native Day April 2021: Serverless Data Lake
Torsten Steinbach
 
PPTX
An intro to Azure Data Lake
Rick van den Bosch
 
PPTX
OLAP on the Cloud with Azure Databricks and Azure Synapse
AtScale
 
PPTX
A developer's introduction to big data processing with Azure Databricks
Microsoft Tech Community
 
PDF
Enabling Key Business Advantage from Big Data through Advanced Ingest Process...
StampedeCon
 
PPTX
How we evolved data pipeline at Celtra and what we learned along the way
Grega Kespret
 
PDF
Unified Data Analytics: Helping Data Teams Solve the World’s Toughest Problems
Databricks
 
PPTX
Azure data platform overview
James Serra
 
Why Power BI is the right tool for you
Marcos Freccia
 
Designing a modern data warehouse in azure
Antonios Chatzipavlis
 
Azure SQL DWH
Shy Engelberg
 
Data warehouse con azure synapse analytics
Eduardo Castro
 
The Developer Data Scientist – Creating New Analytics Driven Applications usi...
Microsoft Tech Community
 
Azure Databricks – Customer Experiences and Lessons Denzil Ribeiro Madhu Ganta
Databricks
 
Yahoo's Next Generation User Profile Platform
DataWorks Summit/Hadoop Summit
 
Azure Cosmos DB + Gremlin API in Action
Denys Chamberland
 
Data Modeling IoT and Time Series data in NoSQL
Basho Technologies
 
Azure Synapse Analytics Overview (r1)
James Serra
 
Leveraging Azure Databricks to minimize time to insight by combining Batch an...
Microsoft Tech Community
 
Introducing Azure SQL Data Warehouse
Grant Fritchey
 
IBM Cloud Native Day April 2021: Serverless Data Lake
Torsten Steinbach
 
An intro to Azure Data Lake
Rick van den Bosch
 
OLAP on the Cloud with Azure Databricks and Azure Synapse
AtScale
 
A developer's introduction to big data processing with Azure Databricks
Microsoft Tech Community
 
Enabling Key Business Advantage from Big Data through Advanced Ingest Process...
StampedeCon
 
How we evolved data pipeline at Celtra and what we learned along the way
Grega Kespret
 
Unified Data Analytics: Helping Data Teams Solve the World’s Toughest Problems
Databricks
 
Azure data platform overview
James Serra
 

Similar to Javascript & SQL within database management system (20)

PDF
How to Radically Simplify Your Business Data Management
Clusterpoint
 
PPTX
Data Modeling for NoSQL
Tony Tam
 
PDF
How Modern SQL Databases Come up with Algorithms that You Would Have Never Dr...
Lukas Eder
 
PPTX
JasperWorld 2012: Reinventing Data Management by Max Schireson
MongoDB
 
PPTX
Webinar: Migrating from RDBMS to MongoDB
MongoDB
 
PDF
SQL? NoSQL? NewSQL?!? What’s a Java developer to do? - JDC2012 Cairo, Egypt
Chris Richardson
 
PPTX
Big Data Analytics Module-3 as per vtu syllabus.pptx
shilpabl1803
 
PPTX
JS App Architecture
Corey Butler
 
PDF
High-performance database technology for rock-solid IoT solutions
Clusterpoint
 
PPTX
NoSQL
dbulic
 
ODP
Front Range PHP NoSQL Databases
Jon Meredith
 
PPTX
NoSQLDatabases
Adi Challa
 
PDF
Hybrid solutions – combining in memory solutions with SSD - Christos Erotocritou
JAXLondon_Conference
 
PPTX
When to Use MongoDB
MongoDB
 
PPTX
3 Ways Modern Databases Drive Revenue
MongoDB
 
PPTX
Big Data (NJ SQL Server User Group)
Don Demcsak
 
KEY
NoSQL databases and managing big data
Steven Francia
 
PDF
How to Get Started with Your MongoDB Pilot Project
DATAVERSITY
 
PDF
Nosql intro
Hoang Nguyen
 
PPTX
MongoDB Days Silicon Valley: Jumpstart: The Right and Wrong Use Cases for Mon...
MongoDB
 
How to Radically Simplify Your Business Data Management
Clusterpoint
 
Data Modeling for NoSQL
Tony Tam
 
How Modern SQL Databases Come up with Algorithms that You Would Have Never Dr...
Lukas Eder
 
JasperWorld 2012: Reinventing Data Management by Max Schireson
MongoDB
 
Webinar: Migrating from RDBMS to MongoDB
MongoDB
 
SQL? NoSQL? NewSQL?!? What’s a Java developer to do? - JDC2012 Cairo, Egypt
Chris Richardson
 
Big Data Analytics Module-3 as per vtu syllabus.pptx
shilpabl1803
 
JS App Architecture
Corey Butler
 
High-performance database technology for rock-solid IoT solutions
Clusterpoint
 
NoSQL
dbulic
 
Front Range PHP NoSQL Databases
Jon Meredith
 
NoSQLDatabases
Adi Challa
 
Hybrid solutions – combining in memory solutions with SSD - Christos Erotocritou
JAXLondon_Conference
 
When to Use MongoDB
MongoDB
 
3 Ways Modern Databases Drive Revenue
MongoDB
 
Big Data (NJ SQL Server User Group)
Don Demcsak
 
NoSQL databases and managing big data
Steven Francia
 
How to Get Started with Your MongoDB Pilot Project
DATAVERSITY
 
Nosql intro
Hoang Nguyen
 
MongoDB Days Silicon Valley: Jumpstart: The Right and Wrong Use Cases for Mon...
MongoDB
 
Ad

Recently uploaded (20)

PPTX
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
PDF
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
PDF
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
PDF
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
PPTX
Finding Your License Details in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
PPTX
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
PDF
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
PPTX
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
PDF
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
PPTX
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
PPTX
Coefficient of Variance in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
PDF
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
PPTX
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
PPTX
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PPTX
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
PDF
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
Finding Your License Details in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
Coefficient of Variance in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
Ad

Javascript & SQL within database management system

  • 1. Javascript & SQL within database management system
  • 3. Clusterpoint — Building and Growing Database-as-a-Service : A Case Study Clusterpoint database 2-in-1: DBaaS & on-premises database Document oriented Sharded + replicated Schema less ACID transactions Cloud enabled (EU & US sites) Clusterpoint — Building and Growing Database-as-a-Service : A Case Study
  • 4. Clusterpoint — Building and Growing Database-as-a-Service : A Case Study Evolution of Computing Infrastructure History Clusterpoint — Building and Growing Database-as-a-Service : A Case Study 1970 1995 2010 20152005 Google discovers that all of web does not fit in a relational database Jeff Dean, Sanjay Ghemaway et al publish papers on MapReduce and BigTable Key-Value Store MapReduce Mainframes Clusters of Commodity Hardware Commercially Viable Technologies are split between: data storage and computing will they merge ?
  • 5. Clusterpoint — Building and Growing Database-as-a-Service : A Case StudyClusterpoint — Building and Growing Database-as-a-Service : A Case Study
  • 6. Clusterpoint — Running JavaScript Inside the Database db.runCommand({ mapreduce: "DenormAggCollection", query: { filter1: { '$in': [ 'A', 'B' ] }, filter2: 'C', filter3: { '$gt': 123 } }, map: function() { emit( { d1: this.Dim1, d2: this.Dim2 }, { msum: this.measure1, recs: 1, mmin: this.measure1, mmax: this.measure2 < 100 ? this.measure2 : 0 } );}, reduce: function(key, vals) { var ret = { msum: 0, recs: 0, mmin: 0, mmax: 0 }; for(var i = 0; i < vals.length; i++) { ret.msum += vals[i].msum; ret.recs += vals[i].recs; if(vals[i].mmin < ret.mmin) ret.mmin = vals[i].mmin; if((vals[i].mmax < 100) && (vals[i].mmax > ret.mmax)) ret.mmax = vals[i].mmax; } return ret; }, finalize: function(key, val) { val.mavg = val.msum / val.recs; return val; }, out: 'result1', verbose: true }); db.result1. find({ mmin: { '$gt': 0 } }). sort({ recs: -1 }). skip(4). limit(8); SELECT Dim1, Dim2, SUM(Measure1) AS MSum, COUNT(*) AS RecordCount, AVG(Measure2) AS MAvg, MIN(Measure1) AS MMin MAX(CASE WHEN Measure2 < 100 THEN Measure2 END) AS MMax FROM DenormAggTable WHERE (Filter1 IN (’A’,’B’)) AND (Filter2 = ‘C’) AND (Filter3 > 123) GROUP BY Dim1, Dim2 HAVING (MMin > 0) ORDER BY RecordCount DESC LIMIT 4, 8 1 2 3 4 5 1 7 6 1 2 3 4 5 Grouped dimension columns are pulled out as keys in the map function, reducing the size of the working set. Measures must be manually aggregated. Aggregates depending on record counts must wait until finalization. Measures can use procedural logic. Filters have an ORM/ActiveRecord- looking style. 6 Aggregate filtering must be applied to the result set, not in the map/reduce. 7 Ascending: 1; Descending: -1 Revision4,Created2010-03-06 RickOsborne,rickosborne.org mySQL MongoDB
  • 7. Clusterpoint — Building and Growing Database-as-a-Service : A Case Study +
  • 8. Clusterpoint — Building and Growing Database-as-a-Service : A Case Study Technology top 2015 (StackOverflow) Clusterpoint — Building and Growing Database-as-a-Service : A Case Study
  • 9. Clusterpoint — Running JavaScript Inside the Database SQL JavaScript flexible to express queries executes in parallel static hard to define expressions bad with custom routines hard to express queries difficult to execute in parallel dynamic easy to define expressions great with custom routines
  • 10. Clusterpoint — Running JavaScript Inside the Database Javascript - V8 Too good to be used only in browsers Clusterpoint — Running JavaScript Inside the Database • Chrome • Node.js • MongoDB • Google BigQuery UDF
  • 11. Clusterpoint — Running JavaScript Inside the Database Javascript - V8 Produces machine code (IA-32, x64, ARM) Clusterpoint — Running JavaScript Inside the Database
  • 12. Clusterpoint — Running JavaScript Inside the Database Javascript - V8 Performance - Problem Clusterpoint — Running JavaScript Inside the Database Compute the 25,000th prime
  • 13. Clusterpoint — Running JavaScript Inside the Database Javascript - V8 Performance - Algorithm Clusterpoint — Running JavaScript Inside the Database For x = 1 to infinity: if x not divisible by any member of an initially empty list of primes, add x to the list until we have 25,000
  • 14. Clusterpoint — Running JavaScript Inside the Database Javascript - V8 Performance - Contenders Clusterpoint — Running JavaScript Inside the Database
  • 15. Clusterpoint — Running JavaScript Inside the Database Javascript - V8 Performance - Results (only 17% slower) Clusterpoint — Running JavaScript Inside the Database
  • 16. Javascript - V8 Data Binding Clusterpoint — Running JavaScript Inside the Database C++ callback V8 if (name == “John”) { return “Male”; } Accessor
 (C++ callback) string * get_value(string &field_name) { if (field_name == “name”) return new string(“John”); else return new string(“Unknown”); }
  • 17. Clusterpoint — Building and Growing Database-as-a-Service : A Case Study JS/SQL Language structure SQL-like structure Arbitrary JavaScript in any clause of the SELECT or UPDATE statement. Joins, indexing nested documents + Clusterpoint — Building and Growing Database-as-a-Service : A Case Study
  • 18. SELECT * FROM product +Clusterpoint — Building and Growing Database-as-a-Service : A Case Study
  • 19. JS/SQL Insert statement INSERT INTO product JSON VALUE { "name": "Schwinn S29 Full Suspension Mountain Bike", "image_url": "schwinn_s29.jpeg", "description": "...", "color": ["black","red"], "order_price": 211.16, "price": 259.16, "packaging": { "height": 23, "width": 25, "depth": 12, "weight": 54 }, "availability": "In Stock" } +Clusterpoint — Building and Growing Database-as-a-Service : A Case Study
  • 20. JS/SQL Update statement Clusterpoint — Running JavaScript Inside the Database + UPDATE product[“id_123”] SET { color.push_back(“orange”); packaging.volume = packaging.height * packaging.width * packaging.depth; }
  • 21. JS/SQL Price buckets +Clusterpoint — Building and Growing Database-as-a-Service : A Case Study
  • 22. JS/SQL Grouping/Aggregation function PriceBucket(price) { var boundaries = [0, 1, 5, 10, 50, 100, 200, 500, 1000]; for (var i = 1; i < boundaries.length; i++) { if (price >= boundaries[i - 1] && price < boundaries[i]) return boundaries[i - 1].toString() + " to " + boundaries[i].toString(); } return "above " + boundaries[boundaries.length - 1].toString(); } SELECT PriceBucket(price), COUNT() FROM product GROUP BY PriceBucket(price); +Clusterpoint — Building and Growing Database-as-a-Service : A Case Study
  • 23. JS/SQL Javascript & SQL in action SELECT PriceBucket(price), COUNT() FROM product GROUP BY PriceBucket(price); +Clusterpoint — Building and Growing Database-as-a-Service : A Case Study doc1 John AccessorField (price) store JS V8 …. PriceBucket(price) ….doc2 George doc3 Marry
  • 24. JS/SQL Joins Clusterpoint — Running JavaScript Inside the Database INSERT INTO product["34A40855"] JSON VALUE { name: "Schwinn S29 Full Suspension Mountain Bike", price: 259.16 }; INSERT INTO order JSON VALUE { product_key: "34A40855", delivery_address: "My Office" }; SELECT delivery_address, product[product_key].price FROM order WHERE product[product_key].price > 20 +
  • 25. Sign up Where: http://cloud.clusterpoint.com How Much? “Zero, none” 10GB free FOREVER !!! Any Docs? http://docs.clusterpoint.com Few fields and you are in Clusterpoint — Running JavaScript Inside the Database
  • 26. Clusterpoint — Building and Growing Database-as-a-Service : A Case Study Thank you!