CQL: SQL In Cassandra
Upcoming SlideShare
Loading in...5
×
 

CQL: SQL In Cassandra

on

  • 17,446 views

CQL presentation from Cassandra NYC, December 6, 2011

CQL presentation from Cassandra NYC, December 6, 2011

Statistics

Views

Total Views
17,446
Views on SlideShare
15,605
Embed Views
1,841

Actions

Likes
7
Downloads
142
Comments
1

18 Embeds 1,841

http://nosql.mypopescu.com 1289
http://www.scoop.it 171
http://kaworu.jpn.org 143
http://www.acunu.com 78
http://feeds.feedburner.com 70
https://twitter.com 39
http://www.hanrss.com 15
http://www.newsblur.com 10
http://www.shisoft.net 7
http://a0.twimg.com 6
http://paper.li 4
http://www.weebly.com 2
http://translate.googleusercontent.com 2
http://localhost 1
http://www.twylah.com 1
http://stg.acunu.com 1
http://us-w1.rockmelt.com 1
http://webcache.googleusercontent.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • Brilliant presentation!
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

CQL: SQL In Cassandra CQL: SQL In Cassandra Presentation Transcript

  • CQL: SQL for Cassandra Cassandra NYC December 6, 2011 Eric Evans eric@acunu.com @jericevans, @acunu
  • ● Overview, history, motivation● Performance characteristics● Coming soon (?)● Drivers status
  • What?● Cassandra Query Language ● aka CQL ● aka /ˈsēkwəl/● Exactly like SQL (except where its not)● Introduced in Cassandra 0.8.0● Ready for production use
  • SQL? Almost.–- Inserts or updatesINSERT INTO Standard1 (KEY, col0, col1)VALUES (key, value0, value1) vs.–- Inserts or updatesUPDATE Standard1SET col0=value0, col1=value1 WHERE KEY=key
  • SQL? Almost.–- Get columns for a rowSELECT col0,col1 FROM Standard1 WHERE KEY=key–- Range of columns for a rowSELECT col0..colN FROM Standard1 WHERE KEY=key–- First 10 results from a range of columnsSELECT FIRST 10 col0..colN FROM Standard1 WHERE KEY=key–- Invert the sorting of resultsSELECT REVERSED col0..colN FROM Standard1 WHERE KEY=key
  • Why?
  • Interface Instability
  • (Un)ease of useColumn col = new Column(ByteBuffer.wrap(“name”.getBytes()));col.setValue(ByteBuffer.wrap(“value”.getBytes()));col.setTimestamp(System.currentTimeMillis());ColumnOrSuperColumn cosc = new ColumnOrSuperColumn();cosc.setColumn(col);Mutation mutation = new Mutation();Mutation.setColumnOrSuperColumn(cosc);List mutations = new ArrayList<Mutation>();mutations.add(mutation);Map mutations_map = new HashMap<ByteBuffer, Map<String, List<Mutation>>>();Map cf_map = new HashMap<String, List<Mutation>>();cf_map.set(“Standard1”, mutations);mutations.put(ByteBuffer.wrap(“key”.getBytes()), cf_map)
  • CQLINSERT INTO Standard1 (KEY, col0) VALUES (key, value0)
  • Why? How about...● Better stability guarantees● Easier to use (you already know it)● Better code readability / maintainability
  • Why? How about...● Better stability guarantees● Easier to use (you already know it)● Better code readability / maintainability● Irritates the NoSQL purists
  • Why? How about...● Better stability guarantees● Easier to use (you already know it)● Better code readability / maintainability● Irritates the NoSQL purists● (Still )irritates the SQL purists
  • Performance
  • Thrift RPCColumn col = new Column(ByteBuffer.wrap(“name”.getBytes()));col.setValue(ByteBuffer.wrap(“value”.getBytes()));col.setTimestamp(System.currentTimeMillis());ColumnOrSuperColumn cosc = new ColumnOrSuperColumn();cosc.setColumn(col);Mutation mutation = new Mutation();Mutation.setColumnOrSuperColumn(cosc);List mutations = new ArrayList<Mutation>();mutations.add(mutation);Map mutations_map = new HashMap<ByteBuffer, Map<String, List<Mutation>>>();Map cf_map = new HashMap<String, List<Mutation>>();cf_map.set(“Standard1”, mutations);mutations.put(ByteBuffer.wrap(“key”.getBytes()), cf_map)
  • Your query, its a graph
  • CQLINSERT INTO Standard1 (KEY, col0) VALUES (key, value0)
  • Hotspot Quoted string literalsUPDATE table SET name = value WHERE KEY = somekey
  • Hotspot Quoted string literalsUPDATE table SET name = value WHERE KEY = somekey
  • Hotspot Quoted string literalsUPDATE table SET name = value WHERE KEY = somekey● Anything that appears between quotes● Inlined Java constructs a StringBuilder to store the contents (slow not fast)● Incurred multiple times per statement
  • Hotspot MarshallingUPDATE table SET clear = abffaadd10 WHERE KEY = acfe12ff
  • Hotspot MarshallingUPDATE table SET clear = abffaadd10 WHERE KEY = acfe12ff ascii blob
  • Hotspot MarshallingUPDATE table SET clear = abffaadd10 WHERE KEY = acfe12ff ascii blob● Terms are marshalled to bytes by type● String.getBytes is slow (AsciiType)● Hex conversion is fast faster (BytesType)● Incurred multiple times per statement
  • Hotspot Copying / Conversionexecute_cql_query( ByteBuffer query, enum compression)● Query is binary to support compression (is it worth it?)● And dont forget the String → ByteBuffer conversion on the client-side● Incurred only once per statement!
  • Achtung! (These tests werent perfect)● Uneeded String → ByteBuffer → String● No query compression implemented● Co-located client and server
  • Insert 20M rows, 5 columns Avg rate Avg latency RPC 20,953/s 1.6ms CQL 19,176/s (-8%) 1.7ms (+9%)
  • Insert 10M rows, 5 cols (indexed) Avg rate Avg latency RPC 9,850/s 5.3ms CQL 9,290/s (-6%) 5.5ms (+4%)
  • Counts, 10M rows, 5 cols Avg rate Avg latency RPC 18,052/s 1.7ms CQL 17,635/s (-2%) 1.7ms
  • Reading 20M rows, 5 cols Avg rate Avg latency RPC 22.726/s 2.0ms CQL 20,272/s (-11%) 2.3ms (+10%)
  • In SummaryDont step over dollars to pick up pennies!
  • Coming Soon(ish)
  • Roadmap● Prepared statements (CASSANDRA-2475)● Compound columns (CASSANDRA-2474)● Custom transport / protocol (CASSANDRA-2478)● Performance testing (CASSANDRA-2268)● Schema introspection (CASSANDRA-2477)● Multiget support (CASSANDRA-3069)
  • Drivers
  • Drivers● Hosted on Apache Extras (Google Code)● Tagged cassandra and cql● Licensed using Apache License 2.0● Conforming to a standard for database connectivity (if applicable)● Coming soon, automated testing and acceptance criteria
  • DriversDriver Platform Statuscassandra-jdbc Java Goodcassandra-dbapi2 Python Goodcassandra-ruby Ruby Newcassandra-pdo PHP Newcassandra-node Node.js Goodhttp://code.google.com/a/apache-extras.org/hosting/search?q=label%3aCassandra
  • The End