It happened to me twice and maybe it has happened to you before: i would install a plugin (like Relevanssi or Search Unleashed), which would break WordPress or not function like i want it, desactivate it, at which point WordPress goes berseck.
everytime i would edit or add a post or page, i would get this error message.

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 587403 bytes) in /wp-includes/wp-db.php

The best solution i ‘ve had so far is to increase php memory limit to a high value. Not clean, i know, but it works.
So as not to destroy the fix whenever you upgrade WordPress, put it in your wp-config.php file.