Hi All,
i want to search in large libraries with sql
about 20000 books;
each book is in one table and all book names stored in table named books;

my code for search is :
Qt Code:
  1. void MyThread::run()
  2. {
  3. QStringList bookTables =db->getList("Select booktable From books;");
  4. QStringList bookNames =db->getList("Select bookNames From books;");
  5. int rowBook=0;
  6. int totalResultBooks=0;
  7. int totalResult=0;
  8. int allBookCount=bookTables.size();
  9. emit sendMaxProgress(allBookCount-1);
  10. while(rowBook<allBookCount )
  11. {
  12. QString query = QString("Select count(id) From b%1 Where text LIKE '%%2%' Limit 0,1 ; ").arg(bookTables.at(rowBook)).arg(searchPatterned);
  13. QString resultBook =db->getStr(query);
  14. if(resultBook.toInt()>0)
  15. {
  16. totalResult+= resultBook.toInt();
  17. totalResultBooks++;
  18. item->setText(bookNames.at(rowBook)+" ("+resultBook+") ");
  19. item->setData(12,bookTables.at(rowBook));
  20. QString str = "found "+QString::number(totalResult)+"at"+QString::number(totalResultBooks)+"Books";
  21. emit sendResult(item,str,rowBook);
  22. }
  23. msleep(40);
  24. rowBook++;
  25. }
  26.  
  27. }
To copy to clipboard, switch view to plain text mode 

my question is :
i used :
Qt Code:
  1. msleep(40);
To copy to clipboard, switch view to plain text mode 

to free 20% of cpu ..

is this way right?
is there any better way ?