Database – Implementing search over large data set, PHP or Mysql stored procedure

databaseMySQLsearch

I'm building an Online Food Ordering System with PHP and MYSQL, One of the feature of the application is to allow users to search for the restaurants by typing the area name.
I would like to know using PHP for search will be more efficient or using Stored Procedure or using any third party tool.

Efficient in the sense when it is to be searched among large set of data which one will be the fastest?

Best Answer

Most likely this should be done with SQL. This would be simpler and have better performance.

But would depend on a few details. Especially how exact or complicated you want it to be able to find the information the user typed in (maybe a list of available areas would be a better ui option here)

You could do a simple search like:

SELECT * FROM areas WHERE name LIKE 'input%';

This would of course fail for any typo the user makes and maybe return several records and you would have to offer the user further options to select one of those.

Assuming at some point you found a single record, it should be simple to find restaurants by area_id.