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 <[email protected]>
Gerrit-Reviewer: Alon Bar-Lev <[email protected]>
Gerrit-Reviewer: Barak Azulay <[email protected]>
Gerrit-Reviewer: Eli Mesika <[email protected]>
Gerrit-Reviewer: Juan Hernandez <[email protected]>
Gerrit-Reviewer: Martin Peřina <[email protected]>
Gerrit-Reviewer: Moti Asayag <[email protected]>
Gerrit-Reviewer: Yair Zaslavsky <[email protected]>
Gerrit-Reviewer: Yaniv Bronhaim <[email protected]>
Gerrit-Reviewer: mooli tayer <[email protected]>
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: No
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches