implemented insert-by-query plan