473,466 Members | 1,613 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Using Match Against in a normalised Database (3 Tables)

I have searched the existing responses in this forum and others and
could not find a solution.
I have a database on MySQL server Version "4.0.13". My table structure
is as follows
TABLE1:MusicCD
This table has three columns - UPC, Title, ExtendedTitle

TABLE2: Artist
This table has three columns - ArtistID, ArtistName, ArtistOtherName

TABLE3: CDArtist
This table has two columns - ArtistID, UPC

I am using this structure because I can have a many to many
relationship between CD and Artist, i.e. one CD may have more than one
Artist and one Artist may have more than one CDs.

My Full Text Indexes are created on
TABLE1 -> (Title and ExtendedTitle)
TABLE2 -> (ArtistName and ArtistOtherName)

Now, when I do full text searches just for title in table 1 or just
for Artist in Table 2.. they are EXTREMELY fast. When I try to search
on a combination of Title AND Artist.. they are EXTREMELY SLOW. (I
have 1.14 million rows in Table 1 and 500K rows in Table2). Sometimes
the query takes even 10 minutes to return the results. I must be doing
something wrong here.

Here is my query - (I need to search for ALL Music CDs whos title or
Extended Title contain the word "Vally" and the ArtistName or
ArtistOtherName contain the word "Mike") (Both conditions should
match.

Select m.* FROM MusicCD m, Artist a, CDArtist c WHERE
MATCH (m.Title, m.ExtendedTitle) AGAINST ('Vally') AND
MATCH (a.ArtistName, a.ArtistOtherName) AGAINST ('Mike') AND
(a.ArtistID = c.ArtistID AND c.UPC = m.UPC)

I would really appreciate if someone can point me to the right
direction. I am not sure where to go from here. This solution cannot
be implemented because of its speed and I need to implement some
solution, which is atleast reasonable.

Thanks in advance
Danis
Jul 19 '05 #1
8 2992
Anyone ??
I really need help in this one.

Thanks
Danis

vz******@verizon.net (vze29xhy) wrote in message news:<76**************************@posting.google. com>...
I have searched the existing responses in this forum and others and
could not find a solution.
I have a database on MySQL server Version "4.0.13". My table structure
is as follows
TABLE1:MusicCD
This table has three columns - UPC, Title, ExtendedTitle

TABLE2: Artist
This table has three columns - ArtistID, ArtistName, ArtistOtherName

TABLE3: CDArtist
This table has two columns - ArtistID, UPC

I am using this structure because I can have a many to many
relationship between CD and Artist, i.e. one CD may have more than one
Artist and one Artist may have more than one CDs.

My Full Text Indexes are created on
TABLE1 -> (Title and ExtendedTitle)
TABLE2 -> (ArtistName and ArtistOtherName)

Now, when I do full text searches just for title in table 1 or just
for Artist in Table 2.. they are EXTREMELY fast. When I try to search
on a combination of Title AND Artist.. they are EXTREMELY SLOW. (I
have 1.14 million rows in Table 1 and 500K rows in Table2). Sometimes
the query takes even 10 minutes to return the results. I must be doing
something wrong here.

Here is my query - (I need to search for ALL Music CDs whos title or
Extended Title contain the word "Vally" and the ArtistName or
ArtistOtherName contain the word "Mike") (Both conditions should
match.

Select m.* FROM MusicCD m, Artist a, CDArtist c WHERE
MATCH (m.Title, m.ExtendedTitle) AGAINST ('Vally') AND
MATCH (a.ArtistName, a.ArtistOtherName) AGAINST ('Mike') AND
(a.ArtistID = c.ArtistID AND c.UPC = m.UPC)

I would really appreciate if someone can point me to the right
direction. I am not sure where to go from here. This solution cannot
be implemented because of its speed and I need to implement some
solution, which is atleast reasonable.

Thanks in advance
Danis

Jul 19 '05 #2
Anyone ??
I really need help in this one.

Thanks
Danis

vz******@verizon.net (vze29xhy) wrote in message news:<76**************************@posting.google. com>...
I have searched the existing responses in this forum and others and
could not find a solution.
I have a database on MySQL server Version "4.0.13". My table structure
is as follows
TABLE1:MusicCD
This table has three columns - UPC, Title, ExtendedTitle

TABLE2: Artist
This table has three columns - ArtistID, ArtistName, ArtistOtherName

TABLE3: CDArtist
This table has two columns - ArtistID, UPC

I am using this structure because I can have a many to many
relationship between CD and Artist, i.e. one CD may have more than one
Artist and one Artist may have more than one CDs.

My Full Text Indexes are created on
TABLE1 -> (Title and ExtendedTitle)
TABLE2 -> (ArtistName and ArtistOtherName)

Now, when I do full text searches just for title in table 1 or just
for Artist in Table 2.. they are EXTREMELY fast. When I try to search
on a combination of Title AND Artist.. they are EXTREMELY SLOW. (I
have 1.14 million rows in Table 1 and 500K rows in Table2). Sometimes
the query takes even 10 minutes to return the results. I must be doing
something wrong here.

Here is my query - (I need to search for ALL Music CDs whos title or
Extended Title contain the word "Vally" and the ArtistName or
ArtistOtherName contain the word "Mike") (Both conditions should
match.

Select m.* FROM MusicCD m, Artist a, CDArtist c WHERE
MATCH (m.Title, m.ExtendedTitle) AGAINST ('Vally') AND
MATCH (a.ArtistName, a.ArtistOtherName) AGAINST ('Mike') AND
(a.ArtistID = c.ArtistID AND c.UPC = m.UPC)

I would really appreciate if someone can point me to the right
direction. I am not sure where to go from here. This solution cannot
be implemented because of its speed and I need to implement some
solution, which is atleast reasonable.

Thanks in advance
Danis

Jul 19 '05 #3

Try sticking "EXPLAIN" in front of your SELECT and post the mysql
output. I bet one table is being text searched once per record matched
in the other.

John
vze29xhy wrote:
Anyone ??
I really need help in this one.

Thanks
Danis

vz******@verizon.net (vze29xhy) wrote in message news:<76**************************@posting.google. com>...
I have searched the existing responses in this forum and others and
could not find a solution.
I have a database on MySQL server Version "4.0.13". My table structure
is as follows
TABLE1:MusicCD
This table has three columns - UPC, Title, ExtendedTitle

TABLE2: Artist
This table has three columns - ArtistID, ArtistName, ArtistOtherName

TABLE3: CDArtist
This table has two columns - ArtistID, UPC

I am using this structure because I can have a many to many
relationship between CD and Artist, i.e. one CD may have more than one
Artist and one Artist may have more than one CDs.

My Full Text Indexes are created on
TABLE1 -> (Title and ExtendedTitle)
TABLE2 -> (ArtistName and ArtistOtherName)

Now, when I do full text searches just for title in table 1 or just
for Artist in Table 2.. they are EXTREMELY fast. When I try to search
on a combination of Title AND Artist.. they are EXTREMELY SLOW. (I
have 1.14 million rows in Table 1 and 500K rows in Table2). Sometimes
the query takes even 10 minutes to return the results. I must be doing
something wrong here.

Here is my query - (I need to search for ALL Music CDs whos title or
Extended Title contain the word "Vally" and the ArtistName or
ArtistOtherName contain the word "Mike") (Both conditions should
match.

Select m.* FROM MusicCD m, Artist a, CDArtist c WHERE
MATCH (m.Title, m.ExtendedTitle) AGAINST ('Vally') AND
MATCH (a.ArtistName, a.ArtistOtherName) AGAINST ('Mike') AND
(a.ArtistID = c.ArtistID AND c.UPC = m.UPC)

I would really appreciate if someone can point me to the right
direction. I am not sure where to go from here. This solution cannot
be implemented because of its speed and I need to implement some
solution, which is atleast reasonable.

Thanks in advance
Danis

Jul 19 '05 #4

Try sticking "EXPLAIN" in front of your SELECT and post the mysql
output. I bet one table is being text searched once per record matched
in the other.

John
vze29xhy wrote:
Anyone ??
I really need help in this one.

Thanks
Danis

vz******@verizon.net (vze29xhy) wrote in message news:<76**************************@posting.google. com>...
I have searched the existing responses in this forum and others and
could not find a solution.
I have a database on MySQL server Version "4.0.13". My table structure
is as follows
TABLE1:MusicCD
This table has three columns - UPC, Title, ExtendedTitle

TABLE2: Artist
This table has three columns - ArtistID, ArtistName, ArtistOtherName

TABLE3: CDArtist
This table has two columns - ArtistID, UPC

I am using this structure because I can have a many to many
relationship between CD and Artist, i.e. one CD may have more than one
Artist and one Artist may have more than one CDs.

My Full Text Indexes are created on
TABLE1 -> (Title and ExtendedTitle)
TABLE2 -> (ArtistName and ArtistOtherName)

Now, when I do full text searches just for title in table 1 or just
for Artist in Table 2.. they are EXTREMELY fast. When I try to search
on a combination of Title AND Artist.. they are EXTREMELY SLOW. (I
have 1.14 million rows in Table 1 and 500K rows in Table2). Sometimes
the query takes even 10 minutes to return the results. I must be doing
something wrong here.

Here is my query - (I need to search for ALL Music CDs whos title or
Extended Title contain the word "Vally" and the ArtistName or
ArtistOtherName contain the word "Mike") (Both conditions should
match.

Select m.* FROM MusicCD m, Artist a, CDArtist c WHERE
MATCH (m.Title, m.ExtendedTitle) AGAINST ('Vally') AND
MATCH (a.ArtistName, a.ArtistOtherName) AGAINST ('Mike') AND
(a.ArtistID = c.ArtistID AND c.UPC = m.UPC)

I would really appreciate if someone can point me to the right
direction. I am not sure where to go from here. This solution cannot
be implemented because of its speed and I need to implement some
solution, which is atleast reasonable.

Thanks in advance
Danis

Jul 19 '05 #5
Thanks for a response John,

Here is the result of Explain:
Please note that ind_TitleAB is the name of my full text Index on
Table1, which includes both title fields.

table type possible_keys key key_len ref
rows Extra
------ -------- ------------------- ----------- -------
----------- ------ -----------
m fulltext PRIMARY,ind_TitleAB ind_TitleAB 0
1 Using where
c ref UPC,ArtistID UPC 10 m.UPC
11
a eq_ref PRIMARY PRIMARY 8
c.ArtistID 1 Using where
John <no****@toplevel.tld> wrote in message news:<zp*******************@newsread2.news.atl.ear thlink.net>...
Try sticking "EXPLAIN" in front of your SELECT and post the mysql
output. I bet one table is being text searched once per record matched
in the other.

John

Jul 19 '05 #6
Thanks for a response John,

Here is the result of Explain:
Please note that ind_TitleAB is the name of my full text Index on
Table1, which includes both title fields.

table type possible_keys key key_len ref
rows Extra
------ -------- ------------------- ----------- -------
----------- ------ -----------
m fulltext PRIMARY,ind_TitleAB ind_TitleAB 0
1 Using where
c ref UPC,ArtistID UPC 10 m.UPC
11
a eq_ref PRIMARY PRIMARY 8
c.ArtistID 1 Using where
John <no****@toplevel.tld> wrote in message news:<zp*******************@newsread2.news.atl.ear thlink.net>...
Try sticking "EXPLAIN" in front of your SELECT and post the mysql
output. I bet one table is being text searched once per record matched
in the other.

John

Jul 19 '05 #7


Are you querying on the same database as you originally posted about?
You said:
Now, when I do full text searches just for title in table 1 or just
for Artist in Table 2.. they are EXTREMELY fast. When I try to search
on a combination of Title AND Artist.. they are EXTREMELY SLOW. (I
have 1.14 million rows in Table 1 and 500K rows in Table2). Sometimes
the query takes even 10 minutes to return the results.
The "explain" output looks like it deals with a very small number of
rows and should run quickly.

John
vze29xhy wrote:
Thanks for a response John,

Here is the result of Explain:
Please note that ind_TitleAB is the name of my full text Index on
Table1, which includes both title fields.

table type possible_keys key key_len ref
rows Extra
------ -------- ------------------- ----------- -------
----------- ------ -----------
m fulltext PRIMARY,ind_TitleAB ind_TitleAB 0
1 Using where
c ref UPC,ArtistID UPC 10 m.UPC
11
a eq_ref PRIMARY PRIMARY 8
c.ArtistID 1 Using where
John <no****@toplevel.tld> wrote in message news:<zp*******************@newsread2.news.atl.ear thlink.net>...
Try sticking "EXPLAIN" in front of your SELECT and post the mysql
output. I bet one table is being text searched once per record matched
in the other.

John

Jul 19 '05 #8


Are you querying on the same database as you originally posted about?
You said:
Now, when I do full text searches just for title in table 1 or just
for Artist in Table 2.. they are EXTREMELY fast. When I try to search
on a combination of Title AND Artist.. they are EXTREMELY SLOW. (I
have 1.14 million rows in Table 1 and 500K rows in Table2). Sometimes
the query takes even 10 minutes to return the results.
The "explain" output looks like it deals with a very small number of
rows and should run quickly.

John
vze29xhy wrote:
Thanks for a response John,

Here is the result of Explain:
Please note that ind_TitleAB is the name of my full text Index on
Table1, which includes both title fields.

table type possible_keys key key_len ref
rows Extra
------ -------- ------------------- ----------- -------
----------- ------ -----------
m fulltext PRIMARY,ind_TitleAB ind_TitleAB 0
1 Using where
c ref UPC,ArtistID UPC 10 m.UPC
11
a eq_ref PRIMARY PRIMARY 8
c.ArtistID 1 Using where
John <no****@toplevel.tld> wrote in message news:<zp*******************@newsread2.news.atl.ear thlink.net>...
Try sticking "EXPLAIN" in front of your SELECT and post the mysql
output. I bet one table is being text searched once per record matched
in the other.

John

Jul 19 '05 #9

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

Similar topics

0
by: Josh | last post by:
I've got a search running from PHP with the following SQL: $results = mysql_query("SELECT DISTINCT ForumThread.id as threadId, ForumThread.Subject as threadTopic, ForumThread.ID as threadId,...
0
by: Mike | last post by:
Hello, I'm trying to understand how to map hierarchical XML data to relational database tables, but I seem to be missing something. I'm not a database expert, but I know the basics. XML seems...
4
by: DraguVaso | last post by:
Hi, For my VB.NET application I have the following situation: 2 tables on my SQL Server: tblAccounts and tblRules. For each Account there are many Rules (so tblRules is linked to my tblAccounts...
4
by: jmdaviault | last post by:
I want to do the equivalent of SELECT id from TABLE WHERE text='text' only fast solution I found is: SELECT id,text from TABLE WHERE MATCH(text) AGAINST('value' IN BOOLEAN MODE) HAVING...
1
by: atl10spro | last post by:
Hello Everyone, I am new to MS Access and although I have created several different databases I lack the VB knowledge to code a search function. I am turning to your expertise for assistance. ...
2
by: Steve Richter | last post by:
what is the best way to use DataGridView to view data from large database tables? Where the sql select statement might return millions of rows? string connectionString =...
6
by: lawrence k | last post by:
Wierd. Go to this page: http://www.ihanuman.com/search.php and search for "yoga" This query gets run: SELECT * FROM albums WHERE MATCH(name,description) AGAINST ('yoga') ORDER BY id DESC
3
by: Cless | last post by:
Hi everyone, Given a connection string, is there a way to retrieve all database objects from a database. I already know through the MSDN documentation of .NET of how to enumerate all database...
3
by: erbrose | last post by:
Hey all, Sorry the subject should have said.. "best way to match values in TWO tables" I have two tables that I need to match based off an Unique ID in both tables. Im running this process using...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.