May 6, 2008 at 8:34 am
Dear All,
I have one senario.
which one is performance wise good ?
Way 1:
Create Table #Calculation
(
Pm varchar(25) NULL,
Mgr varchar(10) NULL,
month int Null,
year int Null,
monthEnd datetime Null
)
Way 2:
Create Table #Calculation
(
Pm varchar(25) Default '',
Mgr varchar(10) Default '',
month int Null Default 0,
year int Default 0,
monthEnd datetime Null
)
Inputs are welcome !
karthik
May 6, 2008 at 10:15 am
I suppose the default might technically incur slightly more resources to find the default and add it to the table (not sure if this is done inline or in a trigger-like operation), but it would be noise.
The decision to set a NULL or default isn't a performance related one. It's an integrity/design issue.
May 6, 2008 at 12:35 pm
It's not really a question of performance. Either one will be about as fast as the other. It's a question of what do you want in your database, and what does it mean.
Null normally means unknown data. Zero length strings usually mean you know what the data is, and it's nothing.
A common example is middle names. If a person has a first name and a last name and no middle name, you'd put a zero-length string (like your second example) in the middle name. If you don't know whether a person has a middle name or not, you'd put Null.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
May 7, 2008 at 7:24 pm
NULL is a kind of wildcard.
If you run "DIR *.*" you get list of all files with any name and any extention.
But if you run "DIR *. " you get list of files havin NO extension, because you specified empty string as an extension.
Hope my explanation is easy enough even for M.C.A.
:hehe:
_____________
Code for TallyGenerator
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply