Only create the database view if the indexing must be done

Merged Samuel GAIST requested to merge fix_db_index_check into master

There's no reason to create the database view early if it might not be used.

Merge request reports