Is it possible to turn off prepared statements on a per query basis?
I am not using Arel, I am constructing a rather elaborate SQL statement with window functions, CTEs and such and then using ActiveRecord::Base.with_connection to execute that statement.
Looking at pg_stats I see that for every invocation of that query there is a prepare running with ? instead of the values in the query and that the average time for the prepare is twice that of actually running the query. I’d like to turn off the prepare to see if it makes a difference.