views:

581

answers:

3

Hello,

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?

A: 

Are you using any MySQL database functions in your code? Do you use any persistent connections? If you turn those off does it go away?

X-Istence
It occurs even when using no functions at all in my code.
thomasrutter
It was just a guess. The other posters have already identified the culprit!
X-Istence
+3  A: 

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.

ax
Thankyou. Upgrading libmysql.dll in my PHP directory almost completely removed the delay. Interestingly, there is still a bit of a delay (few hundred milliseconds) compared to disabling mysql support. But the annoyance factor is solved.
thomasrutter
A: 

This also seems to happen with mysqli now. Taking it out of the ini file + iisreset solves the problem. I'm a newbie, where do I note or escalate this problem?

Did you try replacing libmysql.dll (as provided by PHP) with a more recent version provided by MySQL?
thomasrutter