diff options
-rw-r--r-- | activerecord/CHANGELOG | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/oracle_adapter.rb | 8 | ||||
-rw-r--r-- | railties/configs/databases/oracle.yml | 11 |
3 files changed, 18 insertions, 3 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index e4ada2a7ac..f00de668e4 100644 --- a/activerecord/CHANGELOG +++ b/activerecord/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Oracle: to increase performance, prefetch 100 rows and enable similar cursor sharing. Both are configurable in database.yml. #6607 [philbogle@gmail.com, Michael Schoen] + * Don't inspect unloaded associations. #2905 [lmarlow] * SQLite: use AUTOINCREMENT primary key in >= 3.1.0. #6588 [careo] diff --git a/activerecord/lib/active_record/connection_adapters/oracle_adapter.rb b/activerecord/lib/active_record/connection_adapters/oracle_adapter.rb index b8d3ed5a95..2453781e53 100644 --- a/activerecord/lib/active_record/connection_adapters/oracle_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/oracle_adapter.rb @@ -552,12 +552,14 @@ begin # The OracleConnectionFactory factors out the code necessary to connect and # configure an Oracle/OCI connection. class OracleConnectionFactory #:nodoc: - def new_connection(username, password, database, async) + def new_connection(username, password, database, async, prefetch_rows, cursor_sharing) conn = OCI8.new username, password, database conn.exec %q{alter session set nls_date_format = 'YYYY-MM-DD HH24:MI:SS'} conn.exec %q{alter session set nls_timestamp_format = 'YYYY-MM-DD HH24:MI:SS'} rescue nil conn.autocommit = true conn.non_blocking = true if async + conn.prefetch_rows = prefetch_rows + conn.exec "alter session set cursor_sharing = #{cursor_sharing}" rescue nil conn end end @@ -584,8 +586,10 @@ begin @active = true @username, @password, @database, = config[:username], config[:password], config[:database] @async = config[:allow_concurrency] + @prefetch_rows = config[:prefetch_rows] || 100 + @cursor_sharing = config[:cursor_sharing] || 'similar' @factory = factory - @connection = @factory.new_connection @username, @password, @database, @async + @connection = @factory.new_connection @username, @password, @database, @async, @prefetch_rows, @cursor_sharing super @connection end diff --git a/railties/configs/databases/oracle.yml b/railties/configs/databases/oracle.yml index 3c3c8f8b13..c86cbdbaba 100644 --- a/railties/configs/databases/oracle.yml +++ b/railties/configs/databases/oracle.yml @@ -6,7 +6,16 @@ # Specify your database using any valid connection syntax, such as a # tnsnames.ora service name, or a sql connect url string of the form: # -# //host:[port][/service name] +# //host:[port][/service name] +# +# By default prefetch_rows (OCI_ATTR_PREFETCH_ROWS) is set to 100. And +# until true bind variables are supported, cursor_sharing is set by default +# to 'similar'. Both can be changed in the configation below; the defaults +# are equivalent to specifying: +# +# prefetch_rows: 100 +# cursor_sharing: similar +# development: adapter: oracle |