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

Improve Store::getInProperty performance, refs 1234 #2461

Merged
merged 1 commit into from May 14, 2017
Merged

Conversation

mwjames
Copy link
Contributor

@mwjames mwjames commented May 13, 2017

This PR is made in reference to: #1234

This PR addresses or contains:

  • The following content was used to simulate some high data load
  • Changes on pre/post to the query plan can be found here
  • The PR in particular addresses the Store::getInProperties performance with a significant improvement in query execution time by extending the INNER JOIN with a subquery to pre-select and filter possible matches before being materialized. One example entity with > 100 incoming properties and an overall table size that covers ~1M triples demonstrated the following changes pre/post this PR.
    • MySQL ( 841.3639ms39.1431ms)
    • Postgres (1282.6319ms59.8922ms)
  • The suggestion from SMWSQLStore3Readers::getInProperties performance #1234 on using something like ... WHERE smw_id IN (SELECT p_id FROM mediawiki."smw_di_wikipage" WHERE o_id='19683’); did not create the expected improvement on MySQL hence a different query was selected that showed favorable query plans on both MySQL and Postgres.

To eliminate filesort and other expensive operations we needed to:

  • Create additional composite indexes to ensure the query planner choose the right one with the objective of using an index
  • Eliminate ORDER BY as it is expected to returns all matches and sort the results during a post processing
  • Filter possible matches before being materialized
SELECT DISTINCT smw_title,smw_sortkey,smw_iw FROM "smw_object_ids"
INNER JOIN (
  SELECT p_id FROM "smw_di_wikipage" WHERE o_id='266' GROUP BY p_id
 ) AS t1 ON t1.p_id=smw_id
WHERE smw_iw!=':smw' AND smw_iw!=':smw-delete'

Tested on:

MediaWiki	1.30.0-alpha (3d26a96)
PHP	7.1.1 (apache2handler)
MariaDB	10.1.21-MariaDB
ICU	57.1
MediaWiki	1.26.2
PHP	5.6.8 (apache2handler)
PostgreSQL	9.3.12
ICU	54.1

This PR includes:

  • Tests (unit/integration)
  • CI build passed

@mwjames mwjames added this to the SMW 3.0.0 milestone May 13, 2017
@mwjames
Copy link
Contributor Author

mwjames commented May 14, 2017

This requires either update.php or setupStore.php to be run.

@kghbln One thing to be noted is due to the added indices, the update.php might take a bit longer the first time as those are created and depend largely on the size of the DB.

@mwjames mwjames merged commit 50a4857 into master May 14, 2017
@mwjames mwjames deleted the in-prop branch May 14, 2017 02:51
@kghbln kghbln added enhancement Alters an existing functionality or behaviour store-sql labels May 14, 2017
@kghbln
Copy link
Member

kghbln commented May 14, 2017

@mwjames This surely will come out with a bang! The performance improvements seen are quite impressive! WOW!

One thing to be noted is due to the added indices, the update.php might take a bit longer the first time as those are created and depend largely on the size of the DB.

We should note this is the RELEASE NOTES in any case.

# (#1234)
#
# @since 3.0
# @default false
Copy link
Member

@kghbln kghbln Jul 11, 2017

Choose a reason for hiding this comment

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

@mwjames Shouldn't this say SMW_EL_INPROP?

Copy link
Member

Choose a reason for hiding this comment

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

See #2758

@mwjames
Copy link
Contributor Author

mwjames commented Jul 11, 2017 via email

@kghbln
Copy link
Member

kghbln commented Jul 11, 2017

I hope that by the time of SMW 3.0 the setting can vanish and yes, the default value is different.

You mean the whole smwgEntityLookupFeatures parameter or just "false" as the internal setting?

@kghbln kghbln mentioned this pull request Oct 13, 2017
2 tasks
@kghbln
Copy link
Member

kghbln commented Oct 13, 2017

Documented on wiki

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Alters an existing functionality or behaviour store-sql
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants