Besides bacteria in cavities, Chinese say when one do not have enough sleep for a number of days and dehydrated, it brings out the "gha-for" ("false heat" literal English translation from Cantonese) that causes toothache and swell in the gums too.
Nonetheless, I'll do everything to rid the pain. It ruins my appetite! ;)