不同查询上的Cassandra性能
在Cassandra中,我读到我需要设计我的表模式,以便达到分区的最小数量。我已经设计了模式来满足这个需求。但我的情况是,我需要单独获取所有分区键。所以我计划使用不同查询上的Cassandra性能,cassandra,cqlsh,spark-cassandra-connector,Cassandra,Cqlsh,Spark Cassandra Connector,在Cassandra中,我读到我需要设计我的表模式,以便达到分区的最小数量。我已经设计了模式来满足这个需求。但我的情况是,我需要单独获取所有分区键。所以我计划使用 选择与表格不同的选项 我使用cqlsh对大约15k行运行了一个独特的查询,速度相当快 问题 如果我使用distinct,是否会出现性能问题 cassandra如何单独获取分区密钥 我需要知道不同查询的限制 如果我使用distinct,是否会出现性能问题?cassandra如何单独获取分区密钥 基本上,Cassandra只需撕开节点并收
选择与表格不同的选项
我使用cqlsh对大约15k行运行了一个独特的查询,速度相当快
问题
cassandra cli
工具查看数据,可以看到分区键的处理方式有所不同。下面是一个示例,其中船上的船员按船存储在一个表中
aploetz@cqlsh:presentation> SELECT * FROm shipcrewregistry ;
shipname | lastname | firstname | citizenid | aliases
----------+-----------+-----------+--------------------------------------+--------------------------------------
Serenity | Book | Derial | 48bc975a-c9f2-474d-8a29-247503445877 | {'CLASSIFIED'}
Serenity | Cobb | Jayne | 2d643fb1-54fb-4c98-8d2d-a5bb9c6c8354 | {'Hero of Canton'}
Serenity | Frye | Kaylee | d556cf44-348b-4ea3-8c19-ba9d4877818c | null
Serenity | Inara | Serra | a25b7e02-8099-401a-8c41-d9d2ea894b72 | null
Serenity | Reynolds | Malcolm | 169382b7-21b0-47bf-b1c8-19bc008a9060 | {'Mal', 'Sgt. Reynolds'}
Serenity | Tam | River | af68201f-4135-413e-959c-dd81ea651e52 | null
Serenity | Tam | Simon | aa090e1a-7792-4d7b-bba9-bac66f8c1f15 | {'Dr. Tam'}
Serenity | Washburne | Hoban | 73f591df-c0dc-44c4-b3f3-9c37453c9537 | {'Wash'}
Serenity | Washburne | Zoey | 46bc77ad-53ad-4402-b252-a0543005c583 | {'Corporal Alleyne', 'Zoey Alleyne'}
(9 rows)
但是当我在cassandra cli中查询时
:
[default@presentation] list shipcrewregistry;
Using default limit of 100
Using default cell limit of 100
-------------------
RowKey: Serenity
=> (name=Book:Derial:48bc975a-c9f2-474d-8a29-247503445877:, value=, timestamp=1424904853420170)
=> (name=Book:Derial:48bc975a-c9f2-474d-8a29-247503445877:aliases:434c4153534946494544, value=, timestamp=1424904853420170)
=> (name=Cobb:Jayne:2d643fb1-54fb-4c98-8d2d-a5bb9c6c8354:, value=, timestamp=1424904853492976)
=> (name=Cobb:Jayne:2d643fb1-54fb-4c98-8d2d-a5bb9c6c8354:aliases:4865726f206f662043616e746f6e, value=, timestamp=1424904853492976)
=> (name=Frye:Kaylee:d556cf44-348b-4ea3-8c19-ba9d4877818c:, value=, timestamp=1428442425610395)
=> (name=Inara:Serra:a25b7e02-8099-401a-8c41-d9d2ea894b72:, value=, timestamp=1428442425621555)
=> (name=Reynolds:Malcolm:169382b7-21b0-47bf-b1c8-19bc008a9060:, value=, timestamp=1424904853505461)
=> (name=Reynolds:Malcolm:169382b7-21b0-47bf-b1c8-19bc008a9060:aliases:4d616c, value=, timestamp=1424904853505461)
=> (name=Reynolds:Malcolm:169382b7-21b0-47bf-b1c8-19bc008a9060:aliases:5367742e205265796e6f6c6473, value=, timestamp=1424904853505461)
=> (name=Tam:River:af68201f-4135-413e-959c-dd81ea651e52:, value=, timestamp=1428442425575881)
=> (name=Tam:Simon:aa090e1a-7792-4d7b-bba9-bac66f8c1f15:, value=, timestamp=1424904853518092)
=> (name=Tam:Simon:aa090e1a-7792-4d7b-bba9-bac66f8c1f15:aliases:44722e2054616d, value=, timestamp=1424904853518092)
=> (name=Washburne:Hoban:73f591df-c0dc-44c4-b3f3-9c37453c9537:, value=, timestamp=1428442425587484)
=> (name=Washburne:Hoban:73f591df-c0dc-44c4-b3f3-9c37453c9537:aliases:57617368, value=, timestamp=1428442425587484)
=> (name=Washburne:Zoey:46bc77ad-53ad-4402-b252-a0543005c583:, value=, timestamp=1428442425596863)
=> (name=Washburne:Zoey:46bc77ad-53ad-4402-b252-a0543005c583:aliases:436f72706f72616c20416c6c65796e65, value=, timestamp=1428442425596863)
=> (name=Washburne:Zoey:46bc77ad-53ad-4402-b252-a0543005c583:aliases:5a6f657920416c6c65796e65, value=, timestamp=1428442425596863)
1 Row Returned.
Elapsed time: 86 msec(s).
这是为了说明9行CQL实际上只是引擎盖下的1行
我需要知道不同查询的限制
在CQL中,
DISTINCT
仅对分区键起作用。我不确定有多少行会否定它的有用性。15000行CQL就可以了。但是如果您有数百万个不同的分区键(高基数),我希望性能会下降……尤其是集群中的几个节点。我不太了解cassandra中实际的行存储。cqlsh中显示的行如何映射到基础cassandra中的实际行?请给我任何好的链接来理解它。@Knight71当然!John Berryman就这个话题写了一篇很棒的文章: