473,378 Members | 1,175 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

difference between primary&secondary files

For creating a user database three important files named primary, secondary & transaction log files. so my question is 'what is the difference between primary & secondary files?' and is 'what is the necessity of secondary files?'
Feb 1 '08 #1
2 7547
jagged
23
For creating a user database three important files named primary, secondary & transaction log files. so my question is 'what is the difference between primary & secondary files?' and is 'what is the necessity of secondary files?'
Most of the time I only use the primary file groups. I do have some apps that use partitioning to move data to a secondary file group (which is stored on another disk) essentially to archive data that is X number of days old. In this case, and very simply put, querying the newest data (less than X days old) and the archived data together will be faster (than if only one disk was used) because I have two disks to share the workload.

There are also ways to recover data from only specific file groups. Using the same "setup" as above, if the server were to crash, I can recover and restore the application using the last X days of data a lot faster than if I had to recover ALL of the data (which could run into hundreds of gigs). Most of the time, people can wait until Monday to see data from 2002 but most people can't wait for info from yesterday.

Simple examples, but it gives you a basic idea.
Feb 22 '08 #2
ck9663
2,878 Expert 2GB
Start here first.

Here's some write ups I pick up here and there...


You can group data files for a database together into filegroups for allocation and administration purposes. In
some cases, you can improve performance by controlling the placement of data and indexes into specific
filegroups on specific disk drives.

.. Primary filegroup This filegroup contains the primary data file and any files not put into another specific
filegroup. All pages from system tables are always allocated from files in the primary filegroup.

.. User-defined filegroup You can create user-defined filegroups by using the FILEGROUP keyword in the
CREATE DATABASE or ALTER DATABASE statement.

.. Default filegroup This filegroup contains the pages for all tables and indexes that aren't placed in a
specific filegroup. Only one filegroup in each database can be the default filegroup. A database owner can
change which filegroup is the default by using the ALTER DATABASE statement. If no default filegroup
was speci-fied, the primary filegroup is also the default filegroup.


Why do you need more than one filegroups?


If you need to restore a database from a backup because of a disk crash, you should be aware
that the new database must contain the same number of files as the original. For example, if your
original database consisted of one large 12-GB file, you would need to restore it into a database
with one file of that size. If you don't have another 12-GB drive immediately available, you won't
be able to restore the database! If, however, you originally created the database on several smaller
files, you have added flexibility during a restoration. You might be more likely to have several 4-
GB drives available than one large 12-GB drive.

Spreading the database onto multiple files, even onto the same drive, gives you the
flexibility of easily moving the database onto separate drives if you modify your hardware
configuration in the future. Microsoft's internal SAP system uses a SQL Server 7 database created
on 12 files. Microsoft thought this would give it the ultimate flexibility. They could separate the
files into two groups of six, six groups of two, four groups of three, and so on. This allows them to
experiment with performance enhancements gained as files are spread over different numbers of
physical drives.


-- CK
Feb 22 '08 #3

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

Similar topics

13
by: Mattias Campe | last post by:
Hi, Depending on if I get an image or a text of a certain URL, I want to do something different. I don't know in advance whether I'll get an image or a text. This is a URL that returns an...
0
by: jasper | last post by:
hi, i am trying to make a very simple program that will just detect and output your currently connected IDE devices. It will look something like this: IDE PRIMARY MASTER: IDE PRIMARY SLAVE:...
11
by: BoonHead, The Lost Philosopher | last post by:
I think the .NET framework is great! It's nice, clean and logical; in contradiction to the old Microsoft. It only saddens me that the new Microsoft still doesn't under stand there own...
4
by: rajender_4 | last post by:
Hi techies I have set up a Transaction replication from My Primary Server to Secondary Server on Orders table. Thousand of records gets inserted on Orders every hour which get replicated...
1
by: Lynn.Tilby | last post by:
I am running an experimental system, my disk filled up when running a table build from a query. I mistakenly blew away the files in .../pgsql/data/base/18773 & ../pgsql/data/pg_xlog with NO BU!...
8
by: Martin Maat | last post by:
I am puzzled. I have this object that uses a thread. The thread is encapsulated by the object, the object has Start and Stop methods to enable the client to start or stop the thread. I found...
4
by: rn5a | last post by:
I have a ListBox which should list all the files & directories that exist in a particular directory. The problem is I can get the ListBox to list either all the files or all the directories but not...
1
by: titan.nyquist | last post by:
"At the implementation level, the primary difference is that C# generic type substitutions are performed at runtime and generic type information is thereby preserved for instantiated objects." -...
3
by: KimberlyM | last post by:
This has been driving me crazy. I hope someone can help. The site displays perfectly in FF but all div's do not show in IE. Please help me find the problem! Thanks! Here is my css. ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.