本文介绍了使用 cql 优于节俭的优势的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

相比于 thrift,使用 cql 有什么明显的优势,还是仅仅是开发人员太习惯 SQL 的情况?我想从节俭查询切换到 cql,唯一的问题是我不确定这样做的缺点.它们是什么?

Are there any distinct advantages for using cql over thrift or is it simply a case of developers being too used to SQL? I'm wanting to switch from thrift querying to cql, the only problem is I'm not sure about the downsides of doing so. What are they?

推荐答案

查询
在 CQL 中,您可以查询 cassandra 并在几行中获取数据(使用 JDBC 驱动程序):

Querying
In CQL you can query cassandra and get data in a couple of lines (using JDBC driver):

String query = "SELECT * FROM message;";
PreparedStatement statement = con.prepareStatement(query);

虽然在基于 thrift 的 API 中它有点复杂(以 Astyanax 为例):

While in thrift based API's it's a bit more complicated (example with Astyanax):

OperationResult<ColumnList<String>> result =
     keyspace.prepareQuery(mail/*specify columnfamily structure*/)
             .getKey("lyuben@1363115059").execute();
ColumnList<String> columns = result.getResult();

性能
基于 Acunu、Thrift (RPC) 在查询性能方面略领先于 CQL,但您需要处于高吞吐量是这种性能优势的关键的情况下,才能获得显着优势.

Performance
Based on the benchmarks carried out by Acunu, Thrift (RPC) is slightly ahead of CQL when it comes to query performance, but you need to be in a situation where high throughput is key for this performance advantage to have a significant benefit.

一些值得查找的优秀文章是:

Some excellent articles to lookup are:

编辑

上述基准已经过时,paul 提供了关于准备好的语句的新基准.

The above benchmarks are outdated, the paul provided newer benchmarks on prepared statements.

这篇关于使用 cql 优于节俭的优势的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 17:29