Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TASK] Media browser performance improvements #230

Merged
merged 7 commits into from Dec 9, 2015

Conversation

aertmann
Copy link
Contributor

Optimizes rendering performance of the media browser/module by
re-using modals, optimizing and using count queries.

Brings 0,5x-3x+ speed improvement depending on the selected view
and amount of assets and tags/asset collections visible.

No functional difference.

Additionally fixes a couple of bugs in the asset repository.

Resolves: NEOS-1698

@aertmann
Copy link
Contributor Author

👍

@aertmann
Copy link
Contributor Author

Example of optimized query

SELECT count(DISTINCT t0_.persistence_object_identifier) AS sclr0 FROM typo3_media_domain_model_asset t0_ LEFT JOIN typo3_media_domain_model_audio t1_ ON t0_.persistence_object_identifier = t1_.persistence_object_identifier LEFT JOIN typo3_media_domain_model_document t2_ ON t0_.persistence_object_identifier = t2_.persistence_object_identifier LEFT JOIN typo3_media_domain_model_image t3_ ON t0_.persistence_object_identifier = t3_.persistence_object_identifier LEFT JOIN typo3_media_domain_model_imagevariant t4_ ON t0_.persistence_object_identifier = t4_.persistence_object_identifier LEFT JOIN typo3_media_domain_model_video t5_ ON t0_.persistence_object_identifier = t5_.persistence_object_identifier WHERE (EXISTS (SELECT 1 FROM typo3_media_domain_model_assetcollection_assets_join t6_ INNER JOIN typo3_media_domain_model_assetcollection t7_ ON t6_.media_assetcollection = t7_.persistence_object_identifier WHERE t6_.media_asset = t0_.persistence_object_identifier AND t7_.persistence_object_identifier = '01bdb83b-fd80-cd8b-97e7-ff458d82be5e'))

vs.

SELECT count(a.persistence_object_identifier) c FROM typo3_media_domain_model_asset a LEFT JOIN typo3_media_domain_model_assetcollection_assets_join collectionmm ON a.persistence_object_identifier = collectionmm.media_asset WHERE collectionmm.media_assetcollection = '01bdb83b-fd80-cd8b-97e7-ff458d82be5e'

} else {
$queryString = 'SELECT count(a.persistence_object_identifier) c FROM typo3_media_domain_model_asset a LEFT JOIN typo3_media_domain_model_asset_tags_join tagmm ON a.persistence_object_identifier = tagmm.media_asset LEFT JOIN typo3_media_domain_model_assetcollection_assets_join collectionmm ON a.persistence_object_identifier = collectionmm.media_asset WHERE tagmm.media_tag = ? AND collectionmm.media_assetcollection = ?';
$queryString = 'SELECT count(a.persistence_object_identifier) c FROM typo3_media_domain_model_asset a LEFT JOIN typo3_media_domain_model_asset_tags_join tagmm ON a.persistence_object_identifier = tagmm.media_asset LEFT JOIN typo3_media_domain_model_assetcollection_assets_join collectionmm ON a.persistence_object_identifier = collectionmm.media_asset WHERE tagmm.media_tag = ? AND collectionmm.media_assetcollection = ? AND a.dtype != "typo3_media_imagevariant"';
}

$query = $this->entityManager->createNativeQuery($queryString, $rsm);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this query work with all supported DBs?

@kitsunet
Copy link
Member

kitsunet commented Dec 4, 2015

left some comments, the rest is fine I guess.

@aertmann
Copy link
Contributor Author

aertmann commented Dec 4, 2015

@kitsunet good catch, checked the query on postgres and it fails.. will push follow up

@aertmann aertmann added I: WIP and removed I: WIP labels Dec 4, 2015
Including image variants in asset searches returns lots of
images that aren't desired since they're simple cropped versions
of others.
Optimizes the asset repository count queries to remove
unnecessary joins resulting in ~10x performance gain.

Related: NEOS-1698
@aertmann aertmann force-pushed the media-browser-performance-improvements branch from 6f8916e to af56539 Compare December 4, 2015 10:17
@aertmann
Copy link
Contributor Author

aertmann commented Dec 4, 2015

fixed the queries for postgres 👍

@aertmann
Copy link
Contributor Author

aertmann commented Dec 9, 2015

btw. since there's no functional changes, simply verify that the counts still work and the modal windows (delete asset, delete tag, delete collection) appear and work..

@aertmann
Copy link
Contributor Author

aertmann commented Dec 9, 2015

for reference, this changed the response time from 35 s to 5 s with 6000 assets and ~350 tags

@kitsunet
Copy link
Member

kitsunet commented Dec 9, 2015

Good stuff, thanks a lot 👍

kitsunet added a commit that referenced this pull request Dec 9, 2015
…vements

TASK: Media browser performance improvements

Optimizes rendering performance of the media browser/module by
re-using modals, optimizing and using count queries.

Brings 0,5x-3x+ speed improvement depending on the selected view
and amount of assets and tags/asset collections visible.

No functional difference.

Additionally fixes a couple of bugs in the asset repository.

NEOS-1698 #close
@kitsunet kitsunet merged commit ed247db into neos:2.0 Dec 9, 2015
@aertmann
Copy link
Contributor Author

aertmann commented Dec 9, 2015

thanks

@aertmann aertmann deleted the media-browser-performance-improvements branch December 9, 2015 17:34
@gerhard-boden
Copy link
Contributor

i saw this has already been merged, but i still tried to "manually merge" this changes into my 2.0.4 test system (since i got around a thousand assets there to test the behaviour and performance) but unluckily for me these changes seem to depend on other changes not merged into my 2.0.4 instance yet, since i get:
#1337700024: f:format.identifier expects an object, array given.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants