Scenario 1
I have one table lets say “member”. In that table “member” i have 7 fields ( memid,login_name,password,age,city,phone,country ). In my table i have 10K records.i need to fetch one record . so i’m using the query like this
mysql_query("select * from member where memid=999");
Scenario 2
I have the same table called “member” but i’m splitting the table like this member and member_txt .So in my member_txt table i have memid,age,phone,city,country )and in my member table i have memid,login_name,password .
Which is the best scenario to fetch the data quickly? Either going to single table or split the table into two with reference?
Note: I need to fetch the particular data in PHP and MYSQL. Please let me know which is best method to follow.
we have 10K records
For your own health, use the single table approach.
As long as you are using a primary key for
memid, things are going to be lightning fast. This is becausePRIMARY KEYautomatically assigns an index, which basically tells the exact location for the data and eliminates the need to go through data that it would otherwise do.From http://dev.mysql.com/doc/refman/5.0/en/mysql-indexes.html
Your second approach only makes your system more complex, and provides no benefits.
Use the scenario 1.