Welcome Guest, Not a member yet? Register   Sign In
Poor mult-database performance. What is going on?
#1

[eluser]joelkinzel[/eluser]
All,

I have a somewhat troubling scenario on my hands, so I will try and describe it at length. Basically, I'm wondering if DB performance is really as poor as my test shows it to be, or if there is something going on with my (extremely simple) application.

Scenario:

I have two databases on the same host. I can successfully connect to both. One is the main application database, the other is a database that houses user information. I am using the database to store the session information. The session table is in my main database.

I am using the simple "welcome" set up that comes with CI and basically just adding a simple authentication based on an existing auth system.

I have the session class auto loaded, as well as My_Auth. The database config is setup so that persistence is turned off on the auth database, but left on for the application database.

\application\libraries\MY_Auth
Code:
<?php if(!defined('BASEPATH')) exit('No direct script access allowed.');

class MY_Auth {

    private $appDB;
    private $authDB;
    private $CI;

    public function __construct()
    {
        $CI =& get_instance();
        $this->appDB = $CI->load->database('default', TRUE);
        $this->authDB = $CI->load->database('auth', TRUE);
    }

    public function userExists($id)
    {
        $query = $this->authDB->get_where('vault', array('id' => $id));
        return $query->num_rows === 1;
    }


}

\application\controllers\welcome.php
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Welcome extends CI_Controller {

public function index()
{
                $data['exists'] = $this->My_Auth->userExists(1065); // I know this user id exists in the DB
  $this->load->view('welcome_message', $data);
}
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */

In the view I then dump out the exists variable. In this case, it would read "true" (which it does).

However, my page rendering time went from 0.07s average (without any DB calls, which I still feel is a bit slow), to 1.2s average.

To me, this seems REALLY slow.

My computer running a WAMP stack:

MacPro 2x Xeon @ 2.4Ghz
16GB RAM
Windows 8 Enterprise

Any help is very much appreciated.


Messages In This Thread
Poor mult-database performance. What is going on? - by El Forum - 06-13-2013, 08:31 AM



Theme © iAndrew 2016 - Forum software by © MyBB