implemented insert-by-query plan

I think the TODO can be removed, or is it still relevant?