Ticket #2270 (new defect)

Opened 9 years ago

Stop writing default field values

Reported by: gracinet Owned by: gracinet
Priority: P2 Milestone: CPS 3.5.7
Component: CPSSchemas Version: 3.5.1
Severity: major Keywords: performance
Cc:

Description

From bloat to over-bloat…

The basic contract of DataModel is to provide a guaranteed uniform access to document data, so that developers don't have to bother with exceptions and the like. That's why it provides default values for missing fields in the document. Usually an empty string for String Field, etc.

The problem is that these default values end up being stored.

In case the application has lots of fields that are seldom used (that's what I mean with « bloat »), this pollutes each document with lots of empty attributes, that end up as pickles in ZODB. Further, lots of fields usually means that field names are long. Of course, as any attribute would, each field name is part of the pickle. In practice, this can mean storing gigabytes of useless data (just field names and empty strings litterals) and stressing every aspect of the system under this weight. Here's the over-bloat.

There are cases where storing the default value is legitimate. For instance, this is how creation times are initialized. Therefore we need a boolean flag on the field (defaulting to False) to control that behaviour.

Another problem is backwards compatibility. Many third party developers never understood the benefits of DataModel and accessed document attributes directly. Actually they are taking advantage of the work creation-time datamodels had made before hand.

Note: See TracTickets for help on using tickets.