This should remove the locking problems and speed up queries to collector database.
Tests passed for python2 and python3