Optimize query append.