--- /dev/null
+/**
+ * Implements hook_views_pre_execute().
+ */
+function {{ machine_name }}_views_pre_execute(ViewExecutable $view) {
+ // Whenever a view queries more than two tables, show a message that notifies
+ // view administrators that the query might be heavy.
+ // (This action could be performed later in the execution process, but not
+ // earlier.)
+ $account = \Drupal::currentUser();
+
+ if (count($view->query->tables) > 2 && $account->hasPermission('administer views')) {
+ drupal_set_message(t('The view %view may be heavy to execute.', ['%view' => $view->id()]), 'warning');
+ }
+}