fix adding the prefix

Now it will only add the prefix to sql queries with "prefix_tablename" and not to the placeholder %r which causes conflicts with non statistics tables.