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
 General SQL Server Forums
 Database Design and Application Architecture
 Tables or Create View?

Author  Topic 

oguzkaygun
Yak Posting Veteran

53 Posts

Posted - 2009-12-01 : 15:05:10
Hello
i use MSSQL2005 and MSSQL2008. if i work with a lot of records (for example 1.000.000 or 2.000.000 or more), what i should i do ?
Firstly Should i use one table for each company ?
Second Should i use "create view" and i use only one table for a lot of company ?

Note: My design is for financel software.
Thanks

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-12-01 : 15:25:27
1 or 2 million rows in a table is not big at all. Do not bother partitioning on such a small table. I wouldn't recommend partitioning physicall via a table for each company, but rather when you do get into 500 million rows or more use table partitioning feature provided by SQL Server.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://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."
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-12-01 : 15:26:09
Also, ensure you setup the appropriate indexes on your tables so that your performance is good. You don't want to scan a table with that many rows, so you want seeks via indexes.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://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."
Go to Top of Page

oguzkaygun
Yak Posting Veteran

53 Posts

Posted - 2009-12-02 : 01:49:13
Hello
Thanks for your reply.
Partions means that "Create View"?
Thanks
Go to Top of Page

jackv
Master Smack Fu Yak Hacker

2179 Posts

Posted - 2009-12-02 : 01:50:24
Focus on design , at this point , i.e relational principles and optimising the SELECT statements. As well as indexes mentioned , ensure there is sufficient ( and appropraite) maintenance on the indices - by this I mean : statistics , fragmentation levels

Jack Vamvas
--------------------
http://www.ITjobfeed.com (IT jobs)
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-12-02 : 01:53:21
quote:
Originally posted by oguzkaygun

Hello
Thanks for your reply.
Partions means that "Create View"?
Thanks



No I am referring to partitioned tables which is a technology available in SQL Server 2005 and 2008. You should look into partitioning once your table gets to the 500 million range. Whatever you do, do not create a table for each company. SQL Server can handle the load in just one table. You just need to design your indexes and queries properly.

I don't think I'd use views for what you've described. I'd just use a stored procedure that has an input parameter for the company and then use that input parameter in your WHERE clause.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://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."
Go to Top of Page

jackv
Master Smack Fu Yak Hacker

2179 Posts

Posted - 2009-12-02 : 01:53:21
The decision for the VIEW is dependant on how you want to manage the retrieval of the the data , for example , you may have a complex structure , which may require some streamlining , or may want to release access to the data , but not allow developers th view the underlying select statements

Jack Vamvas
--------------------
http://www.ITjobfeed.com (IT jobs)
Go to Top of Page

oguzkaygun
Yak Posting Veteran

53 Posts

Posted - 2009-12-03 : 04:54:40
Hello

i have two question.
Firstly. If i create new coulums and new sql query (select, insert, update or delete) after i have done partition, Should i do partition again. Or my partition will see my new coulums and my new sql query. Also i can create new table too.
Second. When i done tree partition (company id =1 one partition,company id=2 second partition, company id=3 third partition), can i see all records more fast with select query ? Or can i see only partition1 or partition2 or partition3 more fast with select query?
Should i use Select * from Table1
or should i use Select * from table where companyid='1' ?

Thanks
Go to Top of Page
   

- Advertisement -