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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 when to clone database tables

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2007-01-24 : 08:17:35
ryan writes "Question simple: (question in detail below)
When is it more efficient to break a multi-million row table into seperate tables

i.e
instead of:
table

it would be

table1
table2
table3

And what is the best way to query these tables(ie variable named tables using stored procedures:

ie:
Exec sp_executesql

or

schema_table_name=@procparamtablename
(if this is the case would appreciate a example using joins)




Questions Details:
Hello

I am in the middle of building a real estate website. In the backend there is a realtor section and each relator can have a contact list via pkid->fkid. Each realtor belongs to a company

The contact list could potentially get over 5 million records. I know ms-sql 2005 can handle this but I would like to make it as efficient as possible

Right now contacts are stored in a table called contacts with a foreign key to the company the realtor belong to they belong to:


My thinking was to split the contact table into seperate tables based on the company id:

contact(table)1
contact(table)2


And what is the best way to query these tables(ie variable named tables using stored procedures:

ie:
Exec sp_executesql

or

schema_table_name=@procparamtablename
(if this is the case would appreciate a example using joins)"

mwjdavidson
Aged Yak Warrior

735 Posts

Posted - 2007-01-24 : 10:38:19
You imply it's a 2005 database. In that case, lookup "Partitioned Tables and Index" in Books Online. However, 5m rows is not really a huge number, and I wouldn't necessarily advise doing it for the sake of it. First consider the queries that will be run against this table, and how sensible indexing will help. Definitely don't go down the proposed route of having separate physical tables referenced via dynamic sql!

Mark
Go to Top of Page
   

- Advertisement -