Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strange 5 second pause with PHP command line interface (related to mysql/mysqli extension)

I'm getting a strange 5 to 7 second pause when executing PHP scripts from the command-line PHP client (PHP 5.2 on Windows).

During this pause the PHP script just appears to 'freeze' for a while before returning to the command prompt. It is not using any significant CPU time, it's like it is waiting for some delay.

After experimenting with PHP.ini, I've narrowed this down to the fact that the mysql or mysqli extension is enabled. If these extensions are both disabled, no annoying pause and the PHP script terminates in mere milliseconds.

The command I'm using is:

"C:\Program Files\PHP\php.exe" -f %1

Where %1 is the PHP script.

The pause still occurs even if the PHP script being executed is essentially empty:

<?php

?>

Do you know what is causing this pause and how I can remove it while still allowing mysql or mysqli support for PHP on the command line?

like image 254
thomasrutter Avatar asked Mar 13 '09 05:03

thomasrutter


3 Answers

it's a bug in mysql. you can solve it by getting the latest libmysql.dll (5.1.31 or higher. some older versions also work - see second link). make sure that's the libmysql.dll actually used and there are no other libmysql.dlls in your path. see the related php issue for details.

like image 127
ax. Avatar answered Nov 15 '22 05:11

ax.


For me (Zend Server CE on Mac OS X), the imap exetension was the culprit. Disabling it solved the problem.

Anoyone wants to write a PHP extension bisecting script? :)

like image 21
Olivier 'Ölbaum' Scherler Avatar answered Nov 15 '22 05:11

Olivier 'Ölbaum' Scherler


I also experienced an annoying 2 second delay running PHP from the command line under Windows 7 64bit.

This version had a delay:
php.exe (v5.3.5) shipped with ZendServer Community Edition

This version was wonderfully quick:
php.exe (v5.3.6) shipped with EasyPHP

(Sorry to bump an ancient thread, but hopefully this helps others Googling this issue.)

like image 3
Simon East Avatar answered Nov 15 '22 04:11

Simon East