* Michael Schoen ([EMAIL PROTECTED]) [051212 14:15]:
> Can you try modifying oci_adapter.rb, and change OCIAdapter#active? to 
> use @connection.active? instead of @connection.ping. The 
> OCI8AutoRecover#active? method doesn't hit the db at all, it just 
> returns the last known state. This will be faster, though it means 
> you'll actually get a db failure in your app before it reconnects.
> 
> In trunk this is line 222 of oci_adapter.rb.

Sorry for the delay -- the dba's were making some changes to the layout
on that system late yesterday and early today.  Since the baseline may
have moved in the process, I reran the tests more today.

I found that changing to .active? didn't have any effect on performance.
I started doing some more exploration.

It turns out that the performance hit is coming from the other change in
oci_adapter.rb -- the columns() method.

We had the following "patch" loaded out of our /lib/ directory to
protect us against the data_default whitespace bug from #2788.  Since
0.14.4 rolled we took the patch out:

if $".grep(%r,oci8.rb,).length > 0
  module ActiveRecord
    # Fix bug in data_default regex
    module ConnectionAdapters
      class OCIAdapter
        def columns(table_name, name = nil) #:nodoc:
          select_all(%Q{
              select column_name, data_type, data_default, nullable,
                     case when data_type = 'NUMBER' then data_precision
                          when data_type = 'VARCHAR2' then data_length 
                          else null end as length,
                     case when data_type = 'NUMBER' then data_scale
                          else null end as scale
              from user_catalog cat, user_synonyms syn, all_tab_columns col
             where cat.table_name = '#{table_name.to_s.upcase}'
               and syn.synonym_name (+)= cat.table_name
               and col.owner = nvl(syn.table_owner, user)
               and col.table_name = nvl(syn.table_name, cat.table_name)}
          ).map do |row|
             row['data_default'].gsub!(/^'(.*)'\s+$/, '\1') if 
row['data_default']
             OCIColumn.new(
               oci_downcase(row['column_name']),
               row['data_default'],
               row['data_type'],
               row['length'],
               row['scale'],
               row['nullable'] == 'Y'
             )
          end
        end
      end
    end
  end

I can toggle a 3x+ performance hit (~22 seconds for a unit test or
functional test run to 77-80 seconds for the same) by toggling that
patch in and out on the 0.14.4 Rails install.

I've filed a trac on this (#3210).

Rick
-- 
 http://www.rickbradley.com    MUPRN: 40
                       |  motivation for
   random email haiku  |  emissions controls is to
                       |  reduce oil exports.
_______________________________________________
Rails-core mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails-core

Reply via email to