My views are quite slow in some cases, needs create indexes on field tables. Is there a module for that?


Because views does not create tables but rather builds queries, you cannot add indexes to views but what you can do is insert Mysql Index hints via the Views Index Hint module.

If this module is not flexible enough for you, you can manually add the index hint after the sql query is constructed by using the hook_views_query_alter hook.

  • I think this is not an issue directly to views, but fields tables. Just need a UI to create index for field columns and configuration (indexes) should be exportable. Nov 28 '14 at 3:09
  • In that case I haven't come across any module that provides such a UI :(. If you want to go the coding route though then please refer to the db_add_index and the db_index_exists functions. Dec 2 '14 at 18:18
  • I created this module drupal.org/project/field_index Dec 3 '14 at 10:07

Field module does not always add indexes for its columns (value column of text field for example), this leads to poor performance in views when we would like sort or filter views using the unindexed columns.

We can check the query executed by views and add custom indexes manually, but it's not deployable. With field_index.module, we can create and export custom indexes for fields.

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.