Last active
December 30, 2015 08:19
-
-
Save esafwan/7802034 to your computer and use it in GitHub Desktop.
View Query Alter in Drupal to dramatically increase the query performance. This converts left joins to inner join and disables distinct query.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implements hook_views_query_alter(). | |
* | |
* This disables distinct and turns LEFT joins into INNER joins. This increases | |
* performance. | |
*/ | |
function my_module_views_query_alter(&$view, &$query) { | |
if ($view->name == "my_view") { | |
$query->table_queue['content_type_article']['join']->type = 'INNER'; | |
$query->distinct = 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment