During the sprint, David explained that using varchar columns for entity_type is very expensive. We should switch to using int columns for entity types.

The obvious choice is to create another table that maps entity type names to ids. In fact, I think we should do that. However, I do not think we should require a separate query or join every time we want to access a field table. Instead, in addition to a normalized id/entity_type table, we should also cache entity type ids in a drupal variable. Field API can always read it from the variable to avoid another query. Other modules can use the variables (if we document them as supported) or join against the entity_type table if they want a query to return type names.

Finally, I think field_attach_extract_ids() should return the entity type id along with all the other information. Logically, the entity type id should be first in the list.

Comments

bjaspan’s picture

Fixed in bzr revsision 500.

I realized that the entity type to id mapping is entirely a product of the SQL storage engine; some hypothetical other database may not care to work that way. So the mapping is contained in field_sql_storage.module.

bjaspan’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.