2017-04-07 117 views
0

我有一個表包含cassandra3.10中的8百萬行數據。當我做了如下查詢:select max(glass_id) from poc.dream where time < '2017-04-01 00:00:00+0000' allow filtering; 時間屬性是表的分區鍵,我選擇的數據大小是70百萬。但是我的閱讀表現不好,花了2分鐘纔得到結果。主鍵是PK(time,glass_id);主鍵是PK(time,glass_id);主鍵是PK(time,glass_id)。cassandra讀取性能很差

跟蹤日誌的部分顯示如下:

Preparing statement [Native-Transport-Requests-1] | 2017-04-07 14:58:55.598000 | 172.19.16.44 |   247 | 127.0.0.1 
Computing ranges to query [Native-Transport-Requests-1] | 2017-04-07 14:58:55.599000 | 172.19.16.44 |   771 | 127.0.0.1 
RANGE_SLICE message received from /172.19.16.44 [MessagingService-Incoming-/172.19.16.44] | 2017-04-07 14:58:55.599000 | 172.19.20.89 |    40 | 127.0.0.1 
Submitting range requests on 769 ranges with a concurrency of 1 (0.0 rows per range expected) [Native-Transport-Requests-1] | 2017-04-07 14:58:55.599000 | 172.19.16.44 |   862 | 127.0.0.1 
Enqueuing request to /172.19.20.89 [Native-Transport-Requests-1] | 2017-04-07 14:58:55.599000 | 172.19.16.44 |   881 | 127.0.0.1 
Submitted 1 concurrent range requests [Native-Transport-Requests-1] | 2017-04-07 14:58:55.599000 | 172.19.16.44 |   899 | 127.0.0.1 
Sending RANGE_SLICE message to /172.19.20.89 [MessagingService-Outgoing-/172.19.20.89-Small] | 2017-04-07 14:58:55.599000 | 172.19.16.44 |   937 | 127.0.0.1 
Executing seq scan across 0 sstables for (min(-9223372036854775808), max(-9222003595370030342)] [ReadStage-1] | 2017-04-07 14:58:55.600000 | 172.19.20.89 |   369 | 127.0.0.1 
Read 0 live and 0 tombstone cells [ReadStage-1] | 2017-04-07 14:58:55.600000 | 172.19.20.89 |   517 | 127.0.0.1 
Enqueuing response to /172.19.16.44 [ReadStage-1] | 2017-04-07 14:58:55.600000 | 172.19.20.89 |   575 | 127.0.0.1 
Sending REQUEST_RESPONSE message to /172.19.16.44 [MessagingService-Outgoing-/172.19.16.44-Small] | 2017-04-07 14:58:55.600000 | 172.19.20.89 |   977 | 127.0.0.1 
REQUEST_RESPONSE message received from /172.19.20.89 [MessagingService-Incoming-/172.19.20.89] | 2017-04-07 14:58:55.601000 | 172.19.16.44 |   3018 | 127.0.0.1 
Processing response from /172.19.20.89 [RequestResponseStage-2] | 2017-04-07 14:58:55.601000 | 172.19.16.44 |   3090 | 127.0.0.1 
Enqueuing request to /172.19.20.5 [Native-Transport-Requests-1] | 2017-04-07 14:58:55.601000 | 172.19.16.44 |   3168 | 127.0.0.1 
Enqueuing request to /172.19.20.5 [Native-Transport-Requests-1] | 2017-04-07 14:58:55.601000 | 172.19.16.44 |   3198 | 127.0.0.1 
Enqueuing request to /172.19.20.89 [Native-Transport-Requests-1] | 2017-04-07 14:58:55.601000 | 172.19.16.44 || 127.0.0.1 
Sending RANGE_SLICE message to /172.19.20.5 [MessagingService-Outgoing-/172.19.20.5-Small] | 2017-04-07 14:58:55.601000 | 172.19.16.44 || 127.0.0.1 
Enqueuing request to /172.19.20.5 [Native-Transport-Requests-1] | 2017-04-07 14:58:55.601001 | 172.19.16.44 |   3222 | 127.0.0.1 
Enqueuing request to /172.19.20.89 [Native-Transport-Requests-1] | 2017-04-07 14:58:55.601001 | 172.19.16.44 |   3230 | 127.0.0.1 
Sending RANGE_SLICE message to /172.19.20.89 [MessagingService-Outgoing-/172.19.20.89-Small] | 2017-04-07 14:58:55.601001 | 172.19.16.44 |   3232 | 127.0.0.1 
Enqueuing request to /172.19.20.89 [Native-Transport-Requests-1] | 2017-04-07 14:58:55.601001 | 172.19.16.44 |   3240 | 127.0.0.1 
Sending RANGE_SLICE message to /172.19.20.5 [MessagingService-Outgoing-/172.19.20.5-Small] | 2017-04-07 14:58:55.601001 | 172.19.16.44 |   3247 | 127.0.0.1 
Enqueuing request to /172.19.20.5 [Native-Transport-Requests-1] | 2017-04-07 14:58:55.601001 | 172.19.16.44 |   3249 | 127.0.0.1 
Enqueuing request to /172.19.20.89 [Native-Transport-Requests-1] | 2017-04-07 14:58:55.601001 | 172.19.16.44 |   3257 | 127.0.0.1 
Enqueuing request to /172.19.20.5 [Native-Transport-Requests-1] | 2017-04-07 14:58:55.601001 | 172.19.16.44 |   3264 | 127.0.0.1 
Sending RANGE_SLICE message to /172.19.20.5 [MessagingService-Outgoing-/172.19.20.5-Small] | 2017-04-07 14:58:55.601002 | 172.19.16.44 |   3267 | 127.0.0.1 
Executing seq scan across 0 sstables for (max(-9153807552532774465), max(-9087147317664915466)] [ReadStage-2] | 2017-04-07 14:58:55.601002 | 172.19.16.44 |   3273 | 127.0.0.1 
Enqueuing request to /172.19.20.89 [Native-Transport-Requests-1] | 2017-04-07 14:58:55.601002 | 172.19.16.44 |   3273 | 127.0.0.1 
Sending RANGE_SLICE message to /172.19.20.89 [MessagingService-Outgoing-/172.19.20.89-Small] | 2017-04-07 14:58:55.601002 | 172.19.16.44 |   3274 | 127.0.0.1 
Enqueuing request to /172.19.20.89 [Native-Transport-Requests-1] | 2017-04-07 14:58:55.601002 | 172.19.16.44 |   3285 | 127.0.0.1 
Executing seq scan across 0 sstables for (max(-9072913252686483927), max(-9071905664525634895)] [ReadStage-4] | 2017-04-07 14:58:55.601002 | 172.19.16.44 |   3284 | 127.0.0.1 
Sending RANGE_SLICE message to /172.19.20.5 [MessagingService-Outgoing-/172.19.20.5-Small] | 2017-04-07 14:58:55.601002 | 172.19.16.44 |   3290 | 127.0.0.1 
Enqueuing request to /172.19.20.89 [Native-Transport-Requests-1] | 2017-04-07 14:58:55.601002 | 172.19.16.44 |   3294 | 127.0.0.1 
Sending RANGE_SLICE message to /172.19.20.89 [MessagingService-Outgoing-/172.19.20.89-Small] | 2017-04-07 14:58:55.601002 | 172.19.16.44 |   3296 | 127.0.0.1 
Enqueuing request to /172.19.20.89 [Native-Transport-Requests-1] | 2017-04-07 14:58:55.601002 | 172.19.16.44 |   3304 | 127.0.0.1 
Sending RANGE_SLICE message to /172.19.20.5 [MessagingService-Outgoing-/172.19.20.5-Small] | 2017-04-07 14:58:55.601002 | 172.19.16.44 |   3307 | 127.0.0.1 
Enqueuing request to /172.19.20.89 [Native-Transport-Requests-1] | 2017-04-07 14:58:55.601002 | 172.19.16.44 |   3313 | 127.0.0.1 
Sending RANGE_SLICE message to /172.19.20.89 [MessagingService-Outgoing-/172.19.20.89-Small] | 2017-04-07 14:58:55.601003 | 172.19.16.44 |   3319 | 127.0.0.1 
Enqueuing request to /172.19.20.5 [Native-Transport-Requests-1] | 2017-04-07 14:58:55.601003 | 172.19.16.44 |   3321 | 127.0.0.1 
Read 0 live and 0 tombstone cells [ReadStage-4] | 2017-04-07 14:58:55.601003 | 172.19.16.44 |   3323 | 127.0.0.1 
Read 0 live and 0 tombstone cells [ReadStage-2] | 2017-04-07 14:58:55.601003 | 172.19.16.44 |   3323 | 127.0.0.1 
+0

在問題 –

回答

2

你是做兩件事情錯在一個單一的查詢。

第一條:您正在使用聚合方法max(),該掃描所有的行(對於您的情況下,7000萬行)剛:所以卡桑德拉需要對每個節點執行查詢

其次您還沒有指定分區鍵給你最大的數字。

而不是使用這樣的查詢,更改您的數據模型,以便您可以指定分區鍵並指定glass_id作爲按desc聚類鍵順序。

+0

中添加您的表架構感謝您的幫助。但實際上,到目前爲止,分區鍵是'時間',聚類鍵是'glass_id'。目標是得到glass_id的最大值。 –

+0

你應該改變你的數據模型 –