Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
albertkohl
Aged Yak Warrior
740 Posts |
Posted - 2009-03-31 : 17:42:40
|
| Okay, so i have two tables that are fairly largetable 1 is about 220 million rowstable 2 is about 50 million rowstable 1 has fname,lname,name,address,city,state,zip,phone as fieldstable 2 has fname,lname,name,address,city,state,zip,phone,email as fieldswhenever a client wants data w/ email, i currently run an inner join from table 1 to table 2 matched on lname,address,zipis there a more efficant way to do this? i was thinking FK's but i've never really messed with them, any time i have data that i need to get between two tables i usually just inner-join them as i need them.Thanks! |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2009-03-31 : 17:47:03
|
| You should not be storing your data like this. Why don't you have one table that has all of these fields and then when the email column isn't NULL or empty, that's how you'd know if they want it via email?Foreign keys are just there to protect the integrity of the data. They do not help you query the data. You still would need to join them even if you had FKs in place.Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/Subscribe to my blog"Let's begin with the premise that everything you've done up until this point is wrong." |
 |
|
|
albertkohl
Aged Yak Warrior
740 Posts |
Posted - 2009-03-31 : 17:51:05
|
| DOH! that's what i was planning on doing, how ever updating a 200 million row table takes a few minutes :-) so i guess i'll just have to do it when we have some down time so we dont mess with production... i know the 1000 rows @ a time method you gave me helps prevent long periods of locking, so i'll probably just have to do that, but over a weekend to minimize it more.Thanks, i just wasnt sure if there was a better way or not. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
|
|
|
|
|