Continuous Query Lagged by One Interval


#1

Hi I am currently having issues with my continuous queries where they are not recording the most recent interval.

My query is meant to calculate open high low close every 24 hours. Right now it is 9/2/17 12:52 EST, and my query should have generated a data point for 9/1/17 (which would be timestamped 9/2/17 00:00:00). However, this point does not seem to have been generated yet. The values the query is generating are all correct, however it seems to be behind by a day (note this is being seen across all time ranges). I am having a hard time understanding what is wrong with my query.

CREATE CONTINUOUS QUERY "1d_candle"
ON "exchangedb" RESAMPLE EVERY 1d FOR 1d 
BEGIN 
    SELECT first("rate") as open,
        max("rate") as high, 
        min("rate") as low,
        last("rate") as close,
        sum("quantity") as volume 
    INTO "candles.1d" FROM trades
    GROUP BY currencyPair, exchange, time(1d)
END

Any help as to why this lag appears to be happening would be greatly appreciated.

Thanks,
Pat


#2

Can anybody help with this? I am trying to migrate a rather large corporate database to influx, but will go with an alternative if I cannot get one of the base features to work properly…


#3

You can fix this by removing the "RESAMPLE EVERY 1d FOR 1d " from the continuous query.

As below:

CREATE CONTINUOUS QUERY "1d_candle"
ON "exchangedb"
BEGIN
SELECT first(“rate”) as open,
max(“rate”) as high,
min(“rate”) as low,
last(“rate”) as close,
sum(“quantity”) as volume
INTO “candles.1d” FROM trades
GROUP BY currencyPair, exchange, time(1d)
END