I have a search setup that I'm trying to optimize a query for using MySQL ver14.14 5.5.36 x64_64 and php version is 5.2.17.
There are a couple hundred thousand items in each table within the database and the time to complete the search is getting intolerable when there are 50+ users online.
Basically, I loop through the tables in a database using:
$result = mysql_query("show tables",$dbc1);
while($table = mysql_fetch_array($result)) {
$tablename = $table[0];
where I would then execute this query:
"SELECT * FROM $tablename WHERE FirstName like '$SanitizedFirstName%' and LastName like '$SanitizedLastName%' order by ID asc "
and then I loop through and output the results
while($row = mysql_fetch_array( $resultant2 )) {
Here is a sample of the database and some tables in it
database:people
table:congress
| ID | FirstName | LastName |
| 111111111 | Joe | SkypeMan |
| 111111112 | Susan | Yahooser |
| 111111113 | Bill | Googleheim |
| 111111114 | Margaret | Bingledorf |
| 111111115 | Mark | Aoldelson |
table:senate
| ID | FirstName | LastName |
| 111111111 | Tod | Sampleguy |
| 111111112 | Jason | Datafill |
| 111111113 | Neff | LoremIpsum |
| 111111114 | William | Dotdotdot |
| 111111115 | Lisa | Commaquote |
any help on optimizing this would be appreciated!