Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does it take so long to create a table?

I am creating the following schema:

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)
);

When I run the statement, it seems that the first few columns are processed quickly however when it moves onto the counter columns it slows down more and more for every column.

I have left this statement running for 5 minutes and it still hasn't completed.

Could anyone offer some insight into this behaviour?


This is what CQLSH looks like as the table is being created, and when the screenshot was taken it hadn't progressed for 20 minutes or so.


I just put the create table command into one line and it worked instantly.

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) );
like image 309
Jim Wright Avatar asked Feb 17 '16 11:02

Jim Wright


2 Answers

I raised this bug here: here

This turned out to be due to the tabs in the schema. CQLSH was trying to autocomplete each time it came to a tab.

like image 161
Jim Wright Avatar answered Oct 05 '22 18:10

Jim Wright


I had this same issue on several computers and appears it's a bug in the cqlsh> interactive shell. If you execute the script from your terminal it will immediately execute:

> cqlsh -f your_cql_script.cql <hostname>

This runs immediately no matter what size tables and will save you LOTS of time.

like image 41
Mike S. Avatar answered Oct 05 '22 19:10

Mike S.