0

I'm building an app where it contains 3 mysql database connections to 3 different databases.
Ex.
1. Default connection => DB1
2. conn02 => DB2
3. conn03 => DB3

All this 3 connections use same username and password.

I called other 2 connections in model construct since it was not default. like:

$this->CONN2 = $this->load->database('db2', TRUE);
$this->CONN3 = $this->load->database('db3', TRUE);

Later when i called this model in controller and while rendering the view. It was taking around 7 seconds to render the view in browser. Which was long time for a view to load in browser without any db select queries.

Then i benchmarked the model and saw the result. I came to know that model was taking time. So i disabled the database connections in the model at construct and it was loading fast. I was surprised to see the result.

Can you please tell me how to solve this issue?

Here is the image of benchmark result before and after disabling the database connections in model.

enter image description here

4

1 回答 1

0

我纠正了这个问题。如果我从负载数据库中删除第二个参数(TRUE)。模型载荷在0.0042以内。但我正在使用活动记录,因此必须传递第二个参数 TRUE。

$this->CONN2 = $this->load->database('db2');
$this->CONN3 = $this->load->database('db3');

我有 3 个库自动加载“数据库”、“会话”和“自定义库”。当我禁用此自动加载时。带有模型的整个控制器在0.0356内加载

后来我优化了几个区域,现在 CI 快速渲染页面<= 1sec

于 2013-06-10T17:20:01.343 回答