Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



Reply
Old 04-14-2008, 05:52 PM Copying to tmp table
Super Talker

Posts: 130
Trades: 0
When I run the following:

show processlist

I've been getting some entires of: Copying to tmp table

They don't hang like most of the people have when I do a search in google for the problem. What I want to know is, what does this mean? I just started noticing this and the load on the server seems to be higher than normal.

Thank you
__________________
flann

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
flann is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-14-2008, 10:09 PM Re: Copying to tmp table
joder's Avatar
Flipotron

Posts: 6,442
Name: James
Location: In the ocean.
Trades: 0
In order to process a query, MySQL is copying to a temporary table in memory. The server will do this often and it is normal. However, if your database or code is not optimized, it can cause longer query times and higher load on the server.

If you have access to the MySQL client program or phpmyadmin, do an

EXPLAIN [your query] to see some information on it.
joder is offline
Reply With Quote
View Public Profile
 
Old 04-15-2008, 11:51 AM Re: Copying to tmp table
Super Talker

Posts: 130
Trades: 0
I ran the explain and it appears that it only does this when I use either group by or order by on the table. How would I optimize this better? I do have indexes on the fields being used in both the group by and order by for the table in question.
__________________
flann

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
flann is offline
Reply With Quote
View Public Profile
 
Old 04-15-2008, 12:05 PM Re: Copying to tmp table
joder's Avatar
Flipotron

Posts: 6,442
Name: James
Location: In the ocean.
Trades: 0
It's "normal" for tmp tables to be created on group by and order by. How long is the query running? Is it causing performance issues?
joder is offline
Reply With Quote
View Public Profile
 
Old 04-15-2008, 12:46 PM Re: Copying to tmp table
Super Talker

Posts: 130
Trades: 0
It's running for about 2 seconds. I know that doesn't seem very long, but it is for a left hand nav menu. This menu has online products which causes a complex system of what products a user has and what products should trigger other products. During peak times, this can cause some slowing on the site. The left hand menu only gets created when the user logs in.
__________________
flann

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
flann is offline
Reply With Quote
View Public Profile
 
Old 04-15-2008, 12:50 PM Re: Copying to tmp table
joder's Avatar
Flipotron

Posts: 6,442
Name: James
Location: In the ocean.
Trades: 0
It's hard to know what is going on without the table structure and query.
joder is offline
Reply With Quote
View Public Profile
 
Old 04-15-2008, 03:02 PM Re: Copying to tmp table
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
It sounds like a table spool. Is it eager or lazy?

Quote:
Originally Posted by flann View Post
It's running for about 2 seconds. I know that doesn't seem very long, but it is for a left hand nav menu. This menu has online products which causes a complex system of what products a user has and what products should trigger other products. During peak times, this can cause some slowing on the site. The left hand menu only gets created when the user logs in.
Why are you running this query every time a user navigates? Run it once, and cache the results. Invalidate them from time to time if you have to, but you should get the data from your database server to your web server once, and then use it from there. That's the only way to have a scalable system, whether the query takes 2 hours or 2 milliseconds to run.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Copying to tmp table
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.89131 seconds with 12 queries