How can I insert_all with a query in a way that a prepared statement will be used?

Hi!

When debugging slow Ecto queries (I’m using postgres), because Ecto uses named prepared statements which may use a different generic query plan than when running an individual query, I don’t use Ecto’s Repo.explain. Instead I copy the query’s SQL debug output, and from psql console I set plan_cache_mode='force_generic_plan', create a prepared statement annotating my argument types, and execute it with EXPLAIN (ANALYZE) EXECUTE mystatement(...).

Usually I see similar execution time as when the query is ran from Elixir. But this time the query in Elixir was running for 9s, and the psql query finished in .5s. I spent some time debugging Ecto code, and I think named prepared statements are never used with insert_all, even when a query is passed? So in this particular case, the generic plan would be much better.

So, my question is: is there a way to run a insert_all query with Ecto, where a named prepared statement will be used?