Search is slow on large pagesets - Limited by Postgres' single core limitations
From the Forum: https://forum.mayan-edms.com/viewtopic.php?f=7&t=1560&p=2976#p2976 Not a bug as such, but potential room for improvement.
User is experiencing searches that take 2 minutes +. They have documents containing 150k+ pages.
After diagnosing the issue it's being caused by a slow postgres. This is hindered further by postgres only being able to use 1 core for each query in 9.6.
I think there's a couple of things that could be helped from the Mayan side:
- Optimise searching from a query perspective. This might be a Django limitation though so maybe not. Any ability to parallelize the queries can help if a user upgrades beyond postgres 9.6 would help significantly
- Update our default Postgres versions. 10 brings Parallel queries (https://dba.stackexchange.com/questions/55019/can-a-single-postgresql-query-use-multiple-cores) and this is further improved in 11/12. Only helps if we make code changes though.
I've just ran some dockerised tests on 12 and Mayan installs okay on postgres 12 & 12.1 but then I hit !716 Mayan does run okay on 11 though, but there is no improvement to search.
I will investigate (memcached)caching options to potentially add to the documentation.
In the meantime, the Django docs mention creating indexes for full text searches https://docs.djangoproject.com/en/1.11/ref/contrib/postgres/search/#performance so perhaps that's worth looking into here also if we don't generate them already