mooli tayer has posted comments on this change.

Change subject: tools: Refactor model and DB mapping of 
eventNotificationMethods.
......................................................................


Patch Set 17:

I'm having a hard time deciding between using an enum or a string to store enum 
values in the db in general.

Considerations:
a. standardization: 
SQL enums are not standard ANSI and implemented differently between databases. 
another implication of this is having to state every enum col in 
PostgresDataTypeFactory.isEnum() or dao tests won't work.

b. data consistency 
This is a plus one for enums since it's out of the box(tough they must be 
declared as not null - if a value is a must).
for strings we can do:
notification_method TEXT CHECK (notification_method IN ('EMAIL', 'SNMP_TRAP'))
);

c. space
an enum record is 4 bytes in postgres[1].

a string is a little more complex to calculate;

we use UTF-8 by default which is a variable-width encoding taking up 1-4 
Bytes[2] per char. let's assume the number of chars is defined as varying(128) 
[3]. and that our actual enum is taken from what we will have in snmp-notifier:
public enum EventNotificationMethod {
    EMAIL,
    SNMP_TRAP
}
len(bytes for basic Latin and _) is 2 in UTF-8 . also we need to add one byte 
varying end mark. For average I assume even distribution.

we get:
min = len('EMAIL') * 2 + 1 = 11 bytes
max = len('SNMP_TRAP') * 2 + 1 = 19 bytes
average = 15 bytes

[1] http://www.postgresql.org/docs/9.1/static/datatype-enum.html
[2] http://www.postgresql.org/docs/9.0/static/multibyte.html    
[3] I would prefer variable-width over fixed to allow addition of new types 
with out changing the length definition but another option is to define int as 
fixed as the longest existing enum name.

Thanks to Ofrenkel for bringing a to mind.

-- 
To view, visit http://gerrit.ovirt.org/22135
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I8b71c4e78bbdca3d02d2ac4ef419b9d3d7d58761
Gerrit-PatchSet: 17
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: mooli tayer <mta...@redhat.com>
Gerrit-Reviewer: Alon Bar-Lev <alo...@redhat.com>
Gerrit-Reviewer: Barak Azulay <bazu...@redhat.com>
Gerrit-Reviewer: Eli Mesika <elimes...@gmail.com>
Gerrit-Reviewer: Juan Hernandez <juan.hernan...@redhat.com>
Gerrit-Reviewer: Martin Peřina <mper...@redhat.com>
Gerrit-Reviewer: Moti Asayag <masa...@redhat.com>
Gerrit-Reviewer: Yair Zaslavsky <yzasl...@redhat.com>
Gerrit-Reviewer: Yaniv Bronhaim <ybron...@redhat.com>
Gerrit-Reviewer: mooli tayer <mta...@redhat.com>
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: No
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to