这是模型,使用 Cassandra 2.0、CQL 3 和只有一个节点:
CREATE TABLE purchase (
row_id timeuuid,
date text,
domain_id text,
item_id text,
product_id text,
purchase_id text,
stream_id text,
PRIMARY KEY (row_id)
) WITH
bloom_filter_fp_chance=0.010000 AND
caching='KEYS_ONLY' AND
comment='' AND
dclocal_read_repair_chance=0.000000 AND
gc_grace_seconds=864000 AND
index_interval=128 AND
read_repair_chance=0.100000 AND
replicate_on_write='true' AND
populate_io_cache_on_flush='false' AND
default_time_to_live=0 AND
speculative_retry='99.0PERCENTILE' AND
memtable_flush_period_in_ms=0 AND
compaction={'class': 'SizeTieredCompactionStrategy'} AND
compression={'sstable_compression': 'LZ4Compressor'};
CREATE INDEX purchase_date ON purchase (date);
CREATE INDEX purchase_domain ON purchase (domain_id);
domain_id的所有值都相同,因此在此字段上查询时应该没有问题。但我有这个:
cqlsh:mykeyspace> select count(*) from purchase limit 1000000;
count
--------
114292
所以这不是一个沉重的桌子,而是:
cqlsh:mykeyspace> select * from purchase where domain_id = 'test' limit 5;
row_id | date | domain_id | item_id | product_id | purchase_id | stream_id
--------------------------------------+------------+-----------+-----------+------------+-------------+-----------
090006e0-788f-11e3-a0c1-6142bbb646b5 | 2014-01-01 | test | 254386500 | 6567576457 | 7654546343 | purchase
eb6300b0-788e-11e3-a0c1-6142bbb646b5 | 2014-01-01 | test | 254386500 | 6567576457 | 7654546343 | purchase
fc268980-788e-11e3-a0c1-6142bbb646b5 | 2014-01-01 | test | 254386500 | 6567576457 | 7654546343 | purchase
1fdefe40-7888-11e3-a0c1-6142bbb646b5 | 2014-01-01 | test | 254386500 | 6567576457 | 7654546343 | purchase
f7cc3010-788e-11e3-a0c1-6142bbb646b5 | 2014-01-01 | test | 254386500 | 6567576457 | 7654546343 | purchase
cqlsh:mykeyspace> select count(*) from purchase where domain_id = 'test' limit 1000;
count
-------
1000
cqlsh:mykeyspace> select count(*) from purchase where domain_id = 'test' limit 10000;
Request did not complete within rpc_timeout.
看起来模型是正确的,所以我想知道我做错了什么。
您是否尝试过重建索引并使用rebuild_index nodetool命令完成一次尝试?