When editing a view and updating a view's results using the "Filter" button, the SQL query is executed twice.
StatementWrapperIterator::execute
, such that it only is hit if the condition is TRUE:str_contains($this->clientStatement->queryString, '"node_field_data"')
This is extremely noticeable if it's a long-running query. I'm troubleshooting performance on a site, and a long-running view has it's execution time doubled when I'm testing it in the admin UI like this:
When the view is shown on a page, rather than viewed in the admin UI, the SQL is only executed once, as it should be.
Drupal\Core\Database\StatementWrapperIterator->execute (...\web\core\lib\Drupal\Core\Database\StatementWrapperIterator.php:116)
Drupal\Core\Database\Connection->query (...\web\core\lib\Drupal\Core\Database\Connection.php:851)
Drupal\Core\Database\Query\Select->execute (...\web\core\lib\Drupal\Core\Database\Query\Select.php:525)
Drupal\views\Plugin\views\query\Sql->execute (...\web\core\modules\views\src\Plugin\views\query\Sql.php:1541)
Drupal\views\ViewExecutable->execute (...\web\core\modules\views\src\ViewExecutable.php:1444)
Drupal\views\ViewExecutable->render (...\web\core\modules\views\src\ViewExecutable.php:1472)
Drupal\views\Plugin\views\display\DisplayPluginBase->preview (...\web\core\modules\views\src\Plugin\views\display\DisplayPluginBase.php:2464)
Drupal\views\ViewExecutable->preview (...\web\core\modules\views\src\ViewExecutable.php:1680)
Drupal\views_ui\ViewUI->renderPreview (...\web\core\modules\views_ui\src\ViewUI.php:612)
Drupal\views_ui\ViewPreviewForm->form (...\web\core\modules\views_ui\src\ViewPreviewForm.php:62)
Drupal\Core\Entity\EntityForm->buildForm (...\web\core\lib\Drupal\Core\Entity\EntityForm.php:107)
Drupal\views_ui\ViewFormBase->buildForm (...\web\core\modules\views_ui\src\ViewFormBase.php:41)
call_user_func_array:{/var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php:536} (...\web\core\lib\Drupal\Core\Form\FormBuilder.php:536)
Drupal\Core\Form\FormBuilder->retrieveForm (...\web\core\lib\Drupal\Core\Form\FormBuilder.php:536)
Drupal\Core\Form\FormBuilder->buildForm (...\web\core\lib\Drupal\Core\Form\FormBuilder.php:283)
Drupal\Core\Controller\FormController->getContentResult (...\web\core\lib\Drupal\Core\Controller\FormController.php:73)
Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult (...\web\core\modules\layout_builder\src\Controller\LayoutBuilderHtmlEntityFormController.php:39)
call_user_func_array:{/var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php:123} (...\web\core\lib\Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber.php:123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure:/var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php:121-124} (...\web\core\lib\Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber.php:123)
Drupal\Core\Render\Renderer->executeInRenderContext (...\web\core\lib\Drupal\Core\Render\Renderer.php:627)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext (...\web\core\lib\Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber.php:121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure:/var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php:96-98} (...\web\core\lib\Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber.php:97)
Symfony\Component\HttpKernel\HttpKernel->handleRaw (...\vendor\symfony\http-kernel\HttpKernel.php:181)
Symfony\Component\HttpKernel\HttpKernel->handle (...\vendor\symfony\http-kernel\HttpKernel.php:76)
Drupal\Core\StackMiddleware\Session->handle (...\web\core\lib\Drupal\Core\StackMiddleware\Session.php:58)
Drupal\Core\StackMiddleware\KernelPreHandle->handle (...\web\core\lib\Drupal\Core\StackMiddleware\KernelPreHandle.php:48)
Drupal\Core\StackMiddleware\ContentLength->handle (...\web\core\lib\Drupal\Core\StackMiddleware\ContentLength.php:28)
Drupal\big_pipe\StackMiddleware\ContentLength->handle (...\web\core\modules\big_pipe\src\StackMiddleware\ContentLength.php:32)
Drupal\page_cache\StackMiddleware\PageCache->pass (...\web\core\modules\page_cache\src\StackMiddleware\PageCache.php:106)
Drupal\page_cache\StackMiddleware\PageCache->handle (...\web\core\modules\page_cache\src\StackMiddleware\PageCache.php:85)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle (...\web\core\lib\Drupal\Core\StackMiddleware\ReverseProxyMiddleware.php:48)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle (...\web\core\lib\Drupal\Core\StackMiddleware\NegotiationMiddleware.php:51)
Drupal\Core\StackMiddleware\AjaxPageState->handle (...\web\core\lib\Drupal\Core\StackMiddleware\AjaxPageState.php:36)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle (...\web\core\lib\Drupal\Core\StackMiddleware\StackedHttpKernel.php:51)
Drupal\Core\DrupalKernel->handle (...\web\core\lib\Drupal\Core\DrupalKernel.php:704)
{main} (...\web\index.php:19)
Drupal\Core\Database\StatementWrapperIterator->execute (...\web\core\lib\Drupal\Core\Database\StatementWrapperIterator.php:116)
Drupal\Core\Database\Connection->query (...\web\core\lib\Drupal\Core\Database\Connection.php:851)
Drupal\Core\Database\Query\Select->execute (...\web\core\lib\Drupal\Core\Database\Query\Select.php:525)
Drupal\views\Plugin\views\query\Sql->execute (...\web\core\modules\views\src\Plugin\views\query\Sql.php:1541)
Drupal\views\ViewExecutable->execute (...\web\core\modules\views\src\ViewExecutable.php:1444)
Drupal\views\ViewExecutable->render (...\web\core\modules\views\src\ViewExecutable.php:1472)
Drupal\views\Plugin\views\display\DisplayPluginBase->preview (...\web\core\modules\views\src\Plugin\views\display\DisplayPluginBase.php:2464)
Drupal\views\ViewExecutable->preview (...\web\core\modules\views\src\ViewExecutable.php:1680)
Drupal\views_ui\ViewUI->renderPreview (...\web\core\modules\views_ui\src\ViewUI.php:612)
Drupal\views_ui\ViewPreviewForm->form (...\web\core\modules\views_ui\src\ViewPreviewForm.php:62)
Drupal\Core\Entity\EntityForm->buildForm (...\web\core\lib\Drupal\Core\Entity\EntityForm.php:107)
Drupal\views_ui\ViewFormBase->buildForm (...\web\core\modules\views_ui\src\ViewFormBase.php:41)
call_user_func_array:{/var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php:536} (...\web\core\lib\Drupal\Core\Form\FormBuilder.php:536)
Drupal\Core\Form\FormBuilder->retrieveForm (...\web\core\lib\Drupal\Core\Form\FormBuilder.php:536)
Drupal\Core\Form\FormBuilder->rebuildForm (...\web\core\lib\Drupal\Core\Form\FormBuilder.php:375)
Drupal\Core\Form\FormBuilder->processForm (...\web\core\lib\Drupal\Core\Form\FormBuilder.php:645)
Drupal\Core\Form\FormBuilder->buildForm (...\web\core\lib\Drupal\Core\Form\FormBuilder.php:325)
Drupal\Core\Controller\FormController->getContentResult (...\web\core\lib\Drupal\Core\Controller\FormController.php:73)
Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult (...\web\core\modules\layout_builder\src\Controller\LayoutBuilderHtmlEntityFormController.php:39)
call_user_func_array:{/var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php:123} (...\web\core\lib\Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber.php:123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure:/var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php:121-124} (...\web\core\lib\Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber.php:123)
Drupal\Core\Render\Renderer->executeInRenderContext (...\web\core\lib\Drupal\Core\Render\Renderer.php:627)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext (...\web\core\lib\Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber.php:121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure:/var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php:96-98} (...\web\core\lib\Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber.php:97)
Symfony\Component\HttpKernel\HttpKernel->handleRaw (...\vendor\symfony\http-kernel\HttpKernel.php:181)
Symfony\Component\HttpKernel\HttpKernel->handle (...\vendor\symfony\http-kernel\HttpKernel.php:76)
Drupal\Core\StackMiddleware\Session->handle (...\web\core\lib\Drupal\Core\StackMiddleware\Session.php:58)
Drupal\Core\StackMiddleware\KernelPreHandle->handle (...\web\core\lib\Drupal\Core\StackMiddleware\KernelPreHandle.php:48)
Drupal\Core\StackMiddleware\ContentLength->handle (...\web\core\lib\Drupal\Core\StackMiddleware\ContentLength.php:28)
Drupal\big_pipe\StackMiddleware\ContentLength->handle (...\web\core\modules\big_pipe\src\StackMiddleware\ContentLength.php:32)
Drupal\page_cache\StackMiddleware\PageCache->pass (...\web\core\modules\page_cache\src\StackMiddleware\PageCache.php:106)
Drupal\page_cache\StackMiddleware\PageCache->handle (...\web\core\modules\page_cache\src\StackMiddleware\PageCache.php:85)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle (...\web\core\lib\Drupal\Core\StackMiddleware\ReverseProxyMiddleware.php:48)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle (...\web\core\lib\Drupal\Core\StackMiddleware\NegotiationMiddleware.php:51)
Drupal\Core\StackMiddleware\AjaxPageState->handle (...\web\core\lib\Drupal\Core\StackMiddleware\AjaxPageState.php:36)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle (...\web\core\lib\Drupal\Core\StackMiddleware\StackedHttpKernel.php:51)
Drupal\Core\DrupalKernel->handle (...\web\core\lib\Drupal\Core\DrupalKernel.php:704)
{main} (...\web\index.php:19)
Active
11.0 π₯
Last updated
It affects performance. It is often combined with the Needs profiling tag.