Is there a rul开发者_Go百科e of thumb that allows you to roughly calculate the space taken up by a single record according to the data types it contains? Also, does MySQL use optimization of any sort?
You can use the output of SHOW TABLE STATUS to determine it. Although it depends on the engine.
You will need to insert a number of rows (I'd recommend at least 10,000) to get realistic results; the result will also depend on the exact data, as most tables will have variable-length records.
Yes, there are several optimisations depending on the engine and its configuration. InnoDB (some versions) supports page compression if you enable it. MyISAM doesn't compress its data but does do index packing, which achieves much smaller indexes than would be otherwise possible.
精彩评论