Re: Perfromance issue

Tech-Archive recommends: Speed Up your PC by fixing your registry



Although I agree with Andrew in his response, entirely, there are some
things for you to watch out for that he didn't mention; I assume because he
wanted to stress the importance of data type selection based on its own, not
for performance reasons.

With that said, however, there are performance differences. CHARs are
fixed-width, so there is no needed overhead to maintain them. VARCHARs on
the other hand are variable, and that variability must be managed. That
does introduce a small performance hit on the system. That impact is the
same regardless of the length of the VARCHAR definition. Basically, you
have to leave space in a secondary attribute that basically tells you how
long any particular one value is. This is not necessary for CHARs because
the definition is sufficient. However, this has nothing to do with
indexing, this is just an artifact of the data type.

Also, depending on the ANSI_PADDING settings, both VARCHARs and CHARs will
handle "short" values (those where the length does not match the definition)
differently, from each other as well as determinant on the current
ANSI_PADDING setting.

As far as indexing is concerned, there is no explicit performance overhead
difference between the two data types. However, implicitly, with CHARs, you
will get a uniform fill of the index pages because that data type is
fixed-width. VARCHARs, on the other hand, will vary; thus, their index
pages will contain varying number of rows. This too is determinant on the
current Cluster Index definition, since all non-clustered index also save
the corresponding cluster-index values needed for the Bookmark Lookups.

With that said, it would be difficult to say whether or not a consistent
page fill would have a performance impact or not. That would depend on what
queries are being executed that would make use of such indexes as well as
whether or not the Clustered Index definition was fixed-width or varying.

To support what Andrew advised, the determination of either VARCHAR or CHAR
is base on the data definition, not the performance impact: you either have
fixed-width data or varying.

Sincerely,


Anthony Thomas


--

"Andrew J. Kelly" <sqlmvpnooospam@xxxxxxxxxxxx> wrote in message
news:%23oaAnihyFHA.664@xxxxxxxxxxxxxxxxxxxxxxx
> Not sure what you are asking. Are you asking if you should use a char or
a
> varchar for performance reasons? If so then that is not the way to
> determine a datatype. You need to use the proper datatype for the data
you
> are storing. Chars and Varchars are not the same thing and should not be
> used interchangeably. Maybe you can provide more info so we can give a
> better reply.
>
> PS: This newsgroup is not related to indexes, it is for Failover
> clustering. You may want to try .programming or .server next time for a
> more appropriate audience.
>
> --
> Andrew J. Kelly SQL MVP
>
>
> "charlie" <charlie@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:284F4306-B406-4F09-81AA-B475E2BF09F0@xxxxxxxxxxxxxxxx
> > For a non-clustered index, would it have a performance difference
between
> > varchar(20) and char(20) , using only either one of them.
> >
> > thx!!!
>
>


.



Relevant Pages

  • Re: Table fields of type MEMO are chunked cause of DISTINCT
    ... Contents in table fields of data type "memo" are chunked to a length of max ... 255 chars, if the fields are delivered by a query having the key word ... WHERE BUGS CAN BE REPORTED TO MICROSOFT? ...
    (microsoft.public.access.queries)
  • Re: Spaces consume room?
    ... This is a matter of data type in the table. ... the field is filled with trailing spaces to the size. ... > I have an ISA server logging to a SQL server. ... > get to 255 chars. ...
    (microsoft.public.sqlserver.programming)
  • Re: NVL changing data type of a datetime?
    ... I've played some more with datetimes and also char columns and it seems ... the data type returned is that of the first argument. ... IDS 9.40.UC7 behaves the same way as it does for chars, ... it would be sensible to assume that the writing is on the wall - and fix your code to use CURRENT YEAR TO SECOND instead of just CURRENT. ...
    (comp.databases.informix)
  • Re: NVL changing data type of a datetime?
    ... I've played some more with datetimes and also char columns and it seems ... no matter which way round the arguments are and no matter which is null ... the data type returned is that of the first argument. ... IDS 9.40.UC7 behaves the same way as it does for chars, ...
    (comp.databases.informix)
  • export to text file problem
    ... I recognise that long varchars are cut when exported to the text file. ... This is the scenario: ... The length of the string in the text file is only 232 chars. ...
    (microsoft.public.sqlserver.server)