[dba-SQLServer] Is it faster to...

jwcolby jwcolby at colbyconsulting.com
Mon Jun 21 08:35:13 CDT 2010


 > Seeing as you are the only one in these parts with this kind of firing power, you measure it and 
you tell us little guys what results you get :)

ROTFL.

 >and I suppose that indexes on char fields where in effect they are binary, (T or Space), probably 
do not help also.  There is no range to index.

As I understand it, if the records selected are a small proportion of the total then the index is 
used.  So if the total 'T's are in the 5-10% range of the total records (true in many cases), then 
the index is used.

After that the question becomes, is there overhead in storing a null value that is greater than 
storing a space, both in the table and in any indexes for the given field.

I am not sure how indexes work but my guess would be that spaces would be stored in the index 
whereas nulls would not.  Thus the indexes themselves would probably be smaller.  In the table that 
might not be the case since there might be an overhead for storing null values.

So much to learn, so little time.

John W. Colby
www.ColbyConsulting.com


Mark Breen wrote:
> Hello John,
> 
> Two things come to mind,
> 
> a) my initial temptation is to switch this column to a Bit datatype. That
> must be the smallest.
> 
> b) I know that indexes on Binary Values do not help, and I suppose that
> indexes on char fields where in effect they are binary, (T or Space),
> probably do not help also.  There is no range to index.
> 
> So does that suggest you can switch to Bit, and gain a reduction in storage,
> but regardless, your indexes will not help?  Does it even imply that you
> would be better dropping the index on that column?
> 
> Seeing as you are the only one in these parts with this kind of firing
> power, you measure it and you tell us little guys what results you get :)
> 
> Mark
> 
> 
> 
> 
> 
> 
> 
> On 21 June 2010 13:12, jwcolby <jwcolby at colbyconsulting.com> wrote:
> 
>> My "database from hell" has values in columns of 'T' and space, 'T' where
>> the value is "true" and
>> space where the value is false.
>>
>> Would it be useful to replace the spaces with nulls.  Would it be an actual
>> space savings?  Smaller
>> indexes?  Faster compares?
>> --
>> John W. Colby
>> www.ColbyConsulting.com
>> _______________________________________________
>> dba-SQLServer mailing list
>> dba-SQLServer at databaseadvisors.com
>> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
>> http://www.databaseadvisors.com
>>
>>
> _______________________________________________
> dba-SQLServer mailing list
> dba-SQLServer at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
> http://www.databaseadvisors.com
> 
> 



More information about the dba-SQLServer mailing list