Forum Moderators: coopster
i've built a system that's working with a large mysql database (4 million records at this point) and it's going to easily push 20 million records
It contains two tables, one is the products, and table two is a table contain all the possible variations of the spelling of Product_Name
Table A - (about 15,000 entries)
Prod_ID (unique primary key)
Product_Name (var char 10)
etc.Table B - 4 million entries
ID (unique - primary key)
Prod_ID ( Int - Index)
The_Text (Varchar 10) FULLTEXT index
Typically this section is taking between 2 and 4 seconds to run at the moment.
here's my query
$result=$this->run_sql("SELECT Prod_ID FROM table_b WHERE Product_Name LIKE '%".$keywords."%' ");
if (mysql_num_rows($result))
{
while($row=mysql_fetch_array($result))
{
if (!in_array($row['Prod_ID'],$theArray))
{
$theArray[]=$row['Prod_ID'];
}
}
}
Thanks,
hughie
A 'LIKE' query on a large dataset takes heaps of time. You might want to look into MySQL's Full-text Search Functions which will run queries a lot faster. Documentation is available at [dev.mysql.com ].
Heres the issue
say the database contains the following records
Prod ID prod name
1 -------- babcdefg
2 -------- hytzkaa
SELECT * FROM products WHERE Prod_Name LIKE '%abcd%'
returns ID 1
SELECT * FROM products WHERE (Prod) AGAINST ('abcd')
returns no rows
I think this would be fine searching for whole words but in this instance i'm looking for partial words.
is there any way to use the functionality of LIKE '%abcd%' whilst using MATCH?
Thanks,
hughie
Good luck!