为什么创建表需要这么长时间?

时间:2016-02-17 11:52:23

标签: cassandra cql cassandra-3.0

我正在创建以下架构:

CREATE TABLE stats_by_site_tracking_hourly (
    d_tally text, -- 2016-02
    d_date timestamp, -- 2016-02-01 13
    site_id int,
    is_new_member int, -- 1/0
    device text, -- desktop/tablet/mobile/unknown
    tracking_medium text,
    tracking_source text,
    tracking_campaign text,
    tracking_term text,
    accepted counter,
    adjusted_accepted counter,
    rejected counter,
    adjusted_rejected counter,
    error counter,
    impressions_positive counter,
    adjusted_impressions_positive counter,
    impressions_negative counter,
    adjusted_impressions_negative counter,
    revenue counter,
    adjusted_revenue counter,
    reversals_rejected counter,
    reversals_revenue counter,
    PRIMARY KEY ((d_tally), site_id, d_date, is_new_member, device, tracking_medium, tracking_source, tracking_campaign, tracking_term)
);

当我运行该语句时,似乎快速处理前几列,但是当它移动到计数器列时,它会逐渐减慢每列的速度。

我已将此声明保持运行5分钟,但仍未完成。

有人能对这种行为有所了解吗?

This是CQLSH在创建表时的样子,截图时它没有进展20分钟左右。

我只是将create table命令放到一行中,它立即起作用。

CREATE TABLE stats_by_site_tracking_hourly ( d_tally text, d_date timestamp, site_id int, is_new_member int, device text, tracking_medium text, tracking_source text, tracking_campaign text, tracking_term text, accepted counter, adjusted_accepted counter, rejected counter, adjusted_rejected counter, error counter, impressions_positive counter, adjusted_impressions_positive counter, impressions_negative counter, adjusted_impressions_negative counter, revenue counter, adjusted_revenue counter, reversals_rejected counter, reversals_revenue counter, PRIMARY KEY ((d_tally), site_id, d_date, is_new_member, device, tracking_medium, tracking_source, tracking_campaign, tracking_term) );

2 个答案:

答案 0 :(得分:4)

我在这里提出了这个错误:here

原来这是由于架构中的选项卡。 CQLSH每次进入选项卡时都试图自动完成。

答案 1 :(得分:2)

我在几台计算机上遇到过同样的问题,看来它是cqlsh>中的一个错误。互动壳。如果从终端执行脚本,它将立即执行:

> cqlsh -f your_cql_script.cql <hostname>

无论大小表如何,都会立即运行,并且可以为您节省大量时间。