I have a search feature on my website where i want to search for users and display the user's first name, last name, and email. what is the fastest way to do that?
My table is:
id first name last name email
0 john bay johnbay123@gmail.com
1 bob lof boblof123@gmail.com
2 bob mask mattmask123@gmail.com
I have many other rows/users, like 10,000.
For example, the user searches for "bob". what is the fastest way to search the database for "bob" and display each user's first name, last name, and email?
You can create a View for the required columns from your Table, you need not include all the columns here.
CREATE VIEW vw_yourTable as SELECT *required columns* FROM #YourTable
Then you can create indexes on your search columns of your view. This will enable you to search faster using your view, however, it will not impact your INSERT queries on your primary Table.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.