User tests: Successful: Unsuccessful:
In order to test this PR first apply the PR via the joomla Patch Test. Then log in to the admin panel and click on the add new article. After clicking on the add new article, the query executes.
SELECT a.id AS value, a.title AS text, a.level, a.published
FROM #_categories AS a
LEFT JOIN #_categories AS b
ON a.lft > b.lft
AND a.rgt < b.rgt
WHERE (a.extension = 'com_content')
AND a.published IN (0,1)
GROUP BY a.id, a.title, a.level, a.lft, a.rgt, a.extension, a.parent_id, a.published
ORDER BY a.lft ASC
SELECT DISTINCT c.id AS value, c.title AS text, c.level, c.published
FROM (
SELECT DISTINCT id,title,level,published,parent_id,extension,lft,rgt
FROM #_categories
WHERE (extension = 'com_content') AND published IN (0,1)
ORDER BY lft ASC
) AS c
LEFT JOIN #_categories AS b
ON x.lft > b.lft
AND x.rgt < b.rgt
In the new query the change is the new sub select. In the previous query the tables are being joined and in the new query as you can see in the red color query is the sub select. In the sub select it filters the rows according to the WHERE
clause of the previous query. As you can see this filters the rows and reduce the number of rows before the join and which results a fever number of rows to choose the attributes.Also Removed the group by clause and added the SELECT DISTINCT
instead
http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=34066
Status | Pending | ⇒ | New |
Labels |
Added:
?
?
|
Description | <h2>Testing Instructions:</h2> <p>In order to test this PR first apply the PR via the joomla Patch Test. Then log in to the admin panel and click on the add new article. After clicking on the add new article, the query executes.<br><a href="https://cloud.githubusercontent.com/assets/1329674/3895200/d14f9d8e-224b-11e4-9a13-d83208ea42d5.PNG" target="_blank"><img src="https://cloud.githubusercontent.com/assets/1329674/3895200/d14f9d8e-224b-11e4-9a13-d83208ea42d5.PNG" alt="Add New Article" style="max-width:100%;"></a></p> <h3>Original Query before the Optimization</h3> <div class="highlight highlight-sql"><pre> <span class="k">SELECT</span> <span class="n">a</span><span class="p">.</span><span class="n">id</span> <span class="k">AS</span> <span class="n">value</span><span class="p">,</span> <span class="n">a</span><span class="p">.</span><span class="n">title</span> <span class="k">AS</span> <span class="nb">text</span><span class="p">,</span> <span class="n">a</span><span class="p">.</span><span class="k">level</span><span class="p">,</span> <span class="n">a</span><span class="p">.</span><span class="n">published</span> <span class="k">FROM</span> <span class="o">#</span><span class="n">_categories</span> <span class="k">AS</span> <span class="n">a</span> <span class="k">LEFT</span> <span class="k">JOIN</span> <span class="o">#</span><span class="n">_categories</span> <span class="k">AS</span> <span class="n">b</span> <span class="k">ON</span> <span class="n">a</span><span class="p">.</span><span class="n">lft</span> <span class="o">></span> <span class="n">b</span><span class="p">.</span><span class="n">lft</span> <span class="k">AND</span> <span class="n">a</span><span class="p">.</span><span class="n">rgt</span> <span class="o"><</span> <span class="n">b</span><span class="p">.</span><span class="n">rgt</span> <span class="k">WHERE</span> <span class="p">(</span><span class="n">a</span><span class="p">.</span><span class="n">extension</span> <span class="o">=</span> <span class="s1">'com_content'</span><span class="p">)</span> <span class="k">AND</span> <span class="n">a</span><span class="p">.</span><span class="n">published</span> <span class="k">IN</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">)</span> <span class="k">GROUP</span> <span class="k">BY</span> <span class="n">a</span><span class="p">.</span><span class="n">id</span><span class="p">,</span> <span class="n">a</span><span class="p">.</span><span class="n">title</span><span class="p">,</span> <span class="n">a</span><span class="p">.</span><span class="k">level</span><span class="p">,</span> <span class="n">a</span><span class="p">.</span><span class="n">lft</span><span class="p">,</span> <span class="n">a</span><span class="p">.</span><span class="n">rgt</span><span class="p">,</span> <span class="n">a</span><span class="p">.</span><span class="n">extension</span><span class="p">,</span> <span class="n">a</span><span class="p">.</span><span class="n">parent_id</span><span class="p">,</span> <span class="n">a</span><span class="p">.</span><span class="n">published</span> <span class="k">ORDER</span> <span class="k">BY</span> <span class="n">a</span><span class="p">.</span><span class="n">lft</span> <span class="k">ASC</span> </pre></div> <h3>After the Optimization</h3> <div class="highlight highlight-sql"><pre> <span class="k">SELECT</span> <span class="k">DISTINCT</span> <span class="k">c</span><span class="p">.</span><span class="n">id</span> <span class="k">AS</span> <span class="n">value</span><span class="p">,</span> <span class="k">c</span><span class="p">.</span><span class="n">title</span> <span class="k">AS</span> <span class="nb">text</span><span class="p">,</span> <span class="k">c</span><span class="p">.</span><span class="k">level</span><span class="p">,</span> <span class="k">c</span><span class="p">.</span><span class="n">published</span> <span class="k">FROM</span> <span class="p">(</span> <span class="k">SELECT</span> <span class="k">DISTINCT</span> <span class="n">id</span><span class="p">,</span><span class="n">title</span><span class="p">,</span><span class="k">level</span><span class="p">,</span><span class="n">published</span><span class="p">,</span><span class="n">parent_id</span><span class="p">,</span><span class="n">extension</span><span class="p">,</span><span class="n">lft</span><span class="p">,</span><span class="n">rgt</span> <span class="k">FROM</span> <span class="o">#</span><span class="n">_categories</span> <span class="k">WHERE</span> <span class="p">(</span><span class="n">extension</span> <span class="o">=</span> <span class="s1">'com_content'</span><span class="p">)</span> <span class="k">AND</span> <span class="n">published</span> <span class="k">IN</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">)</span> <span class="k">ORDER</span> <span class="k">BY</span> <span class="n">lft</span> <span class="k">ASC</span> <span class="p">)</span> <span class="k">AS</span> <span class="k">c</span> <span class="k">LEFT</span> <span class="k">JOIN</span> <span class="o">#</span><span class="n">_categories</span> <span class="k">AS</span> <span class="n">b</span> <span class="k">ON</span> <span class="n">x</span><span class="p">.</span><span class="n">lft</span> <span class="o">></span> <span class="n">b</span><span class="p">.</span><span class="n">lft</span> <span class="k">AND</span> <span class="n">x</span><span class="p">.</span><span class="n">rgt</span> <span class="o"><</span> <span class="n">b</span><span class="p">.</span><span class="n">rgt</span> </pre></div> <h3>Query Change Description</h3> <p>In the new query the change is the new sub select. In the previous query the tables are being joined and in the new query as you can see in the red color query is the sub select. In the sub select it filters the rows according to the <code>WHERE</code> clause of the previous query. As you can see this filters the rows and reduce the number of rows before the join and which results a fever number of rows to choose the attributes.Also Removed the group by clause and added the <code>SELECT DISTINCT</code> instead</p> | ⇒ | <h2>Testing Instructions:</h2> <p>In order to test this PR first apply the PR via the joomla Patch Test. Then log in to the admin panel and click on the add new article. After clicking on the add new article, the query executes.<br><a href="https://cloud.githubusercontent.com/assets/1329674/3895200/d14f9d8e-224b-11e4-9a13-d83208ea42d5.PNG" target="_blank"><img src="https://cloud.githubusercontent.com/assets/1329674/3895200/d14f9d8e-224b-11e4-9a13-d83208ea42d5.PNG" alt="Add New Article" style="max-width:100%;"></a></p> <h3>Original Query before the Optimization</h3> <div class="highlight highlight-sql"><pre> <span class="k">SELECT</span> <span class="n">a</span><span class="p">.</span><span class="n">id</span> <span class="k">AS</span> <span class="n">value</span><span class="p">,</span> <span class="n">a</span><span class="p">.</span><span class="n">title</span> <span class="k">AS</span> <span class="nb">text</span><span class="p">,</span> <span class="n">a</span><span class="p">.</span><span class="k">level</span><span class="p">,</span> <span class="n">a</span><span class="p">.</span><span class="n">published</span> <span class="k">FROM</span> <span class="o">#</span><span class="n">_categories</span> <span class="k">AS</span> <span class="n">a</span> <span class="k">LEFT</span> <span class="k">JOIN</span> <span class="o">#</span><span class="n">_categories</span> <span class="k">AS</span> <span class="n">b</span> <span class="k">ON</span> <span class="n">a</span><span class="p">.</span><span class="n">lft</span> <span class="o">></span> <span class="n">b</span><span class="p">.</span><span class="n">lft</span> <span class="k">AND</span> <span class="n">a</span><span class="p">.</span><span class="n">rgt</span> <span class="o"><</span> <span class="n">b</span><span class="p">.</span><span class="n">rgt</span> <span class="k">WHERE</span> <span class="p">(</span><span class="n">a</span><span class="p">.</span><span class="n">extension</span> <span class="o">=</span> <span class="s1">'com_content'</span><span class="p">)</span> <span class="k">AND</span> <span class="n">a</span><span class="p">.</span><span class="n">published</span> <span class="k">IN</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">)</span> <span class="k">GROUP</span> <span class="k">BY</span> <span class="n">a</span><span class="p">.</span><span class="n">id</span><span class="p">,</span> <span class="n">a</span><span class="p">.</span><span class="n">title</span><span class="p">,</span> <span class="n">a</span><span class="p">.</span><span class="k">level</span><span class="p">,</span> <span class="n">a</span><span class="p">.</span><span class="n">lft</span><span class="p">,</span> <span class="n">a</span><span class="p">.</span><span class="n">rgt</span><span class="p">,</span> <span class="n">a</span><span class="p">.</span><span class="n">extension</span><span class="p">,</span> <span class="n">a</span><span class="p">.</span><span class="n">parent_id</span><span class="p">,</span> <span class="n">a</span><span class="p">.</span><span class="n">published</span> <span class="k">ORDER</span> <span class="k">BY</span> <span class="n">a</span><span class="p">.</span><span class="n">lft</span> <span class="k">ASC</span> </pre></div> <h3>After the Optimization</h3> <div class="highlight highlight-sql"><pre> <span class="k">SELECT</span> <span class="k">DISTINCT</span> <span class="k">c</span><span class="p">.</span><span class="n">id</span> <span class="k">AS</span> <span class="n">value</span><span class="p">,</span> <span class="k">c</span><span class="p">.</span><span class="n">title</span> <span class="k">AS</span> <span class="nb">text</span><span class="p">,</span> <span class="k">c</span><span class="p">.</span><span class="k">level</span><span class="p">,</span> <span class="k">c</span><span class="p">.</span><span class="n">published</span> <span class="k">FROM</span> <span class="p">(</span> <span class="k">SELECT</span> <span class="k">DISTINCT</span> <span class="n">id</span><span class="p">,</span><span class="n">title</span><span class="p">,</span><span class="k">level</span><span class="p">,</span><span class="n">published</span><span class="p">,</span><span class="n">parent_id</span><span class="p">,</span><span class="n">extension</span><span class="p">,</span><span class="n">lft</span><span class="p">,</span><span class="n">rgt</span> <span class="k">FROM</span> <span class="o">#</span><span class="n">_categories</span> <span class="k">WHERE</span> <span class="p">(</span><span class="n">extension</span> <span class="o">=</span> <span class="s1">'com_content'</span><span class="p">)</span> <span class="k">AND</span> <span class="n">published</span> <span class="k">IN</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">)</span> <span class="k">ORDER</span> <span class="k">BY</span> <span class="n">lft</span> <span class="k">ASC</span> <span class="p">)</span> <span class="k">AS</span> <span class="k">c</span> <span class="k">LEFT</span> <span class="k">JOIN</span> <span class="o">#</span><span class="n">_categories</span> <span class="k">AS</span> <span class="n">b</span> <span class="k">ON</span> <span class="n">x</span><span class="p">.</span><span class="n">lft</span> <span class="o">></span> <span class="n">b</span><span class="p">.</span><span class="n">lft</span> <span class="k">AND</span> <span class="n">x</span><span class="p">.</span><span class="n">rgt</span> <span class="o"><</span> <span class="n">b</span><span class="p">.</span><span class="n">rgt</span> </pre></div> <h3>Query Change Description</h3> <p>In the new query the change is the new sub select. In the previous query the tables are being joined and in the new query as you can see in the red color query is the sub select. In the sub select it filters the rows according to the <code>WHERE</code> clause of the previous query. As you can see this filters the rows and reduce the number of rows before the join and which results a fever number of rows to choose the attributes.Also Removed the group by clause and added the <code>SELECT DISTINCT</code> instead</p> <p><a href="http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=34066">http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=34066</a></p> |
Labels |
Removed:
?
|
Labels |
Added:
?
|
@zero-24
Please consider the execution time of the query. Not the number of rows.
cause number of rows should be the same. What I explained was in the sub
select it selects a reduced number of rows in order to join with the next
table
On Wed, Aug 13, 2014 at 7:50 PM, zero-24 notifications@github.com wrote:
@test https://github.com/test @nadeeshaan
https://github.com/nadeeshaan i can confirm the query change. ok here.
Is there any special thing that can/need be tested? It still retrun the
same count of rows om my end.—
Reply to this email directly or view it on GitHub
#4106 (comment).
Nadeeshaan Gunasinghe
Department of Computer Science and Engineering
University of Moratuwa
Sri Lanka
Title |
|
thanks @nadeeshaan I can confirm the result by @infograf768
My results are:
Query time bevor the patch: 6.76 ms
Query time after the patch: 1.78 ms
So full success here.
@nadeeshan
This should be tested with the other types of DB
@infograf768
Yes of course. For that we need the support of community members who use the other type of DBs. I think all will give the support in this testing process.
:)
@nadeeshaan Use of subquery would makes sense but think there is an error in your description (mentioning x.). Additionally, in this case the LEFT JOIN could be avoided completely imho, as b is not used at all in the query!!!
@all Imho, those optimization tests should be conducted with large datasets and after having queried the database at least 20 times if not more, so that it has "warmed-up", not with just 3, 30 or even 300 rows, if you want to have any meaningful results, thousands or tens of thousands of rows are needed to see a significant result.
@dgt41 don't understand your question. What is com_overload ?
What I said, is that even though table b is joined in "Original Query before the Optimization" above in the description, none of its columns is used. Moreover, as it is a left join, the only benefit is to have multiple repeated rows depending on if more than 1 left join is possible. So the query itself seems buggy. I guess its original intend was to compute the level by counting the joined elements, but as the (redundant) "level" column exists and is used here, the join is a leftover from the past (from when nested trees were implemented according to The Book).
So not sure that the optimization makes any sense (didn't look at the PHP code as the diff shows not that easily understandable original code).
com_overload is a component that creates mass content in joomla: http://github.com/nikosdion/com_overload
But I am not so sure that is up to date, last commit was like a year ago
com-overload should work fine on j3,3 - I have it running on my test site right now building over 1000 categories and 1500 articles.
On 15 August 2014 22:40, dgt41 notifications@github.com wrote:
com_overload is a component that creates mass content in joomla:
http://github.com/nikosdion/com_overload
https://github.com/nikosdion/com_overload
But I am not so sure that is up to date, last commit was like a year ago—
Reply to this email directly or view it on GitHub
#4106 (comment).
Brian Teeman
Co-founder Joomla! and OpenSourceMatters Inc.
http://brian.teeman.net/
Brian, I already setup a new test bench, I will post some results when the script finish adding stuff
https://www.dropbox.com/s/crkqx6mfpg7zty6/Screenshot%202014-08-16%2001.01.14.png
Yeah. I've set mine running and will test tomorrow
On 15 Aug 2014 23:03, "dgt41" notifications@github.com wrote:
[image: ] Brian, I already setup a new test bench, I will post some
results when the script finish adding stuffhttps://www.dropbox.com/s/crkqx6mfpg7zty6/Screenshot%202014-08-16%2001.01.14.png
—
Reply to this email directly or view it on GitHub
#4106 (comment).
@test
test conditions:
no MYSQL query_cache, Mysql 5.6.16
Data set:
Table assets: 15427
Table categories: 1561
Table content: 13639
tool used: mysqlslap
only the affected query is tested pure sql
old query
alikon@PC-ALIKON c:\xampp
# mysqlslap --concurrency=10 --iterations=10 --query=old_pr6.sql --create-schema
=gtest -uroot -padmin
Warning: Using a password on the command line interface can be insecure.
Benchmark
Average number of seconds to run all queries: 27.457 seconds
Minimum number of seconds to run all queries: 26.557 seconds
Maximum number of seconds to run all queries: 27.900 seconds
Number of clients running queries: 10
Average number of queries per client: 1
new query
alikon@PC-ALIKON c:\xampp
# mysqlslap --concurrency=10 --iterations=10 --query=new_pr6.sql --create-schema
=gtest -uroot -padmin
Warning: Using a password on the command line interface can be insecure.
Benchmark
Average number of seconds to run all queries: 0.599 seconds
Minimum number of seconds to run all queries: 0.265 seconds
Maximum number of seconds to run all queries: 1.359 seconds
Number of clients running queries: 10
Average number of queries per client: 1
Labels |
Removed:
?
|
Title |
|
Labels |
Added:
?
|
Labels |
Added:
?
|
Merged into the 3.4-dev
branch. Thanks!
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2014-08-31 18:39:46 |
@test @nadeeshaan i can confirm the query change. ok here. Is there any special thing that can/need be tested? It still retrun the same count of rows on my end.