It's not danbooru, it's posgresql. Sometimes it doesn't feel like using the indexes... so searches are slow and get timed out. usually when it happens we just bounce the server and it fixes itself, but then has problems again eventually. Unfortunately its just one of those things that you need to try a few times to do.