Chris Fowler wrote:
I have a query that is admittedly inefficient in that it is doing multiple OR clauses and joining multiple tables. However, the query runs at an acceptable speed if I am in a terminal session and run the query directly in the terminal. On the other hand, when PHP performs the same query for use in a page, it takes 5-7 minutes for the query to run (the same query running in the terminal takes about 3-5 seconds). I can do a show processlist when the php page runs the query and I see "Copying to tmp table" in the State column of the show processlist results. Does anyone have any tips on why it is so much slower when run from php vs. the terminal.
Unless there's something going on that I don't know about, it should take the same time either way.
Have you checked that the query is EXACTLY the same?
It's possible that the query run from PHP is not using an index that the console query is. Try doing an 'explain' on the query from the processlist and comparing it to an 'explain' from the console query to see if they are using the same indexes.

Dan

--
signature Daniel Kasak
IT Developer
NUS Consulting Group
Level 5, 77 Pacific Highway
North Sydney, NSW, Australia 2060
T: (+61) 2 9922-7676 / F: (+61) 2 9922 7989
email: [EMAIL PROTECTED]
website: http://www.nusconsulting.com.au
-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to