This is a bug I have reported on the Rails Trac. Basically, our Rails application is connecting to 2 databases, but the action summary time at the end only accounts for the time spent in queries to the local (development) database, and leaves out all the time spent in queries to the second (read-only) database that resides on another machine.
The problem manifested on the production server, where you don’t get the individual query times in the log. This misled us into searching for a different problem completely, and wasted a lot of time.
Here is the log from running in development mode, illustrating the problem very obviously. Note that only the “conditions” table is in the local database, and all other tables are in the second database.
Processing WellListController#list (for 127.0.0.1 at 2006-02-06 11:32:28) [GET]
Parameters: {"action"=>"list", "controller"=>"well_list"}
Condition Load (0.001013) SELECT * FROM conditions WHERE (conditions.search_id = 13)
OperatorCondition Columns (0.006002) SHOW FIELDS FROM conditions
Well Columns (0.016398)
select column_name, data_type, data_default, nullable,
decode(data_type, 'NUMBER', data_precision,
'VARCHAR2', data_length,
null) as length,
decode(data_type, 'NUMBER', data_scale, null) as scale
from user_catalog cat, user_synonyms syn, all_tab_columns col
where cat.table_name = 'WELL'
and syn.synonym_name (+)= cat.table_name
and col.table_name = nvl(syn.table_name, cat.table_name)
and col.owner = nvl(syn.table_owner, user)
Well Count (0.019738) SELECT COUNT(*) FROM well WHERE (OPERATOR IN ( SELECT BUSINESS_ASSOCIATE FROM BUSINESS_ASSOCIATE WHERE LOWER(BA_NAME) LIKE '%sh%'))
Well Load (0.054383) select * from (select raw_sql_.*, rownum raw_rnum_ from (SELECT * FROM well WHERE (OPERATOR IN ( SELECT BUSINESS_ASSOCIATE FROM BUSINESS_ASSOCIATE WHERE LOWER(BA_NAME) LIKE '%sh%')) ) raw_sql_ where rownum < = 10) where raw_rnum_ > 0
Rendering within layouts/application
Rendering well_list/list
RWellStatus Columns (0.010251)
select column_name, data_type, data_default, nullable,
decode(data_type, 'NUMBER', data_precision,
'VARCHAR2', data_length,
null) as length,
decode(data_type, 'NUMBER', data_scale, null) as scale
from user_catalog cat, user_synonyms syn, all_tab_columns col
where cat.table_name = 'R_WELL_STATUS'
and syn.synonym_name (+)= cat.table_name
and col.table_name = nvl(syn.table_name, cat.table_name)
and col.owner = nvl(syn.table_owner, user)
RWellStatus Load (0.014428) select * from (select raw_sql_.*, rownum raw_rnum_ from (SELECT * FROM r_well_status WHERE (r_well_status.status = '00030000') ) raw_sql_ where rownum < = 1) where raw_rnum_ > 0
ProductionEntityWell Columns (0.007681)
select column_name, data_type, data_default, nullable,
decode(data_type, 'NUMBER', data_precision,
'VARCHAR2', data_length,
null) as length,
decode(data_type, 'NUMBER', data_scale, null) as scale
from user_catalog cat, user_synonyms syn, all_tab_columns col
where cat.table_name = 'PDEN_WELL'
and syn.synonym_name (+)= cat.table_name
and col.table_name = nvl(syn.table_name, cat.table_name)
and col.owner = nvl(syn.table_owner, user)
ProductionEntityWell Load (0.009062) select * from (select raw_sql_.*, rownum raw_rnum_ from (SELECT * FROM pden_well WHERE (pden_well.UWI = '0555051107022') ) raw_sql_ where rownum < = 1) where raw_rnum_ > 0
RWellStatus Load (0.015663) select * from (select raw_sql_.*, rownum raw_rnum_ from (SELECT * FROM r_well_status WHERE (r_well_status.status = '02010000') ) raw_sql_ where rownum < = 1) where raw_rnum_ > 0
ProductionEntityWell Load (0.009083) select * from (select raw_sql_.*, rownum raw_rnum_ from (SELECT * FROM pden_well WHERE (pden_well.UWI = '0555051107023') ) raw_sql_ where rownum < = 1) where raw_rnum_ > 0
ProductionEntityWell Load (0.008181) select * from (select raw_sql_.*, rownum raw_rnum_ from (SELECT * FROM pden_well WHERE (pden_well.UWI = '0555051111020') ) raw_sql_ where rownum < = 1) where raw_rnum_ > 0
RWellStatus Load (0.014005) select * from (select raw_sql_.*, rownum raw_rnum_ from (SELECT * FROM r_well_status WHERE (r_well_status.status = '02100000') ) raw_sql_ where rownum < = 1) where raw_rnum_ > 0
ProductionEntityWell Load (0.010287) select * from (select raw_sql_.*, rownum raw_rnum_ from (SELECT * FROM pden_well WHERE (pden_well.UWI = '0555051111022') ) raw_sql_ where rownum < = 1) where raw_rnum_ > 0
RWellStatus Load (0.008513) select * from (select raw_sql_.*, rownum raw_rnum_ from (SELECT * FROM r_well_status WHERE (r_well_status.status = '00070000') ) raw_sql_ where rownum < = 1) where raw_rnum_ > 0
ProductionEntityWell Load (0.010116) select * from (select raw_sql_.*, rownum raw_rnum_ from (SELECT * FROM pden_well WHERE (pden_well.UWI = '0555051112000') ) raw_sql_ where rownum < = 1) where raw_rnum_ > 0
ProductionEntityWell Load (0.014742) select * from (select raw_sql_.*, rownum raw_rnum_ from (SELECT * FROM pden_well WHERE (pden_well.UWI = '0555051112002') ) raw_sql_ where rownum < = 1) where raw_rnum_ > 0
RWellStatus Load (0.014744) select * from (select raw_sql_.*, rownum raw_rnum_ from (SELECT * FROM r_well_status WHERE (r_well_status.status = '06010300') ) raw_sql_ where rownum < = 1) where raw_rnum_ > 0
ProductionEntityWell Load (0.023254) select * from (select raw_sql_.*, rownum raw_rnum_ from (SELECT * FROM pden_well WHERE (pden_well.UWI = '0555051606000') ) raw_sql_ where rownum < = 1) where raw_rnum_ > 0
RWellStatus Load (0.008389) select * from (select raw_sql_.*, rownum raw_rnum_ from (SELECT * FROM r_well_status WHERE (r_well_status.status = '01110000') ) raw_sql_ where rownum < = 1) where raw_rnum_ > 0
ProductionEntityWell Load (0.024230) select * from (select raw_sql_.*, rownum raw_rnum_ from (SELECT * FROM pden_well WHERE (pden_well.UWI = '0555051607000') ) raw_sql_ where rownum < = 1) where raw_rnum_ > 0
ProductionEntityWell Load (0.008161) select * from (select raw_sql_.*, rownum raw_rnum_ from (SELECT * FROM pden_well WHERE (pden_well.UWI = '0555051608000') ) raw_sql_ where rownum < = 1) where raw_rnum_ > 0
ProductionEntityWell Load (0.011345) select * from (select raw_sql_.*, rownum raw_rnum_ from (SELECT * FROM pden_well WHERE (pden_well.UWI = '0555051609000') ) raw_sql_ where rownum < = 1) where raw_rnum_ > 0
Rendered well_list/_list_table (16.23639)
Rendered shared/_header (0.00074)
Rendered shared/_navbar (0.00173)
Rendered shared/_footer (0.00083)
Completed in 21.23575 (0 reqs/sec) | Rendering: 16.32746 (76%) | DB: 0.02618 (0%) | 200 OK [http://localhost/well_list/list]