SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Add Data files dynamically based no of cpu's


Add Data files dynamically based no of cpu's

Author
Message
@SQLFRNDZ
@SQLFRNDZ
Hall of Fame
Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)

Group: General Forum Members
Points: 3989 Visits: 1228
Here is the scenario:

Step1: Verify number of CPU's
SELECT cpu_count FROM sys.dm_os_sys_info

Step2: Verify number of Datafiles
select COUNT(*)-1 from tempdb.sys.sysfiles

Step 3: If Count in steps and step2, we need add additional files using t-sql ?


Can I get help with script please ?


--SQLFRNDZ

SQLRNNR
SQLRNNR
SSC Guru
SSC Guru (111K reputation)SSC Guru (111K reputation)SSC Guru (111K reputation)SSC Guru (111K reputation)SSC Guru (111K reputation)SSC Guru (111K reputation)SSC Guru (111K reputation)SSC Guru (111K reputation)

Group: General Forum Members
Points: 111924 Visits: 18624
Are these the only considerations for this script? Or do you also want to adhere to BP recommendations as can be found here?



Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server, MVP


SQL RNNR

Posting Performance Based Questions - Gail Shaw

@SQLFRNDZ
@SQLFRNDZ
Hall of Fame
Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)

Group: General Forum Members
Points: 3989 Visits: 1228
Yes, I need only the script..Appreciate your help!


--SQLFRNDZ

GilaMonster
GilaMonster
SSC Guru
SSC Guru (417K reputation)SSC Guru (417K reputation)SSC Guru (417K reputation)SSC Guru (417K reputation)SSC Guru (417K reputation)SSC Guru (417K reputation)SSC Guru (417K reputation)SSC Guru (417K reputation)

Group: General Forum Members
Points: 417440 Visits: 47141
Err...bad idea. Really bad idea.

One file per core is an old recommendation, it's not a good idea under all circumstances without consideration or investigation.
http://www.sqlskills.com/BLOGS/PAUL/post/A-SQL-Server-DBA-myth-a-day-%281230%29-tempdb-should-always-have-one-data-file-per-processor-core.aspx

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


@SQLFRNDZ
@SQLFRNDZ
Hall of Fame
Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)

Group: General Forum Members
Points: 3989 Visits: 1228
I knew it is bad practise for tempdb but want to see how we can write a query to dynamically add files based on a condition.


--SQLFRNDZ

SQLRNNR
SQLRNNR
SSC Guru
SSC Guru (111K reputation)SSC Guru (111K reputation)SSC Guru (111K reputation)SSC Guru (111K reputation)SSC Guru (111K reputation)SSC Guru (111K reputation)SSC Guru (111K reputation)SSC Guru (111K reputation)

Group: General Forum Members
Points: 111924 Visits: 18624
Well, what have you got for your script so far?



Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server, MVP


SQL RNNR

Posting Performance Based Questions - Gail Shaw

@SQLFRNDZ
@SQLFRNDZ
Hall of Fame
Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)

Group: General Forum Members
Points: 3989 Visits: 1228
SQLRNNR (12/20/2012)
Well, what have you got for your script so far?



This is what I got so far and I need help with looping script to add files to number of times based on condition cpu_count.

Here is the script I'm able to write so far

DEclare @value1 int
DEclare @value2 int
DECLARE @OUTPUT Varchar(100)
select @value1=COUNT(*)-1 from sys.sysfiles
SELECT @value2=cpu_count FROM sys.dm_os_sys_info
select @OUTPUT =
Case when @value1 = @value2 THEN 'GoodToGo'
ELSE "-- Needs a Script Here --"
END
SELECT @OUTPUT [TEMPDB FILES]
GO


--SQLFRNDZ

SQLRNNR
SQLRNNR
SSC Guru
SSC Guru (111K reputation)SSC Guru (111K reputation)SSC Guru (111K reputation)SSC Guru (111K reputation)SSC Guru (111K reputation)SSC Guru (111K reputation)SSC Guru (111K reputation)SSC Guru (111K reputation)

Group: General Forum Members
Points: 111924 Visits: 18624
@SQLFRNDZ (12/20/2012)


This is what I got so far and I need help with looping script to add files to number of times based on condition cpu_count.

Here is the script I'm able to write so far

DEclare @value1 int
DEclare @value2 int
DECLARE @OUTPUT Varchar(100)
select @value1=COUNT(*)-1 from sys.sysfiles
SELECT @value2=cpu_count FROM sys.dm_os_sys_info
select @OUTPUT =
Case when @value1 = @value2 THEN 'GoodToGo'
ELSE "-- Needs a Script Here --"
END
SELECT @OUTPUT [TEMPDB FILES]
GO


Ok, from there - what would you pseudo-code to achieve your goal?



Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server, MVP


SQL RNNR

Posting Performance Based Questions - Gail Shaw

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