Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


compressing read only file groups


compressing read only file groups

Author
Message
Steve Jones
Steve Jones
SSC-Dedicated
SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)

Group: Administrators
Points: 35903 Visits: 18724
Let me dig around.

Follow me on Twitter: @way0utwestForum Etiquette: How to post data/code on a forum to get the best help
Steve Jones
Steve Jones
SSC-Dedicated
SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)

Group: Administrators
Points: 35903 Visits: 18724
Aha: http://www.sqlservercentral.com/Forums/Topic1511837-391-1.aspx


Follow me on Twitter: @way0utwestForum Etiquette: How to post data/code on a forum to get the best help
Perry Whittle
Perry Whittle
SSCrazy Eights
SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)

Group: General Forum Members
Points: 8775 Visits: 16547
muthyala_51 (1/22/2014)
Steve,

Can you help me to find that article or elaborate on that technique which you are referrring to?

As follows

ALTER DATABASE olddata ADD FILEGROUP newFG



ALTER DATABASE olddata ADD FILE(NAME=somename, FILENAME = 'drive:\path\somefile.NDF', SIZE = 10GB, MAXSIZE = 20GB, FILEGROWTH = 1GB)




CREATE CLUSTERED INDEX [someindex] on schema.table (somecolumn)
WITH (DROP_EXISTING=ON) ON [newFG]




ALTER DATABASE olddata MODIFY FILEGROUP newFG READ_ONLY



-----------------------------------------------------------------------------------------------------------

"Ya can't make an omelette without breaking just a few eggs" ;-)
Nadrek
Nadrek
Ten Centuries
Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)

Group: General Forum Members
Points: 1023 Visits: 2673
I agree with everyone above - if at all possible, use SQL Server Enterprise edition data compression - you just need to be sure every (large) table has a clustered index, then ALTER INDEX ALL with DATA_COMPRESSION = PAGE.

If you do use NTFS compression, use something like http://www.piriform.com/defraggler so you can see not only how many fragments each file in your filegroup is in, but how scattered they are across your disk (assuming contiguous, dedicated, unshared spindles at a SCSI/SAS/SATA/Virtual host/SAN level). NTFS compression is a fiend for fragmenting database files. Once they're read only, they shouldn't change anymore, but you may still want to defragment them, and again if you ever add data to them.

The last NTFS compressed database files I saw were in more than a hundred thousand fragments on the disk for only a few tens of GB of data. Performance was absolutely terrible, unsurprisingly.
muth_51
muth_51
Mr or Mrs. 500
Mr or Mrs. 500 (532 reputation)Mr or Mrs. 500 (532 reputation)Mr or Mrs. 500 (532 reputation)Mr or Mrs. 500 (532 reputation)Mr or Mrs. 500 (532 reputation)Mr or Mrs. 500 (532 reputation)Mr or Mrs. 500 (532 reputation)Mr or Mrs. 500 (532 reputation)

Group: General Forum Members
Points: 532 Visits: 2860
I tested the process quoted by you. It worked fine but the problem is now I can also insert data into read only files.

select name,is_read_only from sys.filegroups

PRIMARY    0
FGDayRange01   1
FGDayRange02   1
FGDayRange03   1
FGDayRange04   1
FGDayRange05   0
FGDayRange06   0

Before Inserts:

total records Partitionnumber
450    3
550    6
50    1
450    4
500    5
450    2

After Inserts:

Total Records   Partition Number
500    3
600    6
50    1
500    4
550    5
500    2

Currently the clustered primary index is created on file group FGDayRange06. I am using the below query to get the total count---

SELECT COUNT(*) AS [Total Records], $Partition.pfFiveDayRange(businessDate) AS [Partition Number]
FROM MSSQLTIPS_Partitions
GROUP BY $Partition.pfFiveDayRange(businessDate);

I am completely bowled by the above scenario. What I am missing? Any suggestions?
muth_51
muth_51
Mr or Mrs. 500
Mr or Mrs. 500 (532 reputation)Mr or Mrs. 500 (532 reputation)Mr or Mrs. 500 (532 reputation)Mr or Mrs. 500 (532 reputation)Mr or Mrs. 500 (532 reputation)Mr or Mrs. 500 (532 reputation)Mr or Mrs. 500 (532 reputation)Mr or Mrs. 500 (532 reputation)

Group: General Forum Members
Points: 532 Visits: 2860
Any suggestions ???
Steve Jones
Steve Jones
SSC-Dedicated
SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)

Group: Administrators
Points: 35903 Visits: 18724
Are you saying you can add data to the partitions that are marked as read-only in the filegroups? It's possible there is a bug here wtih the partitions that doesn't respect the filegroup status.

However a trigger that rejects inserts into those ranges might help.

Follow me on Twitter: @way0utwestForum Etiquette: How to post data/code on a forum to get the best help
muth_51
muth_51
Mr or Mrs. 500
Mr or Mrs. 500 (532 reputation)Mr or Mrs. 500 (532 reputation)Mr or Mrs. 500 (532 reputation)Mr or Mrs. 500 (532 reputation)Mr or Mrs. 500 (532 reputation)Mr or Mrs. 500 (532 reputation)Mr or Mrs. 500 (532 reputation)Mr or Mrs. 500 (532 reputation)

Group: General Forum Members
Points: 532 Visits: 2860
Steve Jones - SSC Editor (2/27/2014)
Are you saying you can add data to the partitions that are marked as read-only in the filegroups? It's possible there is a bug here wtih the partitions that doesn't respect the filegroup status.

However a trigger that rejects inserts into those ranges might help.


YES. I can insert data into read only files. Can you provide more information or any kb article details? Also I am not familiar on how to create triggers on ranges. Thanks...
Jeff Moden
Jeff Moden
SSC-Forever
SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)

Group: General Forum Members
Points: 44847 Visits: 39850
muthyala_51 (1/22/2014)
current size of the database is 2.36 TB. Monthly around 100 GB of data will be added to this partitioned table. We can increase the drive size by adding more space. But I am looking for options to reduce the data size by file compression or data compression.


My recommendation would be to make one of the file groups Read-Write, run REORGANIZE on all indexes, and then see how much free space (not data, not index) there is.

Also, when you set the individual file groups to Read-Only, are you seting the "SINGLE_USER" mode of the database?

--Jeff Moden

RBAR is pronounced ree-bar and is a Modenism for Row-By-Agonizing-Row.
First step towards the paradigm shift of writing Set Based code:
     Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
Although they tell us that they want it real bad, our primary goal is to ensure that we dont actually give it to them that way.
Although change is inevitable, change for the better is usually not.
Just because you can do something in PowerShell, doesnt mean you should. Wink

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
muth_51
muth_51
Mr or Mrs. 500
Mr or Mrs. 500 (532 reputation)Mr or Mrs. 500 (532 reputation)Mr or Mrs. 500 (532 reputation)Mr or Mrs. 500 (532 reputation)Mr or Mrs. 500 (532 reputation)Mr or Mrs. 500 (532 reputation)Mr or Mrs. 500 (532 reputation)Mr or Mrs. 500 (532 reputation)

Group: General Forum Members
Points: 532 Visits: 2860
i am not making the database into single user mode. I just leave the latest partition to read write and change the rest of the filegroups to read only. As paritions are based on date column, all new rows will be inserted into the latest file group.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search