anchor.diff:      new_state().
   
   %%
  -subqueries_done(QId, #state{qid          = QId,
  -                            receiver_pid = ReceiverPid,
  -                            sub_qrys     = SubQQ} = State) ->
  +maybe_subqueries_done(QId, #state{qid = QId,
  +                                  sub_qrys = SubQQ} = State) ->
       case SubQQ of
           [] ->
  -            QueryResult2 = prepare_final_results(State),
  -            %   send the results to the waiting client process
  -            ReceiverPid ! {ok, QueryResult2},
  -            pop_next_query(),
  -            % clean the state of query specfic data, ready for the next one
  -            new_state();
  +            subqueries_done(State);
           _ ->
               % more sub queries are left to run
               State
       end.
  +
  +subqueries_done(#state{receiver_pid = ReceiverPid} = State) ->
  +    QueryResult2 = prepare_final_results(State),
  +    %   send the results to the waiting client process
  +    ReceiverPid ! {ok, QueryResult2},
  +    pop_next_query(),
  +    % clean the state of query specfic data, ready for the next one
  +    new_state().
   
   -spec prepare_final_results(#state{}) ->
                                      {[riak_pb_ts_codec:tscolumnname()],
  
positive.code: safe_nthtail(Offset, [_|Tail]) ->
      safe_nthtail(Offset-1, Tail).
  
  %%%===================================================================
  %%% Unit tests
  %%%===================================================================
  
negative.code:     {noreply, State2};
  
  handle_info({{_, QId}, done}, #state{ qid = QId } = State) ->
      {noreply, maybe_subqueries_done(QId, State)};
  
  handle_info({{SubQId, QId}, {results, Chunk}}, #state{qid = QId} = State1) ->
      State2 = add_subquery_result(SubQId, Chunk, State1),
      %% we may be able to return early from a query if we have enough rows to
      %% meet the OFFSET and LIMIT
      case is_result_limit_satisfied(State2) of
          true ->
              {noreply, subqueries_done(State2)};
          false ->
              {noreply, throttling_spawn_index_fsms(estimate_query_size(State2))}
      end;
  
  handle_info({{SubQId, QId}, {error, Reason} = Error},
              #state{receiver_pid = ReceiverPid,
  