tags:

views:

337

answers:

1

Hi,

First I am sorry if I posted at the wrong place. Now onto the problem:

I am developing a web app with CakePHP with Oracle backend on Windows box, the development was initially done in CodeIgniter, and recently we decided to migrate to CakePHP.

The Oracle server is located at the different subnet. I am able to connect Cake to the remote server no problem, I set up some simple model, view and controller. However, when I am trying to access one of the controller. e.g. http://www.example.com/facilities/, it takes a while loading the page, and after 30 seconds the script times out.

After lotsa debugging, I found out that these lines are causing the problem.

cake/libs/model/datasources/dbo/dbo_oracle.php:448


     $sql = 'SELECT view_name AS name FROM all_views UNION SELECT table_name
             AS name FROM all_tables';

    if (!$this->execute($sql)) {
         return false;
     }

From my understanding, Cake is trying to fetch all tables in the database and associate it with the Model, when I try to run the above query on sqldeveloper, I got 3.7k+ result and I think it's slowing it down to the point where the script times out.

Is there any workaround to this?

Thank's in advance.

+1  A: 

ALL_TABLES and ALL_VIEWS contain list of all tables / views that you can access.

  • Try connecting as someone with less SELECT privileges.
  • Alternatively you can change ALL_TABLES / ALL_VIEWS to USER_TABLES / USER_VIEWS. That will only return objects that you own.
jva
That does the trick, thank's. I was actually thinking of the same solution but with filtering the query using "where owner = 'some-user'", but I guess your solution is clearer. Thank's again! I think this just emphasize Joel's point on leaky abstraction.
andreas