how to improve speed in database?

jay padaliya

I am starting to create my first web application in my career using mysql.

I am going to make table which contain users information (like id, firstname, lastname, email, password, phone number).

Which of the following is better?

  1. Put all data into one single table (userinfo).

  2. Divide all data by alphabet character and put data into many tables. for example, if user's email id is [email protected] that put into table (userinfo_j) and if user's email id is [email protected] that put into table (userinfo_k).

Neville Kuyt

I don't want to sound condescending, but I think you should spend some time reading up on database design before tackling this project, especially the concept of normalization, which provides consistent and proven rules for how to store information in a relational database.

In general, my recommendation is to build your database to be easy to maintain and understand first and foremost. On modern hardware, a reasonably well-designed database with indexes running relational queries can support millions of records, often tens or hundreds of millions of records without performance problems.

If your database has a performance problem, tune the query first; add indexes second, buy better hardware third, and if that doesn't work, you may consider a design that makes the application harder to maintain (often called denormalization).

Your second solution will almost certainly be slower for most cases.

Relational databases are really, really fast when searching by indexed fields; searching for "email like '[email protected]'" on a reasonable database will be too fast to measure on a database with tens of millions of records.

However, including the logic to find the right table in which to search will almost certainly be slower than searching in all the tables.

Especially if you want to search by things other than email address - imagine finding all the users who signed up in the last week. Or who have permission to do a certain thing in your application. Or who have a @gmail.com account.

So, the second solution is bad from a design/maintenance point of view, and will almost certainly be slower.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

TOP Ranking

HotTag

Archive