Publié
2007-02-14 15:39
An interesting discussion spawned on the civicrm-dev list recently regarding our implementation of custom groups and fields. We have been super cautious about this and have advised people not to create more than 20 custom fields per object (contact, activity, group, relationship etc). However creating a custom field is relatively easy and people have been doing it at a fast and furious pace. We've heard of implementations with more than 100 custom fields. This has worked for some people, but a large number of custom fields has the following problems:
- Custom values are stored in a thin table, one per value. This table will grow significantly for large number of custom values
- Primary Export is not possible since it will exceed the mysql JOIN limit of 61 tables
- You cannot make a large number of these custom fields searchable, else search will exceed the mysql JOIN limit
- There is potentially a slow down with operations involving large number of custom fields. I suspect we can easily optimize these queries once we are aware of them
Filed under
Comments
I have been Googling, and haven't found clear guidance about practical impacts of the number of custom fields, in total, or per object.
Looking at what I think is a current ERD, it looks like there is still one custom fields table, which means that these warnings/considerations are still relevant?
Thanks for any clarification.
In 4.0.6, I added a field group called Academic, and I see a table civicrm_value_academic_1 in my database, so it seems that, at some point the "CCK" approach was chosen.
To finish my example:
SELECT
`civicrm_contact`.`first_name`
, `civicrm_contact`.`last_name`
, `civicrm_value_academic_1`.`institution_1`
, `civicrm_value_academic_1`.`year_2`
FROM
`acendedu_civi1`.`civicrm_contact`
INNER JOIN `acendedu_civi1`.`civicrm_custom_group`
ON (`civicrm_contact`.`contact_type` = `civicrm_custom_group`.`extends`)
INNER JOIN `acendedu_civi1`.`civicrm_value_academic_1`
ON (`civicrm_value_academic_1`.`entity_id` = `civicrm_contact`.`id`)
WHERE (`civicrm_contact`.`id` 2);
That is to say...contact_id matches the entity_id in the custom field value records, and the custom (field) group extends Individual, which happens to be the contact_type of the Contact. Clear as mud?
since this is a really really old blog post :)
thanx
lobo