Cassandra read timeout

前端 未结 1 946
梦谈多话
梦谈多话 2021-01-12 17:30

I am pulling big amount of data from cassandra 2.0, but unfortunately getting timeout exception. My table:

CREATE KEYSPACE StatisticsKeyspace
  WITH REPLICA         


        
相关标签:
1条回答
  • 2021-01-12 18:05

    If using the java client from datastax, pagination is enabled by default with a row set of 5000. If you still get a timeout, you may try to reduce this using

    public Statement setFetchSize(int fetchSize)
    

    (read more)

    If you are using the cli, you may need to experiment with some kind of manual pagination:

    SELECT KeywordId, Date, HourOfDay, Impressions, Clicks,AveragePosition,ConversionRate,AOV,AverageCPC,Bid 
    FROM StatisticsKeyspace.hourlystatistics 
    WHERE Date >= '2014-03-22' AND Date <= '2014-03-24' 
    LIMIT 100;
    
    SELECT * FROM ....  WHERE token(KeywordId) > token([Last KeywordId received]) AND ...
    LIMIT 100;
    

    To detect some cluster issues you can try a select with a limit of 1, maybe there is an underlying problem.

    Hope that helps.

    If you are still experiencing performance issues with your query, I would look at your secondary index, since the amount of data transferred seems to reasonable (only 'small' data types are returned). If I am right, changing the fetch size will not change much. Instead, do you insert dates only in your "Date" (timestamp) column? If you are inserting actual timestamps instead, the secondary index on this column will be very slow due to the cardinality. If you insert a date only, the timestamp will default to date + "00:00:00" + TZ which should reduce the cardinality and thus improve the look-up speed. (watch out for timezone issues!) To be absolutely sure, try a secondary index on a column with a different data type, like an int for Date (counting the days since 1970-01-01 or sth).

    0 讨论(0)
提交回复
热议问题