Active Record Prepare SQL

Would it be possiblein the future to see Active Record generate Prepare and Bind SQL statements rather than passing literals to the DB?

Yes. Why?

jeremy

Because, at least in DB2, you have much lower cost preparing select c1 from t1 where c1 = ? rather than c1 = 'Hi' DB2 caches the queries that come in and all that use the ? are equivalent thus there is no new overhead in determining the access method. With literals, unless they are identical each literal will cause more overhead.

Just to satisfy my own curiosity...does this need to be included in
ActiveRecord. Couldn't this be implemented in the DB2 adapter?

Thanks guys. Mike

Well I did ask about the ibm_db adapter first but since the SQL is generated in active record the adapter wouldn't know what was a parameter originally. Also, I checked and Oracle and SQL Server work the same way. Since the cost of preparing a literal is 10x preparing out of cache in all three major databases it seems like a worthwhile addition.

Thanks for the reply Jorg.