Turning off prepared statements on a case by case basis

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
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
I’d like to turn off the prepare to see if it makes a difference.


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs