• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
database connection constantly over 1 second

I’m having a problem with CodeIgniter that it’s taking over 1 second to load every time.
I have navigated this down to being problem with the database connection that’s taking over 1 second to connect.

I’ve read some people having this issue too in PHP who have solved it by changing the server from “localhost” to, this however only solves it for me in application not using CodeIgniter.

I’ve come to this after disabling everything on autoload (Controller Execution Time: 0.0029), but when putting database on autoload it gets slow (Controller Execution Time: 1.0172) even when no queries are run.

Does anyone have any idea what could be causing this?
Some settings:

$config['sess_cookie_name']  = 'ci_session';
$config['sess_expiration']  = 7200;
$config['sess_expire_on_close'] = FALSE;
$config['sess_encrypt_cookie'] = TRUE;
$config['sess_use_database'] = TRUE;
$config['sess_table_name']  = 'ci_sessions';
$config['sess_match_ip']  = TRUE;
$config['sess_match_useragent'] = FALSE;
$config['sess_time_to_update'] = 300;

$db['default']['hostname'] = 'mysql:';
$db['default']['username'] = DBUSER;
$db['default']['password'] = DBPASS;
$db['default']['database'] = DATABASE;
$db['default']['dbdriver'] = 'pdo';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = FALSE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;

Have you tried a pattern like:
$db['default']['hostname'] = 'mysql:host=;';

Thanks for your reply and your idea, it did however not solve the problem.

If anyone else have any idea for this, please let us know, we are really looking for a solution for this.

Have you tried running this on a different machine, perhaps with a fresh httpd and mysqld stack? Could be something going on with the daemon's themselves?


I will see if I'm able to try it on another PC tomorrow, but all I need to do to replicate this is to set the below settings, so maybe there is something wrong with the machine, but using "plain and simple" script with just the "new PDO..." code connects instantly... Hmm

$autoload['libraries'] = array('database');

$db['default']['hostname'] = 'mysql:';
$db['default']['username'] = 'xxx';
$db['default']['password'] = 'xxx';
$db['default']['database'] = 'xxx';
$db['default']['dbdriver'] = 'pdo';

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.