CenterForOpenScience / SHARE

SHARE is building a free, open, data set about research and scholarly activities across their life cycle.
http://share-research.readthedocs.io/en/latest/index.html
Apache License 2.0
100 stars 58 forks source link

[SHARE-1000][Fix] Speed up fetch query in indexer #727

Closed aaxelb closed 6 years ago

aaxelb commented 6 years ago

Once the query reached a certain number of joins, Postgres would (apparently) do all the joins for every work in the database, then apply the WHERE filter after the fact.

This change explicitly filters the works in a subquery before joining anything to it, so Postgres doesn't have the power to make such bad life choices.

coveralls commented 6 years ago

Coverage Status

Coverage remained the same at 78.648% when pulling 79a199e2b022a3f07c3b90dd0d0ba374f3fe7f58 on aaxelb:fix/SHARE-1000--how-about-not-slowly into 737ee1d248ac8fdec2804dc862a0252f7185db85 on CenterForOpenScience:develop.