arkadiyk
|
Posted: August 06, 2010 08:33 by arkadiyk
|
|
Hi, here is a profiler info for a query with 3 joins: %self cumulative total self children calls self/call total/call name 93.99 5360 5407 5360 47 9 595.56 600.78 ActiveRecord::ConnectionAdapters::JdbcConnection#columns 3.56 5563 203 203 0 1 203.00 203.00 ActiveRecord::ConnectionAdapters::JdbcConnection#execute_query 0.56 5595 3094 32 3062 264 0.12 11.72 Array#each I copied the columns caching from "identity_column" method into "columns" making my query about 10 times faster. Here are the methods I have changed. Another little problem is fixed here is XML datatype handling.
module ::JdbcSpec
module MsSQL
module Column
attr_accessor :identity, :is_special
def simplified_type(field_type)
case field_type
when /int|bigint|smallint|tinyint/i then :integer
when /numeric/i then (@scale.nil? || @scale == 0) ? :integer : :decimal
when /float|double|decimal|money|real|smallmoney/i then :decimal
when /datetime|smalldatetime/i then :datetime
when /timestamp/i then :timestamp
when /time/i then :time
when /date/i then :date
when /text|ntext|xml/i then :text
when /binary|image|varbinary/i then :binary
when /char|nchar|nvarchar|string|varchar/i then :string
when /bit/i then :boolean
when /uniqueidentifier/i then :string
end
end
end
def columns(table_name, name = nil)
return [] if table_name =~ /^information_schema\./i
@table_columns = {} unless @table_columns
if @table_columns[table_name] == nil
@table_columns[table_name] = super
@table_columns[table_name].each do |col|
col.identity = true if col.sql_type =~ /identity/i
col.is_special = true if col.sql_type =~ /text|ntext|image|xml/i
end
end
@table_columns[table_name]
end
def identity_column(table_name)
columns(table_name).each do |col|
return col.name if col.identity
end
return nil
end
def get_special_columns(table_name)
special = []
columns(table_name).each do |col|
special << col.name if col.is_special
end
special
end
end
end
Thank you, Arkadiy |
MS SQL: JdbcConnection#columns in Rail 3 is very slow
Replies: 0 - Last Post: August 06, 2010 08:33
by: arkadiyk
by: arkadiyk
showing 1 - 1 of 1
Replies: 0 - Last Post: August 06, 2010 08:33
by: arkadiyk
by: arkadiyk






