When a tooth has decay, a dental filling is likely the best treatment option.  Caught early enough, cavities can be treated easily and painlessly. If not treated, decay can lead to tooth pain, infection, and some circumstances, root canal treatment or extraction.   Most fillings are best performed under local anesthesia, however, in some cases, it can be done without.  Fillings require removal of the soft, bacteria-ridden tooth structure present.  If the decayed material extends deep (all the way to the nerve center of the tooth), it would require root canal treatment (see RCT page) prior to filling it.  

Once all of the decay is gone and the tooth is deemed structurally sound enough to be filled, a white (composite resin filling) is placed.  A UV light will then cure (harden) the resin.  The resin filling is then polished, and the patient's bite is adjusted.   Besides being tooth-colored, one of the main advantages of composite material is that it is also tooth-like in it's physical nature. This translates to teeth that are less prone to fracture and breakage when compared to other filling materials.  

Although amalgam fillings usage is sharply declining today, they are still employed in some dental offices (usually ones with aging doctors).   These fillings were the best available back in their day, but they are almost always inferior to the latest generation of today's composite resins.  Amalgam fillings unfortunately can (and usually do) create long-term damage in teeth due to being composed of a material very dissimilar to tooth structure.  While they may serve admirably for years,  after a decade or two, they will eventually cause stress fractures on teeth, leading to possible complete fractures and decay.  Because of this, when gapping or cracks are apparent around amalgam fillings, it is appropriate to replace them.