? ? Error
Related to # 4842

User tests: Successful: Unsuccessful:

avatar nadeeshaan
nadeeshaan
14 Aug 2014

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

Original Query before the Optimization

  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.lft 
  AND a.rgt 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

Votes

# of Users Experiencing Issue
1/1
Average Importance Score
5.00

avatar nadeeshaan nadeeshaan - open - 14 Aug 2014
avatar jissues-bot jissues-bot - change - 14 Aug 2014
Status Pending New
Labels Added: ? ?
avatar zero-24
zero-24 - comment - 14 Aug 2014

@test

Test results

Bevor patch: 3.62 ms
After patch: 1.11 ms

thanks @nadeeshaan :+1:

avatar brianteeman brianteeman - change - 14 Aug 2014
Labels Added: ?
Removed: ?
avatar 810
810 - comment - 14 Aug 2014

@test

Test results

Before patch: 2.04 ms
After patch: 1.77 ms

  • Success

thanks @nadeeshaan

avatar roland-d
roland-d - comment - 15 Aug 2014

@test success
Before patch: 3.91
After patch: 0.35
You may blame the J!Tracker Application for transmitting this comment.

avatar infograf768 infograf768 - change - 15 Aug 2014
Labels Added: ?
avatar beat
beat - comment - 15 Aug 2014

:+1: for the query refactoring

Wondering if instead of:

AND a.published IN (0,1)

AND a.published >=0 AND a.published <= 1

(with using the possibility to remove one of the 2 compares, depending on the 3 possible values of published). And if that's possible, then a 2-columns index on published, lft would do miracles on that query on large sets.

Could further speedup the query (with lots of categories). In earlier MySQL versions it was the case.

Also if WHEREa.alias<> 'root' is equivalent to WHEREa.id> 0 it could give it another boost.

avatar brianteeman
brianteeman - comment - 16 Aug 2014

@test
Tested with 1178 categories and 57345 articles and 59883 assets (created by com_overload)
before 3.99ms
after 0.54ms

screenshot 2014-08-16 11 24 15
screenshot 2014-08-16 11 26 52

avatar alikon
alikon - comment - 19 Aug 2014

Also if WHEREa.alias<> 'root' is equivalent to WHEREa.id> 0it could give it another boost.

for readabilty i prefer WHERE a.lft >0 means more in nested set term

avatar gunjanpatel
gunjanpatel - comment - 19 Aug 2014

Updated to WHERE a.lft > 0 as per @alikon suggestion.
Thanks.

avatar nicksavov nicksavov - change - 21 Aug 2014
Labels Removed: ?
avatar brianteeman brianteeman - change - 21 Aug 2014
The description was changed
Status New Pending
avatar brianteeman brianteeman - change - 23 Sep 2014
Category SQL
avatar roland-d roland-d - alter_testresult - 3 Oct 2014 - brianteeman: Tested successfully
avatar roland-d roland-d - alter_testresult - 3 Oct 2014 - 810: Tested successfully
avatar roland-d roland-d - alter_testresult - 3 Oct 2014 - zero-24: Tested successfully
avatar roland-d roland-d - change - 3 Oct 2014
Status Pending Ready to Commit
avatar phproberto phproberto - change - 8 Oct 2014
Labels Added: ?
avatar nicksavov nicksavov - close - 8 Oct 2014
avatar phproberto phproberto - close - 8 Oct 2014
avatar phproberto phproberto - change - 8 Oct 2014
Status Ready to Commit Closed
Closed_Date 0000-00-00 00:00:00 2014-10-08 09:08:09
avatar wilsonge
wilsonge - comment - 17 Oct 2014

Hi,
This has broken tags on postgres even more (I've been working through some of PBF to try and fix some issues in it). Can you guys please investigate?

avatar nicksavov nicksavov - change - 17 Oct 2014
Labels Added: ?
avatar nicksavov
nicksavov - comment - 17 Oct 2014

George, I think we might have to open a new issue since this one's already committed. Or we'll have to revert.

I'll reopen for now until a committer can review.

avatar nicksavov nicksavov - reopen - 17 Oct 2014
avatar nicksavov nicksavov - change - 17 Oct 2014
Status Closed New
avatar wilsonge
wilsonge - comment - 17 Oct 2014

Yeah if this doesn't get fixed we'll need to revert. This stops any tags from being retrieved for the parent field when creating a new tag in postgres (admittedly you still can't save a tag because of a unrelated SQL error. but small steps right :P)

avatar brianteeman
brianteeman - comment - 18 Oct 2014

Setting to Needs Review

This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/4114.

avatar brianteeman brianteeman - change - 18 Oct 2014
Status New Needs Review
avatar Bakual
Bakual - comment - 18 Oct 2014

Created PR #4842 with the proposed fix from @alikon.

avatar Bakual Bakual - close - 18 Oct 2014
avatar Bakual Bakual - change - 18 Oct 2014
Status Needs Review Closed
Closed_Date 2014-10-08 09:08:09 2014-10-18 15:23:32
avatar brianteeman brianteeman - change - 18 Oct 2014
Rel_Number 4842
Relation Type Related to

Add a Comment

Login with GitHub to post a comment