package-search: improving performance on fetching facet display name (2nd try) #2692
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In our CKAN project, HDX, we show all facets ( as opposed to just the popular ones ) on the search page. We have 241 groups and 110 orgs so the time spent for fetching the
display_name
for the orgs and groups can be significant. Therefore, instead of fetching the title for each org and group I've changed the code to do only one db query and to fetch only the needed columns.On HDX
On my laptop ( i5, 16GB RAM, SSD ) I get the following time with the unchanged pacakge_search() function:
2015-10-18 20:07:16,683 INFO [ckan.lib.base] /dataset render time 2.159 seconds
After the change:
2015-10-18 20:05:28,595 INFO [ckan.lib.base] /dataset render time 0.930 seconds
On "Core" CKAN
I get the following time with the unchanged pacakge_search() function:
2015-10-18 20:44:50,578 INFO [ckan.lib.base] /dataset render time 0.347 seconds
2015-10-18 20:47:28,893 INFO [ckan.lib.base] /dataset render time 0.417 seconds
And after the change:
2015-10-18 20:40:33,138 INFO [ckan.lib.base] /dataset render time 0.205 seconds
2015-10-18 20:43:14,784 INFO [ckan.lib.base] /dataset render time 0.221 seconds
In debug mode ( pydevd ), the differences are much higher: around 3 seconds on HDX and 1 second on core ckan
Also I removed a reference to the pkg variable that is no longer used since "trusting solr".