0

I'm working on trying to optimize a View SQL query and I noticed that the query being executed is using a join on a the entity_id field of a field table. I noticed that for some reason unbeknownst to me the entity_id field is not a primary key. The delta field is a primary key.

Can anyone enlighten me as to why this is the case? Can I safely tag entity_id as a primary key without incurring a wrath of unintended consequences? Thank you for your help.

field table

3

The primary key for a field table is compound, consisting of:

  • entity_type
  • deleted
  • entity_id
  • language
  • delta

It's probably just the way your GUI is displaying the data that's confusing. This is Navicat's representation, for example:

enter image description here

If not, then something fishy has happened. Since the entity_id is supposed to be part of the compound key, if it isn't, it should be safe to add it to the rest. Take a backup first just in case.

  • Thank you. I will take a look in another GUI or on the command line. For reference, I'm using Sequel Pro. – Blake Frederick May 1 '15 at 17:23
  • I have checked the table on the command line and I've confirmed that this is a GUI display issue. Thank you for your help! – Blake Frederick May 1 '15 at 17:34
1

The field tables store the usages of that field for all entities that use that field. In other words, nodes and users could both have the same field on them. In this case, a particular field could be on both nodes and users. In this case, the entity ID may not be unique.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.