Re: long PHP mysql_connect times

2005-03-18 Thread Dan Tappin
On Mar 18, 2005, at 4:16 AM, Daniel Hawker wrote:
Curiouser and curiouser said Alice...
When you say *it seems to be the first connect* do you mean in a page,
ie the first connect/disconnect takes ages but then any subsequent
connects are fine)
Exactly.  If I use pconnect the first one takes on average 5 seconds.  
The remain ones are 0 because they are already open.   mysql_connect 
takes 5 seconds for each one.

Equally the fact that you can run the SQL queries locally (with no
latency) and that PHP and HTML pages (with no SQL queries contained) 
run
fine, would seem to insinuate the problem is with how PHP communicates
with MySQL, rather than an underlying problem with either MySQL or
PHP/Apache. You could check your my.cnf and php.ini files and see if
they have corrupted themselves or similar. May be worth checking out 
the
mysql.sock location and its privileges. It may be finding it hard to
locate/create the sock file and hence is taking a long time to do the
first query.
Restating apache resets the issue i.e.  the next pconnects takes 5 
seconds.  Quitting the browser has no effect.  I am currently testing 
now to see if there is a time out issue i.e. if I wait 5 minutes will 
the delay reappear?

Dan T
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]


Re: long PHP mysql_connect times

2005-03-18 Thread Jeremy Cole
Restating apache resets the issue i.e.  the next pconnects takes 5 
seconds.  Quitting the browser has no effect.  I am currently testing 
now to see if there is a time out issue i.e. if I wait 5 minutes will 
the delay reappear?
FWIW, this sounds like a slow-to-respond DNS resolver.  Are Apache and 
MySQL on seperate machines, by any chance?  Or, alternatively, are you 
connecting locally on the machine using the machine's DNS name?

E.g.: mysql_connect(foo.example.com, ...) instead of 
mysql_connect(localhost, ...)

Can you try this:
Whatever name you are using in mysql_connect(), run this:
$ host foo.example.com
Then, take the IP that gives you and do the same:
$ host 1.2.3.4
Mainly you're looking for the delay in this second step.
--
Jeremy Cole
Technical Yahoo - MySQL (Database) Geek
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]


Re: long PHP mysql_connect times [Resolved]

2005-03-18 Thread Dan Tappin
Thanks Jeremy!
It was the lack of a reverse DNS entry.  I had the host resolved to an 
IP but now reverse arpa entry.  I added the DNS PTR record and viola!

I would have never though of / figured that one out.
Dan T
On Mar 18, 2005, at 10:59 AM, Jeremy Cole wrote:
Restating apache resets the issue i.e.  the next pconnects takes 5 
seconds.  Quitting the browser has no effect.  I am currently testing 
now to see if there is a time out issue i.e. if I wait 5 minutes will 
the delay reappear?
FWIW, this sounds like a slow-to-respond DNS resolver.  Are Apache and 
MySQL on seperate machines, by any chance?  Or, alternatively, are you 
connecting locally on the machine using the machine's DNS name?

E.g.: mysql_connect(foo.example.com, ...) instead of 
mysql_connect(localhost, ...)

Can you try this:
Whatever name you are using in mysql_connect(), run this:
$ host foo.example.com
Then, take the IP that gives you and do the same:
$ host 1.2.3.4
Mainly you're looking for the delay in this second step.
--
Jeremy Cole
Technical Yahoo - MySQL (Database) Geek

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]


Re: long PHP mysql_connect times [Resolved]

2005-03-18 Thread Jeremy Cole
Hi Dan,
It was the lack of a reverse DNS entry.  I had the host resolved to an 
IP but now reverse arpa entry.  I added the DNS PTR record and viola!
Excellent.
Also FWIW, you're not gaining anything by disconnecting after each query 
in your PHP code.  Connect once at the beginning of the script, 
disconnect once at the end.  All the extraneous connect/disconnect puts 
extra, unnecessary load on the database server.

I would have never though of / figured that one out.
Nobody knows... the troubles I've seen... :)
Regards,
Jeremy
--
Jeremy Cole
Technical Yahoo - MySQL (Database) Geek
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]


long PHP mysql_connect times

2005-03-17 Thread Dan Tappin
I'm not sure if it's a OS X, PHP or MySQL issue so I apologize in 
advance if this is taken as too off topic.

I have a PHP5.x site under development with MySQL 4.1.10.  I had the 
site running fine and there were no speed issues at all.  Everything is 
on the same system (a dual G5 Xserve).

Today however the PHP pages with MySQL calls started to take forever to 
load.  Static html and php files still loaded instantly.

I tracked the issue down to mysql_connect.  Initial calls to this 
function are taking 5 to 10 seconds each.  Subsequent calls missing a 
mysql_close call do not have the latency issue.  Normally I try have 
each call to mysql_connect followed by a mysql_close to keep my mysql 
tables in order.

I have tried:
 - loading the pages remotely and locally (both slow)
 - checked the Apache / MySQL logs
 - manually ran the mysql queries to check for slow queries (all 0.0x 
seconds duration)
 - restarted apache / mysql
 - used host and ip for mysql_connect function call (i.e. not a DNS 
look-up issue)
 - full reboot

mysql_pconnect still stalls on the first connect but subsequent 
requests have no delay.  Manual CLI connections do not show the 
connection delay.  I am stumped.

What is the best practice for using connect vs. pconnect?  Is it not 
best to open a connection, run a query and then close the connection?

Thanks,
Dan T
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]