Mysql word search slow
in
Programming Questions
•
2 years ago
hi, i'm searching a database of a few thousand entries and let my script look how often the word is comming in the database.
The problem is that it's slow as shit :(
What can i do to make it faster?
here's my code:
The problem is that it's slow as shit :(
What can i do to make it faster?
here's my code:
- void checkMysql() {
if ( dbconnection.connect() )
{
dbconnection.query( "SELECT * FROM `Boyd` WHERE 1");
println("zoekt database");
}
if (xLoop == true) {
while (dbconnection.next ())
{
String q = dbconnection.getString(1);
String r = dbconnection.getString(2);
// questionboyd = append(questionboyd, q);
questionboyd = append(questionboyd, r);
// String q = dbconnection.getString(2);
}
}
for ( int x = 1; x< questionboyd.length; x++ ) {
println("vraag "+x+":: "+questionboyd[x]);
questionboydSplit = split(questionboyd[x], " ");
println(dateBeginMysql);
println(dateEndMysql);
String count = "0";
boolean value = false;
for ( int o = 0; o< questionboydSplit.length; o++ ) {
if (questionboydSplit[o].length() >7) {
if ( dbconnection.connect() )
{
//ALTER TABLE news_google_split ADD FULLTEXT(word)
// dbconnection.query( "SELECT count(*) FROM `news_google_split` WHERE `word` LIKE '"+questionboydSplit[o]+"' AND `date` >= '"+dateBeginMysql+" ' AND `date` <= '"+dateEndMysql+"' ");
dbconnection.query( "SELECT count(*) FROM `news_google_split` WHERE `word` LIKE '"+questionboydSplit[o]+"' AND `date` >= '2010-12-07 ' AND `date` <= '2010-12-30 ' ");
}
while (dbconnection.next ())
{
value = true;
count = dbconnection.getString(1);
//println(count);
}
}
if ( value == true) {
if ((Integer.parseInt( count ) > 0) ) {
questionboydSplitCounter = append(questionboydSplitCounter, count);
println(questionboydSplitCounter);
println("woord " + questionboydSplit[o]);
value = false;
}
}
}
}
}
1
