As Stormi says, the very best preventive is daily combing and brushing. And remember to always comb out any tangles or mats before you bathe your dog...bathing mats will set them into place almost permanently, like making felt!
There is an equine product called "Cowboy Magic Detangler and Shine" that is almost fool proof for removing knots, mats and tangles. Just drops (really, just the tiniest bit) put on the knot or mat, and worked in well with the fingertips, will allow you to separate the strands with your fingers and a comb. If you do this before a bath, it will wash out, but it is okay to leave in. On a daily basis, a tiny bit on a tangle should not be a problem to leave in. (It is a silicone based product, so if you use tons of it often, it can be drying to the hair coat.)
I like it because it can save some really seriously matted coats without resorting to cutting out the mats or shaving.