No way to define complex field indexes

Created on 15 November 2016, about 8 years ago
Updated 7 November 2024, 14 days ago

Problem/Motivation

I was working on an issue with entity reference and views being slow under D7, but this seems to be affecting D8 as well.
In short - D7 field schema API foes not allow you in any way to define index that is based on generic field columns and custom ones.

For the entity reference example. THe following index is impossible to be defined in field schema API:
- deleted
- entity_type
- field_name_target_id

You can create it in D7 with the db_add_index, but for new fields this does not work.

For detailed description see this:
🐛 Missing database index Needs work

Assigning the issue against D8, as both entity reference and views are both in core and they have this index missing.

Proposed resolution

Any ideas how to tackle this in D8 are welcome.

This is for D7:
For what I can see an alter hook of sort that will be called against the final field table schema only to the field's module might work.
- Best as it's going to be atomic.

A hook that will be invoked just to notify for field's creation, so modules can hook on it and add indexes with the existing API
- Possible but not perfect, as it non-atomic. Create + alter to add the index.

Remaining tasks

Decide on a solution for D7 & D8.

User interface changes

None.

API changes

Additions only.

Data model changes

None.

🐛 Bug report
Status

Postponed: needs info

Version

11.0 🔥

Component

field system

Created by

🇧🇬Bulgaria ndobromirov

Live updates comments and jobs are added and updated live.
  • Performance

    It affects performance. It is often combined with the Needs profiling tag.

  • Needs backport to D7

    After being applied to the 8.x branch, it should be considered for backport to the 7.x branch. Note: This tag should generally remain even after the backport has been written, approved, and committed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇳🇿New Zealand quietone

    @ndobromirov, thanks for reporting this and helping to improve Drupal.

    There has been no discussion here for 8 years and the issue summary is not clear if this is a problem with Drupal 8+ or not. Therefore, I am setting the status to Postponed (maintainer needs more info) to get confirmation that this is an issue on Drupal 10 or Drupal 11. If we don't receive additional information to help with the issue, it may be closed after three months.

    Thanks!

Production build 0.71.5 2024