Arien vs. The World

Posts Tagged ‘performance

When I started studying for the MySQL Certification Exam I thought the first chapters of the book would be rather boring. But at least that didn’t happen with chapter 5, which talks about data types. I have probably been lazy on reading the documentation of the last versions of MySQL (or all versions in general), but I did learn a lot in this chapter.

For example, I thought the VARCHAR type could only hold up to 255 characters on MySQL. And welllllllll… That was true until the version 5.0.3, which allowed VARCHAR to hold up to 65.535 characters. That’s quite a huge leap, and I really wasn’t aware of it, pfff. I usually take TEXT as the field type when I have something that might be bigger than 255 characters, but from now on, VARCHAR it is!

Also, I saw that DATETIME fields take a lot of space compared to the other temporal types… It’s cheaper to store DATE and TIME separatedly, heh. Oh well, that’s another mistake I won’t make again.

I also learned a bit more about collations and differences between them (binary or non-binary, case (in)sensitive, etc). I always kind of wondered why we were using this and not that collation but wasn’t curious enough to look for the answer or ask about it. Now I know, and the book explanation is great.

But it wasn’t all about new things for me. Fortunately I could recognize most of the things I read on this chapter, so I didn’t feel like a complete ignorant :P. For example, I knew a great deal about the SET type, since I’ve used it before, and how it differs from ENUM fields. One funny thing that someone mentioned when we were checking our exam answers today was, that ENUM fields can hold so many members that it would be easy to add the names of all the towns in Spain into one of these. There was a general LOL about it, but after that session I was looking up some VARCHAR vs CHAR debate information and found this post on the MySQL Performance Blog. Turns out his idea isn’t really that crazy (performance-wise, at least).

Talking about VARCHAR vs CHAR, I was also successfully able to explain why CHAR might be better in some cases than VARCHAR (even if it takes more space). This wasn’t explained in this chapter and I found it weird, but I’m glad we got to talk about it, generated a nice debate for the peeps remaining in the class (some had left already) and nice conclusions.

Ah well, from this chapter I’ve learned and shared my knowledge and I’ve had quite some fun reading it. And I definately won’t let all these little pearls go to waste. From now on, I’m going to be more careful when I create new tables. The next step will be to learn to create better queries (or maybe find out that the ones I write are already super efficient… but that’s wishful thinking :P).

I hope the rest of the book is as interesting or more. This was about the best thing that happened today at work and I want it to stay fun and challenging!

Advertisements

Tweet-tweet

Categories

December 2017
M T W T F S S
« May    
 123
45678910
11121314151617
18192021222324
25262728293031