Function __global->remove_unneeded_joins_rough

Definitions

sources/database_search.php

  • Optimise out JOIN queries we don't need, using a fairly simple MySQL-centric algorithm.We do this as apparently on at least some MySQL versions unused LEFT JOINs are not optimised out.Assumes that any fields from a join are referenced using the JOINs alias.
  • Visibility: public
  • Is abstract?: No
  • Is static?: No
  • Is final?: No
  • Returns: string

Parameters

Name Type Passed by reference? Variadic? Default Set Range Description
$query string No No required parameter N/A N/A The SQL query

Returns

  • Optimised query
  • Type: string
  • Set: N/A
  • Range: N/A

Preview

Code (PHP)

/**
 * Optimise out JOIN queries we don't need, using a fairly simple MySQL-centric algorithm.We do this as apparently on at least some MySQL versions unused LEFT JOINs are not optimised out.Assumes that any fields from a join are referenced using the JOINs alias.
 *
 * @param  string $query The SQL query
 * @return string Optimised query
 */

function remove_unneeded_joins_rough(string $query) : string