By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,853 Members | 1,034 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,853 IT Pros & Developers. It's quick & easy.

Which will give me better performance (Table design for Joins)

P: 20
I have two tables Users and UserLogin. Here i will use two methods of table design. and which query will return me the result more fast.
The table size will be large that it may contain records in lakhs.

Method 1:
Tables:
Users ( UserID varchar(20) primary key, PassWord varchar(20))
UsersLogin(UserID varchar(20),LoginDate DateTime)
Query:
Select Users.UserID,UsersLogin.LoginDate
from Users U inner join UsersLogin UL
on Users.UserID = UsersLogin.UserID
Method 2:
Tables:
Users ( SysUserID Integer primary key,UserID varchar(20), PassWord varchar(20))
UsersLogin(SysUserID Integer, LoginDate DateTime)
Query:
Select Users.UserID,UsersLogin.LoginDate
from Users U inner join UsersLogin UL
on Users.SysUserID = UsersLogin.SysUserID
Here for the seccond method i made SysUserID additional which will be a system generated ID, and for joins which will give better performance.
Feb 26 '07 #1
Share this Question
Share on Google+
1 Reply


ronverdonk
Expert 2.5K+
P: 4,258
You can find that out by using the EXPLAIN SELECT ... in MySQL and study the results for each table.

Ronald :cool:
Feb 26 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.