473,396 Members | 1,929 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Optimizing a query

I have this query which does a left outer join and it takes forever (like
half a day). Here are the results of an explain analysis.

mysql> explain SELECT count(searchresult.title) AS number,
campaigntrack.title, tracknum, trackid FROM campaigntrack LEFT OUTER JOIN
searchresult ON searchresult.title = campaigntrack.title WHERE
campaigntrack.albumid = 1 GROUP BY title ORDER BY tracknum;
+---------------+------+---------------+------+---------+------+----------+---------------------------------------------+
| table | type | possible_keys | key | key_len | ref | rows |
Extra |
+---------------+------+---------------+------+---------+------+----------+---------------------------------------------+
| campaigntrack | ALL | NULL | NULL | NULL | NULL | 62 |
where used; Using temporary; Using filesort |
| searchresult | ALL | NULL | NULL | NULL | NULL | 19875751 |
|
+---------------+------+---------------+------+---------+------+----------+---------------------------------------------+

Here are the schemas for the tables:

campaignalbum:

| trackid | int(10) unsigned | | PRI | NULL | auto_increment |
| tracknum | int(11) | YES | | NULL | |
| artistid | int(11) | YES | | NULL | |
| albumid | int(11) | YES | | NULL | |
| title | varchar(255) | YES | | NULL | |

searchresult:

| title | varchar(255) | YES | | NULL | |

Any suggestions on how to optimize this would be greatly appreciated.

Thanks.

__________________________________________________ _______________
<b>Get MSN 8</b> and enjoy automatic e-mail virus protection.
http://join.msn.com/?page=features/virus
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/my***********...ie.nctu.edu.tw

Jul 19 '05 #1
0 1190

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: A Future Computer Scientist | last post by:
A question: Is it really important to think about optimizing the native code or optimizing it for P Code? Or does the code you write make a difference?
6
by: Uros | last post by:
Hello! I have some trouble getting good results from my query. here is structure stat_views id | integer id_zone | integer created | timestamp
1
by: xpcer | last post by:
hi, friends, i have an problem, like this, i have tables, when i want to use "select" statement that include "join" sintaxt, my query will execute about 1 hour, so long. can u tell me how to...
0
by: rashmigaikwad | last post by:
Hi All, I need help in optimizing the query mentioned below: SELECT SUM(CASE WHEN PROD_TYP='HBRMC' AND INC_MULTIPLE < 2.50 AND LTV <= 0.75 OR LTV IS NULL THEN ADV_IN_QTR ELSE 0 END) ...
5
by: John Rivers | last post by:
Hello has anybody else noticed I have queries that SQL 2000 optimizes correctly and they run very fast Yet SQL 2005 keeps using a dumb query plan and queries run very slow The problem...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.