Advertisement

09.18.2008 at 02:29PM PDT, ID: 23744088
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

5.0

Why is my mySQL Query running so slow!?

Asked by stellaartois in PHP and Databases, MySQL Server

Hi All,

I am building a lyrics website that allows users to search lyrics fully.  I have a seperate table for all Song Lyrics, Songs, Albums and Artists.

I have taken all of the lyrics and song names and indexed them in another table by weight per word.

When I type in to the search box and submit the form, the form retrieves the data from the tables using the following query:

SELECT search_index.song_id AS song_id, songs.song_name AS song_name, COUNT(*) AS nb, SUM(search_index.weight) AS total_weight, songs.album_id AS album_id, songs.artist_id AS artist_id, albums.album_name AS album_name, artists.artist_name AS artist_name, albums.album_date AS album_date FROM search_index LEFT JOIN (songs, albums, artists) ON (search_index.song_id = songs.song_id AND songs.album_id = albums.album_id AND albums.artist_id = artists.artist_id) WHERE (search_index.word='[SEARCH WORD]' OR word='[SEARCH WORD]') GROUP BY search_index.song_id ORDER BY nb DESC, total_weight DESC LIMIT 20

The code snippet is the structure of my tables.  They are all linked by ID's.

It runs really really slow and i dont know what tacktic to take to speed it up.

ThanksStart Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
CREATE TABLE IF NOT EXISTS `albums` (
  `album_id` int(10) NOT NULL auto_increment,
  `artist_id` int(10) NOT NULL default '0',
  `album_name` varchar(255) NOT NULL default '',
  `album_url` varchar(255) NOT NULL,
  `album_date` varchar(10) NOT NULL,
  `album_art` varchar(255) NOT NULL,
  PRIMARY KEY  (`album_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=36136 ;
 
-- --------------------------------------------------------
 
--
-- Table structure for table `artists`
--
 
CREATE TABLE IF NOT EXISTS `artists` (
  `artist_id` int(10) NOT NULL auto_increment,
  `artist_name` varchar(255) NOT NULL default '',
  `artist_url` varchar(255) NOT NULL default '',
  PRIMARY KEY  (`artist_id`),
  UNIQUE KEY `artist_name` (`artist_name`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=7953 ;
 
-- --------------------------------------------------------
 
--
-- Table structure for table `lyrics`
--
 
CREATE TABLE IF NOT EXISTS `lyrics` (
  `lyrics_id` int(10) NOT NULL auto_increment,
  `artist_id` int(10) NOT NULL,
  `album_id` int(10) NOT NULL,
  `song_id` int(10) NOT NULL default '0',
  `song_lyrics` longtext NOT NULL,
  `lyrics_url` varchar(255) NOT NULL,
  PRIMARY KEY  (`lyrics_id`),
  UNIQUE KEY `song_id` (`song_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=411424 ;
 
-- --------------------------------------------------------
 
--
-- Table structure for table `moved_artists`
--
 
CREATE TABLE IF NOT EXISTS `moved_artists` (
  `artist_id` int(10) NOT NULL default '0',
  `artist_name` varchar(255) NOT NULL default '',
  `artist_url` varchar(255) NOT NULL default '',
  PRIMARY KEY  (`artist_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
 
-- --------------------------------------------------------
 
--
-- Table structure for table `search_index`
--
 
CREATE TABLE IF NOT EXISTS `search_index` (
  `word_id` int(10) NOT NULL auto_increment,
  `artist_id` int(10) NOT NULL,
  `song_id` int(10) NOT NULL,
  `word` varchar(225) NOT NULL default '',
  `weight` int(10) NOT NULL default '0',
  UNIQUE KEY `word_id` (`word_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=27182361 ;
 
-- --------------------------------------------------------
 
--
-- Table structure for table `songs`
--
 
CREATE TABLE IF NOT EXISTS `songs` (
  `song_id` int(10) NOT NULL auto_increment,
  `artist_id` int(10) NOT NULL default '0',
  `album_id` int(10) NOT NULL,
  `song_name` varchar(255) NOT NULL default '',
  `song_url` varchar(255) NOT NULL default '',
  PRIMARY KEY  (`song_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=415872 ;
 
Loading Advertisement...
 
[+][-]09.18.2008 at 02:32PM PDT, ID: 22515727

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.18.2008 at 02:33PM PDT, ID: 22515742

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.18.2008 at 04:47PM PDT, ID: 22516668

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.19.2008 at 04:33AM PDT, ID: 22519935

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.19.2008 at 04:35AM PDT, ID: 22519952

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.19.2008 at 04:50AM PDT, ID: 22520077

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.19.2008 at 04:57AM PDT, ID: 22520139

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.19.2008 at 05:13AM PDT, ID: 22520242

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.19.2008 at 05:25AM PDT, ID: 22520336

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.19.2008 at 07:10AM PDT, ID: 22521223

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: PHP and Databases, MySQL Server
Sign Up Now!
Solution Provided By: cxr
Participating Experts: 3
Solution Grade: B
 
 
[+][-]09.19.2008 at 07:12AM PDT, ID: 22521249

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.19.2008 at 01:11PM PDT, ID: 22525056

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628