Home > Mobile >  Is it fine for server to search from millions of rows in MySQL using PHP or use third party's A
Is it fine for server to search from millions of rows in MySQL using PHP or use third party's A

Time:10-28

My client has a website built in PHP. There is a form where user has to put name and address of a person. after that request goes to the database and fetch rows having exact same name and address.

A sample query given below (Actual query is in prepared statement.):

SELECT * FROM clients WHERE name='$name' AND address='$address' LIMIT 1

So I just want to know that is it fine for the server to search from MILLIONS of rows? As there may be multiple users searching at the same time. Or I've to use third-party's database for better performance.

Any suggests for third party? (My client is looking for "cloudtables" but I have doubt in it.)

Pardon me for any mistakes as it's my first question on StackOverflow! Thanks in advance.

CodePudding user response:

if you want exact search on name and address than this is ok. but if you want search on random input than you should try the PHP LIKE query.

CodePudding user response:

If you are testing both with =, then be sure to have

INDEX(name, address)

That applies regardless of whether you create the table or a 3rd party does. The query will be very fast.

If you switch to LIKE with a leading wildcard, the index won't be useful; it will take a long time to wade through millions of rows.

  • Related