joomla/joomla-cms — pull request #4114 by nadeeshaan (2014-08-14 18:30:31+00:00)
Title: Sql optimise admin get list of tags branch

## Testing Instructions:
In order to check the query execution log in to the admin console and click add new category. Then the query triggers.

![addnewcat](https://cloud.githubusercontent.com/assets/1329674/3902065/3db4850a-22b7-11e4-97b9-33754b08d439.png)

### Original Query before the Optimization

```sql
SELECT a.id AS value, a.path, a.title AS text, a.level, a.published
FROM ltzvy_tags AS a
LEFT JOIN `ltzvy_tags` AS b
ON a.lft > b.lft
AND a.rgt < b.rgt
WHERE `a`.`alias` <> 'root'
AND a.published IN (0,1)
GROUP BY a.id, a.title, a.level, a.lft, a.rgt, a.parent_id, a.published, a.path
ORDER BY a.lft ASC
```
### After the Optimization

```sql
SELECT DISTINCT a.id AS value, a.path, a.title AS text, a.level, a.published
FROM ltzvy_tags AS a
LEFT JOIN `ltzvy_tags` AS b
ON a.lft > b.lft
AND a.rgt < b.rgt
WHERE `a`.`alias` <> 'root'
AND a.published IN (0,1)
ORDER BY a.lft ASC
```

### Query Change Description
In this query `GROUP BY` clause has been removed and instead added the 'SELECT DISTINCT' clause in order to optimize the query execution