SlideShare a Scribd company logo
1 of 20
Download to read offline
The State of CQL

Sylvain Lebresne (DataStax)
A short CQL primer
New in Cassandra 2.0
Native protocol
What's next?

2/20
A better API for Cassandra
Thrift is not satisfactory:

· Not user friendly, hard to use.
· Low level, very little abstraction.
· Hard to evolve (in a backward compatible way).
· Unreadable without driver abstraction.
Cassandra has often been regarded as hard to develop against.
It doesn't have to be that way!

3/20
Quick historical notes
· CQL1 first introduced in Cassandra 0.8, became CQL2 in Cassandra 1.0
· "These aren't the CQL you are looking for"
· CQL3 (CQL for short thereafter) introduced in Cassandra 1.2
· Semantically, CQL1/CQL2 are closer to the Thrift API than to CQL3.
· CQL3 is the version that's here to stay: no plan for a CQL4 any time soon.

4/20
A short CQL primer
The Cassandra Query Language
· Syntactically, a subset of SQL (with a few extensions)
CET TBEues(
RAE AL sr
ue_dui,
sri ud
nm tx,
ae et
pswr tx,
asod et
ealtx,
mi et
pcuepoiebo,
itr_rfl lb
PIAYKY(sri)
RMR E ue_d
)

· INSERT and UPDATE are both upserts
· No joins, no sub-queries, no aggregation, ...
· Denormalization is the norm: do the work at write time, not read time
6/20

CL
Q
Denormalization: Cassandra modeling 101
Efficient queries in Cassandra are based on 2 principles:

· the data queried is collocated on one replica set
· the data queried is collocated on disk on those replicas
Denormalization is the technique that allows to achieve this in practice.
But this means CQL exposes:

· how to collocate data on the same replica set
· how to collocate data on disk (for a given replica)

7/20
This is done in CQL through the primary key
CET TBEibxs(
RAE AL noe

CL
Q

ue_dui,
sri ud
eali tmui,
mi_d ieud
sne tx,
edr et
rcpet sttx>
eiins e<et,
sbettx,
ujc et
i_edboen
sra ola,
P I A Y K Y (u e _ d, e a l i
RMR E
sri
m i _ d)
)

CQL distinguishes 2 sub-parts in the PRIMARY KEY:
partition key: decides the node on which the data is stored
clustering columns: within the same partition key, (CQL3) rows are
physically ordered following the clustering columns

·
·

This is important, because CQL only allow queries for which an explicit index
exists:
- Gtls 5 eal i ue 5b2-b ibx
- e at 0 mis n sr 1-3a8 no
8/20

SLC *FO ibxsWEEue_d5b2-b ODRB eali DS LMT5;
EET
RM noe HR sri=1-3a8 RE Y mi_d EC II 0

CL
Q
CQL main features

· Collections (set, map and list)
· Secondary indexes
· Convenience functions (timeuuid, type conversions, ...)
· ...
For more details:

· http://cassandra.apache.org/doc/cql3/CQL.html
· http://www.datastax.com/documentation/cql/3.1/webhelp/index.html

9/20
New in Cassandra 2.0
New in Cassandra 2.0
Lightweight transactions:
ISR IT ts (d nm)VLE (2 'o' I NTEIT;
NET NO et i, ae AUS 4, Tm) F O XSS

CL
Q

UDT ts STpswr=nwas WEEi=2I pswr=odas;
PAE et E asod'eps' HR d4 F asod'lps'

Triggers:
CET TIGRmTigrO ts UIG'ytigrCas;
RAE RGE yrge N et SN m.rge.ls'

CL
Q

ALTER DROP:
CET TBEts ( itPIAYKY po1it po2tx,po3fot;
RAE AL et k n RMR E, rp n, rp et rp la)

CL
Q

ATRTBEts DO po3
LE AL et RP rp;

Preparing TIMESTAMP, TTL and LIMIT:
SLC *FO mTbeLMT?
EET
RM yal II ;
UDT mTbeUIGTL?STv=2WEEk='o'
PAE yal SN T
E
HR
fo;

11/20

CL
Q
New in Cassandra 2.0
Conditional DDL:
CET TBEI NTEIT ts ( itPIAYKY;
RAE AL F O XSS et k n RMR E)

CL
Q

DO KYPC I EIT k;
RP ESAE F XSS s

Secondary indexes everywhere (almost):
CET TBEtmln (
RAE AL ieie

CL
Q

eeti ui,
vn_d ud
cetda tmui,
rae_t ieud
cnetbo,
otn lb
PIAYKY(vn_d cetda)
RMR E eeti, rae_t
)
;
CET IDXO tmln (rae_t;
RAE NE N ieie cetda)

SELECT aliases:
SLC eeti,
EET vn_d
dtO(rae_t A ceto_ae
aefcetda) S raindt,
12/20

FO tmln;
RM ieie

CL
Q
Coming in Cassandra 2.0.2
Named bind variables:
L
S L C * F O t m l n W E E c e t d a > : l w A D c e t d a < : h g A D k y = Q;
EET
RM ieie HR rae_t
t o N r a e _ t = t i h N e Ck
:

Prepared IN:
SLC *FO uesWEEue_dI ?
EET
RM sr HR sri N ;

CL
Q

Limited SELECT DISTINCT:
CET TBEts (
RAE AL et
eeti it
vn_d n,
cetda tmsap
rae_t ietm,
cnetbo,
otn lb
PIAYKY(vn_d cetda)
RMR E eeti, rae_t
)
;
SLC DSIC eeti FO ts;
EET ITNT vn_d RM et

13/20

CL
Q
The native protocol
A binary transport protocol for CQL
Native protocol
· Binary transport protocol for CQL
· Query execution, prepared statements, authentication, compression, ...
· Asynchronous (allows multiple concurrent queries per connection)
· Server notifications (Only generic cluster events currently)
· Existing drivers for Java, C#, Python, C++, Golang, ...
Example usage of the Java driver (https://github.com/datastax/java-driver):
Cutrcutr=Cutrbidr)adotcPit"2...".ul(;
lse lse
lse.ule(.dCnaton(17001)bid)
Ssinssin=cutrcnet"yesae)
eso eso
lse.onc(mKypc";
fr(o rw:ssineeue"EET*FO mTbe)
o Rw o
eso.xct(SLC
RM yal")
/ D smtig..
/ o oehn .

15/20

JV
AA
New in Cassandra 2.0: native protocol 2
Cursors:
fr(o rw:ssineeue"EET*FO mTbe)
o Rw o
eso.xct(SLC
RM yal")

JV
AA

/ D smtig..
/ o oehn .

Batching prepared statements:
P e a e S a e e t p = s s i n p e a e " N E T I T m T b e ( 1 p ) V L E ( , ?A ;
rprdttmn s
eso.rpr(ISR NO yal p, 1 AUS ? J V
))
"A
Bthttmn b =nwBthttmn(;
acSaeet s
e acSaeet)
b.d(sbn(,"1);
sadp.id0 v")
b.d(sbn(,"2);
sadp.id1 v")
b.d(sbn(,"3);
sadp.id2 v")
ssineeueb)
eso.xct(s;

One-shot prepare and execute:
s s i n e e u e " N E T I T u e s ( d p o o V L E ( , ? " s m I , p o o y eJ V
e s o . x c t ( I S R N O s r i , h t ) A U S ? ) , o e d h t B t sA A
)
;

SASL for authentication

16/20
What's next?
Cassandra 2.1 and beyond
CQL: some ideas
· Storage engine optimizations for CQL
· Secondary index for collections
· Server side functions
· User defined types
· ...

18/20
User defined types
CET TP ades(
RAE YE drs
sre tx,
tet et
zpcd it
i_oe n,
saetx,
tt et
poe sttx>
hns e<et
)
;
CET TBEues(
RAE AL sr
i ui PIAYKY
d ud RMR E,
nm tx,
ae et
adessmptx,ades
drse a<et drs>
)
;
ISR IT ues(d nm)VLE (3-a71 "yvi Lben";
NET NO sr i, ae AUS 244-6, Slan erse)
UDT uesSTadess"ok]={
PAE sr E drse[wr"
sre:'7 Mrnr Iln Bv #1'
tet 77 aies sad ld 50,
zpcd:944
i_oe 40,
sae 'A,
tt: C'
19/20

poe:{603960 }
hns
5-8-00
}WEEi =244-6;
HR d
3-a71

CL
Q
Thank You!
(Questions?)

More Related Content

Similar to Cassandra EU - State of CQL

Improving Software Reliability via Mining Software Engineering Data
Improving Software Reliability via Mining Software Engineering DataImproving Software Reliability via Mining Software Engineering Data
Improving Software Reliability via Mining Software Engineering DataTao Xie
 
Embedded JavaScript
Embedded JavaScriptEmbedded JavaScript
Embedded JavaScriptJens Siebert
 
Code GPU with CUDA - Identifying performance limiters
Code GPU with CUDA - Identifying performance limitersCode GPU with CUDA - Identifying performance limiters
Code GPU with CUDA - Identifying performance limitersMarina Kolpakova
 
224698998 moshell-commands
224698998 moshell-commands224698998 moshell-commands
224698998 moshell-commandsAchmad Salsabil
 
Constructing Distributed Doubly Linked Lists without Distributed Locking
Constructing Distributed Doubly Linked Lists without Distributed LockingConstructing Distributed Doubly Linked Lists without Distributed Locking
Constructing Distributed Doubly Linked Lists without Distributed LockingKota Abe
 
QR Factorizations and SVDs for Tall-and-skinny Matrices in MapReduce Architec...
QR Factorizations and SVDs for Tall-and-skinny Matrices in MapReduce Architec...QR Factorizations and SVDs for Tall-and-skinny Matrices in MapReduce Architec...
QR Factorizations and SVDs for Tall-and-skinny Matrices in MapReduce Architec...Austin Benson
 
Formal Semantics of SQL and Cypher
Formal Semantics of SQL and CypherFormal Semantics of SQL and Cypher
Formal Semantics of SQL and CypheropenCypher
 
Introduction to Compiler Development
Introduction to Compiler DevelopmentIntroduction to Compiler Development
Introduction to Compiler DevelopmentLogan Chien
 
3.ASSEMBLERS.pptx
3.ASSEMBLERS.pptx3.ASSEMBLERS.pptx
3.ASSEMBLERS.pptxGaganaP13
 
Arquillian - extensions which you have to take with you to a deserted island
Arquillian - extensions which you have to take with you to a deserted islandArquillian - extensions which you have to take with you to a deserted island
Arquillian - extensions which you have to take with you to a deserted islandSoftwareMill
 
T-S Fuzzy Observer and Controller of Doubly-Fed Induction Generator
T-S Fuzzy Observer and Controller of Doubly-Fed Induction GeneratorT-S Fuzzy Observer and Controller of Doubly-Fed Induction Generator
T-S Fuzzy Observer and Controller of Doubly-Fed Induction GeneratorIJPEDS-IAES
 
#include LPC17xx.h#include Lights.h#include traffic_fo.docx
#include LPC17xx.h#include Lights.h#include traffic_fo.docx#include LPC17xx.h#include Lights.h#include traffic_fo.docx
#include LPC17xx.h#include Lights.h#include traffic_fo.docxajoy21
 

Similar to Cassandra EU - State of CQL (20)

Wien2k getting started
Wien2k getting startedWien2k getting started
Wien2k getting started
 
Improving Software Reliability via Mining Software Engineering Data
Improving Software Reliability via Mining Software Engineering DataImproving Software Reliability via Mining Software Engineering Data
Improving Software Reliability via Mining Software Engineering Data
 
JavaFX, because you're worth it
JavaFX, because you're worth itJavaFX, because you're worth it
JavaFX, because you're worth it
 
OptimizingARM
OptimizingARMOptimizingARM
OptimizingARM
 
191010 opie2
191010 opie2191010 opie2
191010 opie2
 
Embedded JavaScript
Embedded JavaScriptEmbedded JavaScript
Embedded JavaScript
 
1st and 2nd Semester M Tech: Computer Science and Engineering (Dec-2015; Jan-...
1st and 2nd Semester M Tech: Computer Science and Engineering (Dec-2015; Jan-...1st and 2nd Semester M Tech: Computer Science and Engineering (Dec-2015; Jan-...
1st and 2nd Semester M Tech: Computer Science and Engineering (Dec-2015; Jan-...
 
Code GPU with CUDA - Identifying performance limiters
Code GPU with CUDA - Identifying performance limitersCode GPU with CUDA - Identifying performance limiters
Code GPU with CUDA - Identifying performance limiters
 
224698998 moshell-commands
224698998 moshell-commands224698998 moshell-commands
224698998 moshell-commands
 
Constructing Distributed Doubly Linked Lists without Distributed Locking
Constructing Distributed Doubly Linked Lists without Distributed LockingConstructing Distributed Doubly Linked Lists without Distributed Locking
Constructing Distributed Doubly Linked Lists without Distributed Locking
 
QR Factorizations and SVDs for Tall-and-skinny Matrices in MapReduce Architec...
QR Factorizations and SVDs for Tall-and-skinny Matrices in MapReduce Architec...QR Factorizations and SVDs for Tall-and-skinny Matrices in MapReduce Architec...
QR Factorizations and SVDs for Tall-and-skinny Matrices in MapReduce Architec...
 
Assembler Numerical in system programming
Assembler Numerical in system programmingAssembler Numerical in system programming
Assembler Numerical in system programming
 
Formal Semantics of SQL and Cypher
Formal Semantics of SQL and CypherFormal Semantics of SQL and Cypher
Formal Semantics of SQL and Cypher
 
Introduction to Compiler Development
Introduction to Compiler DevelopmentIntroduction to Compiler Development
Introduction to Compiler Development
 
3.ASSEMBLERS.pptx
3.ASSEMBLERS.pptx3.ASSEMBLERS.pptx
3.ASSEMBLERS.pptx
 
Arquillian - extensions which you have to take with you to a deserted island
Arquillian - extensions which you have to take with you to a deserted islandArquillian - extensions which you have to take with you to a deserted island
Arquillian - extensions which you have to take with you to a deserted island
 
T-S Fuzzy Observer and Controller of Doubly-Fed Induction Generator
T-S Fuzzy Observer and Controller of Doubly-Fed Induction GeneratorT-S Fuzzy Observer and Controller of Doubly-Fed Induction Generator
T-S Fuzzy Observer and Controller of Doubly-Fed Induction Generator
 
#include LPC17xx.h#include Lights.h#include traffic_fo.docx
#include LPC17xx.h#include Lights.h#include traffic_fo.docx#include LPC17xx.h#include Lights.h#include traffic_fo.docx
#include LPC17xx.h#include Lights.h#include traffic_fo.docx
 
An Example MIPS
An Example  MIPSAn Example  MIPS
An Example MIPS
 
NLP@ICLR2019
NLP@ICLR2019NLP@ICLR2019
NLP@ICLR2019
 

More from pcmanus

Webinar Big Data Paris
Webinar Big Data ParisWebinar Big Data Paris
Webinar Big Data Parispcmanus
 
On cassandra's evolution @ Berlin buzzwords
On cassandra's evolution @ Berlin buzzwordsOn cassandra's evolution @ Berlin buzzwords
On cassandra's evolution @ Berlin buzzwordspcmanus
 
Fosdem 2012
Fosdem 2012Fosdem 2012
Fosdem 2012pcmanus
 
33rd degree conference
33rd degree conference33rd degree conference
33rd degree conferencepcmanus
 
On Cassandra Development: Past, Present and Future
On Cassandra Development: Past, Present and FutureOn Cassandra Development: Past, Present and Future
On Cassandra Development: Past, Present and Futurepcmanus
 
Cassandra
CassandraCassandra
Cassandrapcmanus
 

More from pcmanus (6)

Webinar Big Data Paris
Webinar Big Data ParisWebinar Big Data Paris
Webinar Big Data Paris
 
On cassandra's evolution @ Berlin buzzwords
On cassandra's evolution @ Berlin buzzwordsOn cassandra's evolution @ Berlin buzzwords
On cassandra's evolution @ Berlin buzzwords
 
Fosdem 2012
Fosdem 2012Fosdem 2012
Fosdem 2012
 
33rd degree conference
33rd degree conference33rd degree conference
33rd degree conference
 
On Cassandra Development: Past, Present and Future
On Cassandra Development: Past, Present and FutureOn Cassandra Development: Past, Present and Future
On Cassandra Development: Past, Present and Future
 
Cassandra
CassandraCassandra
Cassandra
 

Recently uploaded

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 

Recently uploaded (20)

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 

Cassandra EU - State of CQL

  • 1. The State of CQL Sylvain Lebresne (DataStax)
  • 2. A short CQL primer New in Cassandra 2.0 Native protocol What's next? 2/20
  • 3. A better API for Cassandra Thrift is not satisfactory: · Not user friendly, hard to use. · Low level, very little abstraction. · Hard to evolve (in a backward compatible way). · Unreadable without driver abstraction. Cassandra has often been regarded as hard to develop against. It doesn't have to be that way! 3/20
  • 4. Quick historical notes · CQL1 first introduced in Cassandra 0.8, became CQL2 in Cassandra 1.0 · "These aren't the CQL you are looking for" · CQL3 (CQL for short thereafter) introduced in Cassandra 1.2 · Semantically, CQL1/CQL2 are closer to the Thrift API than to CQL3. · CQL3 is the version that's here to stay: no plan for a CQL4 any time soon. 4/20
  • 5. A short CQL primer
  • 6. The Cassandra Query Language · Syntactically, a subset of SQL (with a few extensions) CET TBEues( RAE AL sr ue_dui, sri ud nm tx, ae et pswr tx, asod et ealtx, mi et pcuepoiebo, itr_rfl lb PIAYKY(sri) RMR E ue_d ) · INSERT and UPDATE are both upserts · No joins, no sub-queries, no aggregation, ... · Denormalization is the norm: do the work at write time, not read time 6/20 CL Q
  • 7. Denormalization: Cassandra modeling 101 Efficient queries in Cassandra are based on 2 principles: · the data queried is collocated on one replica set · the data queried is collocated on disk on those replicas Denormalization is the technique that allows to achieve this in practice. But this means CQL exposes: · how to collocate data on the same replica set · how to collocate data on disk (for a given replica) 7/20
  • 8. This is done in CQL through the primary key CET TBEibxs( RAE AL noe CL Q ue_dui, sri ud eali tmui, mi_d ieud sne tx, edr et rcpet sttx> eiins e<et, sbettx, ujc et i_edboen sra ola, P I A Y K Y (u e _ d, e a l i RMR E sri m i _ d) ) CQL distinguishes 2 sub-parts in the PRIMARY KEY: partition key: decides the node on which the data is stored clustering columns: within the same partition key, (CQL3) rows are physically ordered following the clustering columns · · This is important, because CQL only allow queries for which an explicit index exists: - Gtls 5 eal i ue 5b2-b ibx - e at 0 mis n sr 1-3a8 no 8/20 SLC *FO ibxsWEEue_d5b2-b ODRB eali DS LMT5; EET RM noe HR sri=1-3a8 RE Y mi_d EC II 0 CL Q
  • 9. CQL main features · Collections (set, map and list) · Secondary indexes · Convenience functions (timeuuid, type conversions, ...) · ... For more details: · http://cassandra.apache.org/doc/cql3/CQL.html · http://www.datastax.com/documentation/cql/3.1/webhelp/index.html 9/20
  • 11. New in Cassandra 2.0 Lightweight transactions: ISR IT ts (d nm)VLE (2 'o' I NTEIT; NET NO et i, ae AUS 4, Tm) F O XSS CL Q UDT ts STpswr=nwas WEEi=2I pswr=odas; PAE et E asod'eps' HR d4 F asod'lps' Triggers: CET TIGRmTigrO ts UIG'ytigrCas; RAE RGE yrge N et SN m.rge.ls' CL Q ALTER DROP: CET TBEts ( itPIAYKY po1it po2tx,po3fot; RAE AL et k n RMR E, rp n, rp et rp la) CL Q ATRTBEts DO po3 LE AL et RP rp; Preparing TIMESTAMP, TTL and LIMIT: SLC *FO mTbeLMT? EET RM yal II ; UDT mTbeUIGTL?STv=2WEEk='o' PAE yal SN T E HR fo; 11/20 CL Q
  • 12. New in Cassandra 2.0 Conditional DDL: CET TBEI NTEIT ts ( itPIAYKY; RAE AL F O XSS et k n RMR E) CL Q DO KYPC I EIT k; RP ESAE F XSS s Secondary indexes everywhere (almost): CET TBEtmln ( RAE AL ieie CL Q eeti ui, vn_d ud cetda tmui, rae_t ieud cnetbo, otn lb PIAYKY(vn_d cetda) RMR E eeti, rae_t ) ; CET IDXO tmln (rae_t; RAE NE N ieie cetda) SELECT aliases: SLC eeti, EET vn_d dtO(rae_t A ceto_ae aefcetda) S raindt, 12/20 FO tmln; RM ieie CL Q
  • 13. Coming in Cassandra 2.0.2 Named bind variables: L S L C * F O t m l n W E E c e t d a > : l w A D c e t d a < : h g A D k y = Q; EET RM ieie HR rae_t t o N r a e _ t = t i h N e Ck : Prepared IN: SLC *FO uesWEEue_dI ? EET RM sr HR sri N ; CL Q Limited SELECT DISTINCT: CET TBEts ( RAE AL et eeti it vn_d n, cetda tmsap rae_t ietm, cnetbo, otn lb PIAYKY(vn_d cetda) RMR E eeti, rae_t ) ; SLC DSIC eeti FO ts; EET ITNT vn_d RM et 13/20 CL Q
  • 14. The native protocol A binary transport protocol for CQL
  • 15. Native protocol · Binary transport protocol for CQL · Query execution, prepared statements, authentication, compression, ... · Asynchronous (allows multiple concurrent queries per connection) · Server notifications (Only generic cluster events currently) · Existing drivers for Java, C#, Python, C++, Golang, ... Example usage of the Java driver (https://github.com/datastax/java-driver): Cutrcutr=Cutrbidr)adotcPit"2...".ul(; lse lse lse.ule(.dCnaton(17001)bid) Ssinssin=cutrcnet"yesae) eso eso lse.onc(mKypc"; fr(o rw:ssineeue"EET*FO mTbe) o Rw o eso.xct(SLC RM yal") / D smtig.. / o oehn . 15/20 JV AA
  • 16. New in Cassandra 2.0: native protocol 2 Cursors: fr(o rw:ssineeue"EET*FO mTbe) o Rw o eso.xct(SLC RM yal") JV AA / D smtig.. / o oehn . Batching prepared statements: P e a e S a e e t p = s s i n p e a e " N E T I T m T b e ( 1 p ) V L E ( , ?A ; rprdttmn s eso.rpr(ISR NO yal p, 1 AUS ? J V )) "A Bthttmn b =nwBthttmn(; acSaeet s e acSaeet) b.d(sbn(,"1); sadp.id0 v") b.d(sbn(,"2); sadp.id1 v") b.d(sbn(,"3); sadp.id2 v") ssineeueb) eso.xct(s; One-shot prepare and execute: s s i n e e u e " N E T I T u e s ( d p o o V L E ( , ? " s m I , p o o y eJ V e s o . x c t ( I S R N O s r i , h t ) A U S ? ) , o e d h t B t sA A ) ; SASL for authentication 16/20
  • 18. CQL: some ideas · Storage engine optimizations for CQL · Secondary index for collections · Server side functions · User defined types · ... 18/20
  • 19. User defined types CET TP ades( RAE YE drs sre tx, tet et zpcd it i_oe n, saetx, tt et poe sttx> hns e<et ) ; CET TBEues( RAE AL sr i ui PIAYKY d ud RMR E, nm tx, ae et adessmptx,ades drse a<et drs> ) ; ISR IT ues(d nm)VLE (3-a71 "yvi Lben"; NET NO sr i, ae AUS 244-6, Slan erse) UDT uesSTadess"ok]={ PAE sr E drse[wr" sre:'7 Mrnr Iln Bv #1' tet 77 aies sad ld 50, zpcd:944 i_oe 40, sae 'A, tt: C' 19/20 poe:{603960 } hns 5-8-00 }WEEi =244-6; HR d 3-a71 CL Q