Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Database Server Software > MySQL > slow query (UNION) on a station with 4 processors and 8 gb ram

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-06-07, 07:26
Zamolxe Zamolxe is offline
Registered User
 
Join Date: Feb 2004
Posts: 35
Post slow query (UNION) on a station with 4 processors and 8 gb ram

Code:
( SELECT SQL_CALC_FOUND_ROWS [...] - 12 rows FROM `produs` ) UNION ALL ( SELECT [...] - 12 rows FROM `produs_lgp` AS `produs` ) ORDER BY `row3` LIMIT 0,25

`produs` has - 30000+ rows
`produs_lgp` has - 120000+ rows

in the attached picture (screen_explain.gif) you will see an EXPLAIN statement result of the query above. can someone tell me from that explain if something is wrong? i don't understand why the query takes 20 seconds to execute (i've tried different my.cnf configurations and got nearly same results)

[later edit]
- i use UNION ALL for FOUND_ROWS
- i use SELECT SQL_CALC_FOUND_ROWS because later i use SELECT FOUND_ROWS() for pagination, getting the number of total results. i also noticed that in the whole script (that is running this queries) the part with "SELECT FOUND_ROWS()" takes a lot of time..
[/later edit]
Attached Thumbnails
slow-query-union-station-4-processors-8-gb-ram-screen_explain.gif  
__________________
e-commerce studies

Last edited by Zamolxe : 11-06-07 at 08:01. Reason: explanation about pagination
Reply With Quote
  #2 (permalink)  
Old 11-06-07, 11:22
aschk aschk is offline
Registered User
 
Join Date: Mar 2007
Location: 636f6d7075746572
Posts: 734
The 3rd line from the bottom. You are examining 112511 rows, and the analyser is not using a key.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

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