? ? Success

User tests: Successful: Unsuccessful:

avatar nadeeshaan
nadeeshaan
13 Aug 2014

Testing Instructions:

In order to test this PR, first apply the PR via the Joomla! Patch Tester and then login to the Joomla! site. When accessing the pages where articles are being showed this query triggers.

Article Pages

Original Query before the Optimization

SELECT b.rules
FROM #__assets AS a
LEFT JOIN #__assets AS b 
    ON b.lft = a.rgt
WHERE (a.name = 'com_content')
GROUP BY b.id, b.rules, b.lft
ORDER BY b.lft

After the Optimization

Decomposed Query 1:

SELECT lft,rgt
FROM #__assets
WHERE (name = 'com_content')

Decomposed Query 2:

SELECT rules,lft
FROM #__assets
WHERE lft = retrieved_rgt_value

Query Change Description

As we compare the previous query and the decomposed queries you can clearly see that the JOIN operation of the previous query has been removed not using the sub selects, but first retrieving the required lft and rgt values from the #__assets and then use these values normally to retrieve the rules values from the #_assets table using a simple select query

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

@test

Test results

Bevor patch: 4.59 ms
After patch: 0.59 ms and 0.61 ms

So also here full success :+1:

thanks @nadeeshaan

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

@test

Test results

Before patch: 23.74 ms
After patch: 0.89 ms and 0.88 ms

  • Success

thanks @nadeeshaan

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

@nadeeshaan Thanks, good direction too, looking at description above only:

You could probably still have a single query using sub-query.

There is one thing that got missing on the rewrite and that could be important for the authorizations:
ORDER BY b.lft : that is most probably needed to get authorization tree ordered in the correct rules inheritence. So from a security audit perspective NOT yet OK.

avatar brianteeman
brianteeman - comment - 16 Aug 2014

@test
Tested with 1178 categories and 57345 articles and 59883 assets (created by com_overload)
before 1.72ms
after 0.41ms + 0.34ms

screenshot 2014-08-16 11 15 32
screenshot 2014-08-16 11 17 20

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 - 4 Oct 2014
Category SQL
avatar alikon
alikon - comment - 15 Nov 2014

@test success
tested with mysqlslap with 15k #__assets items
this test was perfomed 10 times with 100 concurrent requests
image

in this test the x-axis represent the number of concurrent requests varying from 10 to 100
image

@beat
the #__assets table have a "UNIQUE CONSTRAINT" on the #__assets.name field

avatar alikon alikon - test_item - 15 Nov 2014 - Tested successfully
avatar brianteeman brianteeman - test_item - 24 Nov 2014 - Tested successfully
avatar brianteeman
brianteeman - comment - 24 Nov 2014

Two good tests but because of @beat comment I am setting this to needs review

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

avatar brianteeman brianteeman - change - 24 Nov 2014
Status Pending Needs Review
avatar alikon
alikon - comment - 25 Nov 2014

the original query was decomposed in two query
the first query don't need an order by lft cause the field name have a UNIQUE CONSTRAINT
SELECT lft,rgt
FROM #__assets
WHERE (name = 'com_content')

the second query have the order by lft
SELECT rules,lft
FROM #__assets
WHERE lft <= retrieved_lft_value
AND rgt >= retrieved_rgt_value
order by lft

so don't understand what is exactly the problem

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

avatar sovainfo
sovainfo - comment - 5 Apr 2015

Request for RTC and removal of erroneous label "New Feature", suggest to replace it with "Improvement" or "Optimization".

Agree with @alikon that @beat made a mistake and there is no need for review.


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/4107.
avatar orware
orware - comment - 6 Apr 2015

We've been discussing this item in the sql-optimisation-wg on Glip and we've issued a new pull request to supersede this one after additional discussion:
#6681

We'd love to have those involved with this pull request to help us test the new pull request so we can hopefully get it merged quickly.

Thank you!

avatar brianteeman brianteeman - change - 6 Apr 2015
Status Needs Review Closed
Closed_Date 0000-00-00 00:00:00 2015-04-06 20:32:45
avatar brianteeman brianteeman - close - 6 Apr 2015

Add a Comment

Login with GitHub to post a comment