Varchars Versus Char Data Types

Question: How much Varchars cost in Performance?

I'd like to be able to take advantage of varchars instead of chars to save on disk space, but I'm concerned about a possible performance loss. How much will varchars cost me?

Answer: Somewhat less Performance with Varchars.

This is one of those "your mileage may vary" answers, but in general, varchars are compressed character fields. Your engine knows where the field starts, but it has to make some calculations in order to find out where the field ends. With fixed-length character fields in your table, it is relatively easy for the engine to parse the row into fields. It's a little more CPU-intensive with varchars, as each field depends upon the amount of data in the varchar.

Ad hoc tests have shown INSERT and SELECT statements costing about 5 percent more with varchars. UPDATES can be more expensive, with additional costs up to 20 percent or so depending upon the amount of page reorganization needed. Some studies have show that DELETES are for some reason a little faster with varchars than with chars. (I'll believe it when I see it.)

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.197.212