• Hi there,

    We’ve just started using the CCTM for building a new CMS based around WordPress and so far it’s been working beautifully (especially the relation feature for fields), but there’s been a discussion about the way the CCTM handles empty custom fields.

    Basically, say you create a new content type called News with two custom text fields for it, Event and Location.

    If you add a News post, but don’t enter a value for Event and Location, the postmeta table will still be populated with two new rows for the respective post… one for Event and one for Location. The meta_value of which will obviously be empty, because no data was entered.

    The question is: when we’re talking about thousands of News that don’t have data for one field (or even both), won’t these extra “empty value” rows add needless overhead to the table itself and everything that relates to it? (say, the Search).

    And if so, isn’t there a way to stop the CCTM from creating these rows if the custom field is empty when you first add the content type?

    http://wordpress.org/extend/plugins/custom-content-type-manager/

Viewing 1 replies (of 1 total)
  • Plugin Contributor fireproofsocks

    (@fireproofsocks)

    You’re right: this is overhead, and it would make for a good feature request in the bug tracker.

    But if you’re really concerned about overhead, you wouldn’t be using WordPress at all: its database tables are poorly indexed, the pattern between the wp_posts and wp_postmeta tables is flexible but inefficient, and WordPress has no native caching mechanism and no log reporting, its support of custom permalinks is saliently poor, and to cap it off, its architecture is riddled with wonky inefficiencies and incongruent code. In sort, WordPress gets undue attention for “having a clean manager”, but that sounds a lot like bedding a girl for her bra size.

    But really, you’d have to benchmark this to see if it affects your site. MySQL can handle millions and millions of row without blinking provided the tables are well indexed and the server has adequate resources. The number of rows is in most cases a moot point.

    There’s some related discussion here in the Wiki — of particular note here as for cutting down on number of rows — in particular the CCTM uses one row per field, whereas WP can use multiple rows for a single field’s data:
    http://code.google.com/p/wordpress-custom-content-type-manager/wiki/CustomFieldsDataStructure

    You can create your own types of custom fields (http://code.google.com/p/wordpress-custom-content-type-manager/wiki/CustomCustomFields) — for example, you could write your own versions of the relation fields that doesn’t store the data if the field is empty — just override the save_post_filter() function (sorry the docs aren’t up to tutorial status, but it’s just an abstract PHP class, so I think any developer worth his/her salt would be able to implement it and alter behavior as needed).

    Hope that helps.

Viewing 1 replies (of 1 total)

The topic ‘Database rows created even if the custom field is empty’ is closed to new replies.