Rima
Rima

Reputation: 199

Oracle enhanced with rails 3.1

We have migrated our app from Rails 2.2 to rails 3.1 and started using activerecord-oracle_enhanced-adapter-1.4.1

I keep seeing this sql in my logs when the app loads and when any request comes to the server.

  (102.0ms)  SELECT DECODE(table_name, UPPER(table_name), LOWER(table_name), table_name) FROM all_tables WHERE owner = SYS_CONTEXT('userenv', 'session_user') AND secondary = 'N'
   (102.4ms)  SELECT DECODE(table_name, UPPER(table_name), LOWER(table_name), table_name) FROM all_tables WHERE owner = SYS_CONTEXT('userenv', 'session_user') AND secondary = 'N'
   (101.2ms)  SELECT DECODE(table_name, UPPER(table_name), LOWER(table_name), table_name) 
.....

Almost 21 queries at one time ..

When i digged into the library the origin of the statement is

 class OracleEnhancedAdapter 
    def tables

Can anyone tell me why these sqls are fired everytime. This behavior was not seen in rails 2.2 .

Does it affect the performance of the app or is it routine ?

Upvotes: 1

Views: 310

Answers (1)

dexter
dexter

Reputation: 13593

This happens during the first request to the application. It's pretty routine for ActiveRecord to get the list of table names from the database for the connected user.

This query will be fired only once (not per request but every time the server is started). This is specific to the database adapter implementation.

For e.g, the sqlite3-ruby gem fires an equivalent query:

SQL (0.6ms) SELECT name FROM sqlite_master WHERE type = 'table' AND NOT name = 'sqlite_sequence'

Upvotes: 2

Related Questions