Compiled GraphQL as aDatabase Query Language
Predrag Gruevski
Kensho Knowledge Graph
“Current CEOs of French banks that earned€1+/share last quarter?”
Kensho Knowledge Graph
“Current CEOs of French banks that earned€1+/share last quarter?”
Graph Database
Relational Databases
Timeseries Database
Under the hood:
Approach that does not scale
“Current CEOs of French banks thatearned€1+/share last quarter?”
Graph Database
Relational Databases
Timeseries Database
Product engineerwrites queries forall database backends
An ideal solution
“Current CEOs of French banks thatearned€1+/share last quarter?”
Graph Database
Relational Databases
Timeseries Database
Universal query layer
graphdatabasequery
SQLquery
timeseriesquery
Domain ofproduct engineer
Domain ofinfrastructureengineer
declarative query
GraphQL to the rescue? Not quite.
GraphQL can consolidate all data into a single schema,but its resolvers causeawfulperformance.
Backend
Backing databases
Time
FindFrance
Find allcompaniesin France
Are theybanks?
… 10^N round-trips later …
Get theircurrent CEOs
😴
Compile GraphQL to single database queries
GraphQL compiler
Graph Database
Relational Database
Timeseries Database
GraphQLquery
graphdatabasequery
SQLquery
timeseriesquery
Why this works well
Product engineers focus onbusiness logicDatabase-agnostic: switching MySQL => Postgres has no visible impactFully declarative: ignorant of indexes, data sizes, join order…Infrastructure engineers handleunderlyingimplementationFree to choose the best database for the jobCompiler ensures workarounds for database bugs are always in placeCompiler ensures proper semantics in tricky situations:optional edges followed by required edges (outer join then inner join)recursive edge traversals (recursive joins)
Why this works well
Product engineers focus onbusiness logicDatabase-agnostic: switching MySQL => Postgres has no visible impactFully declarative: ignorant of indexes, data sizes, join order…Infrastructure engineers handleunderlyingimplementationFree to choose the best database for the jobCompiler ensures workarounds for database bugs are always in placeCompiler ensures proper semantics in tricky situations:optional edges followed by required edges (outer join then inner join)recursive edge traversals (recursive joins)
0
Embed
Upload