Hi,
we are using SQL 2008 with a dedicated drive respectively for user db, temp db and the transaction log. Analysis shows that temp db is almost never used, while the drive of the user db sometimes has some nasty peaks in the queue, so I'd like to split the user db in half and put one part on the drive of temp db.
What would be the simplest way to do this?
Thanks
Alex
0
Comments
If you already have the database, adding new file won't do any good. New file will not be used, unless you add some new tables.
You cannot force table to use particular file, unless you create a separate filegroup, define a file in new filegroup, and then issuing some ALTER TABLE statement forcing it to be moved to the new filegroup. In theory you can do the same with indexes - put them to separate filegroup. But believe me - you do not want to do this
There is another technique called table partitioning, where you can split table across different files, but this again requires configuration files in separate filegroups. Again - not a simple thing to do (with NAV tables) and probably not worth the efforts to configure and administer to get some benefits.
The simplest solution I can think of is to backup database using native NAV backup, delete SQL database, create new one with two or more files (can be in the same filegroup), then restore database from native NAV backup.
According to my experience tempdb is used, and quite heavily, but it is not a constant load, but rather short and high spikes. It is rather hard to observe. But WHEN tempdb is used SQL can really push the storage where file is located to its limits.
If you really believe (or just know) your tempdb disk is not used to make some good use of it you may want to dump SQL backup onto it, if you don't already have another separate disk configured for that purpose. If data disk and tempdb disk are really separate physical disks this will speed up your backup significantly.
Slawek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
BTW, we have very few write transactions, hence the low use of tempdb.
I must correct myself: Actually all data files must be in the same default filegroup (Data Filegroup 1) if SQL is supposed to create tables in different files when Nav native backup is restored.
Regards,
Slawek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
Regards,
Slawek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
Not sure I agree with the above, as I work with a system that seems to contradict this. The database is around ~320 GB used and is split across 3 even-sized datafiles. The vast majority of data is contained within only a few files. Two tables alone account for 50% of the database. Based on the above statement I would expect the used portion of each file to be uneven. However when I check the used space,they are within 70 MB (.6%) of each other.
Regards,
Slawek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
160GB / 2 = 80GB (per table)
320GB /3 = 120GB (The database is around ~320 GB used and is split across 3 even-sized datafiles)
80GB (table size) < 120 GB (data file size)
It looks for me that single table can perfectly fit in single data file... Even without using data compressions.
SQL does not warrant you that all files will be filled equally. When you create new table SQL server simply picks least used data file. Once table is created in some file all table data is pushed to that file.
The example you've given doesn't contradict, but either doesn't prove anything.. It is just one of many possible cases in my opinion.
Regards,
Slawek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
You can also use it to spread a database from 1 to multiple files.
1. Create the additional files (same filegroup)
2. Run DBCC SHRINKFILE with the EMPTYFILE argument onoriginal file
3. Drop original file.
Each data file is 125 GB with 103.19 GB, 103.14, and 103.21 used respectively. The two files in question are 90 GB and 92 GB respectively.
For arguments sake lets' say that each of these tables is in its own file (based on size and what you've said above) and that the remianing tables are mostly in the third file. Given this situation would you not expect system I/O activity to be uneven across the three files?
It's not.
From BOL:
I have a slightly smaller copy of the DB mentioned above. It's 3 files have 99.36 GB, 99.31 GB, and 99.36 GB used. If I were to drop one of the larger tables, would we then expect to see all (or most) of the new free space gained in one file?
Thoughts?
1. Prior to starting the used space on each file was 99.36 GB, 99.31 GB, and 99.36 GB respectively.
2. I then dropped the indexed views for the table.
3. Checking used space it was now 99.31 GB, 99.26 GB, and 99.31 GB respectively
4. I then dropped the table
5. Checking used space it was now 71.05 GB, 71.01 GB, and 71.07 GB respectively
Thoughts?
I was pretty sure that I've read some documents about SQL I/O engine, stating that pages are allocated in extents from the same file. I couldn't find it unfortunately, but it looks like the document was incorrect, or, most likely, I remembered it incorrectly.
In that case simply adding second file, and rebuilding clustered indexes on biggest (or all) tables should spread data (at least some of it) across two files. And definitely adding two or more files and emptying first one (DBCC shirinkfile(.. EMPTYFILE)) will also do the trick
Kind regards,
Slawek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03