-
Notifications
You must be signed in to change notification settings - Fork 737
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
Lazy load status data #1058
Lazy load status data #1058
Conversation
It seems like this change somehow breaks the tests. Can you have a look? Please also update the CHANGELOG.md file. |
It seems like the reason of tests failed is docker building error. Can we try to re-run the tests on CircleCI and travis-ci? I don't have the re-run button here. |
Please ignore CircleCI. I just restarted the tests for Travis CI. |
@chuangbo Here is the error on Travis which is in Status.php, so I assume it is related: https://travis-ci.org/ruflin/Elastica/jobs/116031553#L2048 |
Thank you. The tests have been passed. Actually this pull request looks more like a hack to me, I think would it be better (api design) to move the |
I agree it is currently far from clean, as we mix stats and status (which was not the same in the past). This came with the upgrade to elasticsearch 2.0 when we tried to keep it as BC compatible as possible. I'm good with this temporary hack for the moment but agree we should rethink the API here. I would even say Status should probably disappear as it does not exist anymore on the elasticsearch side. @chuangbo Do you want to open a Github Issue with a proposal how to proceed? |
In an elasticsearch instance with large number of indices, getting `_stats` is a huge expense, which `Elastica\Status` will load it for (every instance) [https://github.com/ruflin/Elastica/blob/e2daadc27ba263ab5b33c4afac10b1144078cd5d/lib/Elastica/Status.php#L44]. But some methods of `Elastica\Status` don't use `Status->_data`, e.g. `getIndicesWithAlias`. So it's possible to lazy load `_stats` data at when it's needed, to speed up stats independent function calls.
Thank you, the commits have been rebased. For the proposal issue, I'm afraid that I'm not quite familiar with elasticsearch, I was using a Magento plugin which based on Elastica and then we faced this performance issue. Sorry. |
@chuangbo Thanks a lot for the contribution. No worries, I'm sure someone will pick it up. |
In an elasticsearch instance with large number of indices, getting
_stats
is a huge expense, whichElastica\Status
will load it for every instanceBut some methods of
Elastica\Status
don't useStatus->_data
, e.g.getIndicesWithAlias
. So it's possible to lazy load_stats
data at when it's needed, to speed up stats independent function calls.