sql - Is converting database string enums to integers worth it? -



sql - Is converting database string enums to integers worth it? -

there 2 ways store enum types in database: string or integer.

saving enumeration ( sex = {male,female}, account_type = {regular,pro,admin}, etc. ) strings makes things more readable requires more space integers.

on other hand, integers require mapping enums in , out of database. benefit, case-sensitivity handled outside of database integers.

assuming both indexed, doing integer conversion worth it? how much faster lookup integers?

example

perhaps concrete illustration help visualize things. lets take above account_type database of 100,000 users.

string enum

assuming 8-bit fixed length char type

7*100000*8/8 = 700000 bytes

integer enum

assuming 8-bit tinyint integers

100000*8/8 = 400000 bytes

seems size half integer enums. need concider indexes.

the reply is, expect, depends.

the larger database more important space savings - not on disk in network io , computation.

personally, store integers instead of textual values, unless there direct db supprt enumerations (as mysql does).

sql enums database-agnostic

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -