anchor.diff:      [Row] = ets:lookup(TableId, RowId),
       % ?Debug("row_with_key ~p ~p", [RowId, Row]),
       {reply, Row, SN, State, infinity};
  -handle_sync_event({statistics, ColumnIds, RowIds}, _From, SN, #state{tableId = TableId, rowFun = RowFun, ctx=#ctx{stmtCols=StmtCols}} = State) ->
  +handle_sync_event({statistics, ColumnIds, RowIds}, _From, SN, #state{nav = Nav, tableId = TableId, indexId = IndexId, rowFun = RowFun, ctx=#ctx{stmtCols=StmtCols}} = State) ->
  +    case Nav of
  +        raw -> TableUsed = TableId;
  +        _ ->   TableUsed = IndexId
  +    end,
       ColNames = [(lists:nth(ColId, StmtCols))#stmtCol.alias || ColId <- ColumnIds],
       ?Debug("Getting the stats for the columns ~p and rows ~p columns ~p", [ColumnIds, RowIds, ColNames]),
       Rows = tuple_to_list(ets:foldl(fun(Row, SelectRows) ->
  
positive.code:             {_,_,RK} ->
                  ExpandedRow = RowFun(RK),
                  Value = lists:nth(ColumnId, ExpandedRow);
              Row ->
                  Value = element(3 + ColumnId, Row)
          end,
          case proplists:get_value(Value, CountList) of
              undefined -> {Total+1, [{Value, 1} | CountList]};
              OldCount -> {Total+1, lists:keyreplace(Value, 1, CountList, {Value, OldCount+1})}
          end
      end, {0, []}, TableId),
      ?Debug("Histo Rows ~p", [Result]),
      HistoRows = [[nop, Value, integer_to_binary(Count), 100 * Count / Total] || {Value, Count} <- Result],
      HistoRowsWithId = [[Idx | lists:nth(Idx, HistoRows)] || Idx <- lists:seq(1, length(HistoRows))],
  
negative.code:             {reply, {error, iolist_to_binary(io_lib:format("~p", [Error])), erlang:get_stacktrace()}
                    , SN, State, infinity}
      end;
  handle_sync_event({histogram, ColumnId}, _From, SN, #state{nav = Nav, tableId = TableId, indexId = IndexId, rowFun = RowFun} = State) ->
      case Nav of
          raw -> TableUsed = TableId;
          _ ->   TableUsed = IndexId
      end,            
      ?Info("Getting the histogram of the column ~p, nav ~p", [ColumnId, Nav]),
      {Total, Result} = ets:foldl(fun(Row, {Total, CountList}) ->
          RealRow = case Row of
              {_, Id} -> lists:nth(1, ets:lookup(TableId, Id));
  