我在插入一行时有一个rpc_timeout(集群有3个节点,在另一个表上可以处理超过10000次插入/分钟)
这是表格:
CREATE TABLE test_table (
agent text,
run_id text,
process_id text,
datetime timestamp,
tracking_time timestamp,
email text,
ip text,
event_id uuid,
event_name text,
message_id text,
source text,
url text,
test_table text,
PRIMARY KEY ((process_id, event_name), event_id));
CREATE INDEX test_table_process_id ON test_table (process_id);
这是插页:
BEGIN BATCH
INSERT INTO test_table (message_id, run_id, event_id, ip, process_id, agent, datetime, event_name, url, test_table, email, tracking_time) VALUES ('exampleaaaaaaaaaaaaaaaaaaaaaaaaa', 'bar', 376d8e20-35ca-4615-8e9f-f0b5b4431981, 'None', 'test-dummy', 'None', '2014-08-31 17:20:24', 'hard_bounce', 'None', 'mandrill', 'example.webhook@mandrillapp.com', '2014-09-01T18:04:40');
APPLY BATCH;
我不知道超时是否是由于二级索引造成的。
system.log 中没有任何错误
可能会从批处理中超时,2i没有太多开销,但事务有。请尝试使用未标记的批处理。
BEGIN UNLOGGED
INSERT INTO test_table (message_id, run_id, event_id, ip, process_id, agent, datetime, event_name, url, test_table, email, tracking_time) VALUES ('exampleaaaaaaaaaaaaaaaaaaaaaaaaa', 'bar', 376d8e20-35ca-4615-8e9f-f0b5b4431981, 'None', 'test-dummy', 'None', '2014-08-31 17:20:24', 'hard_bounce', 'None', 'mandrill', 'example.webhook@mandrillapp.com', '2014-09-01T18:04:40');
APPLY BATCH;
除非有很好的理由,否则使用单独的写入而不是批处理——这更具性能。