Cavities come in many shapes and sizes; the price of a composite filling varies based on how many surfaces are involved.
Each tooth has a total of 5 surfaces. There's the surface we use to chew or bite with, the surface that touches the cheek, the surface that touches the tongue, the surface that touches or touched the tooth in front of it, and the back surface of the tooth.
shutterstock 2152171719 min

1 surface filling

A 1 surface filling means that only one surface of the tooth is affected by the cavity. Most frequently it is the biting surface that has many grooves, but it can also be the surface on the cheek side or the tongue side. After adequately numbing the tooth, one side of the tooth has to have the cavity removed, and one side has to have the filling finished and polished, so the cost of a one-surface filling is less than larger fillings.

2 surface filling

A 2 surface filling means that two surfaces of the tooth are affected. Very frequently this happens when a cavity starts between teeth. A cavity that is between teeth is always a minimum of two surfaces, because it is necessary to drill through the biting surface to reach the cavity that developed between the teeth. This means that after adequately numbing and removing the cavity, it is necessary to place something called a matrix band to provide a shape for the additional surface, so that during the placement of the filling, the filling material creates a good contact and does not bond to the adjacent tooth. This involves more time in removing the cavity, more materials, and more time in finishing the two surfaces and polishing. There is also additional risk, because if the contact does not work out, part of the filling has to be redone to correct the contact.
shutterstock 1276642348 min
shutterstock 1619593054 min

3 surface filling

A 3 surface filling is often when both sides of the tooth have cavities that started between teeth. This involves additional time in shaping the contacts or additional surfaces, and additional finishing and polishing, again with additional possible areas of failure that would need to be corrected. A 3 surface filling can also be needed when a tooth cusp fractures or becomes undermined by the soft cavity.

4+ surface filling

A 4+ surface filling is when four or all five sides of a tooth are affected by cavity or fracture. Or, when a previous large 4 surface filling started leaking along the margins and the small decay has the potential to travel quickly along the filling margin towards the nerve. A 4+ surface filling is also often on front teeth where there is a chip that involves the biting edge. Four or five surfaces need to be properly shaped, and properly polished, so a 4+ surface restoration costs more than smaller restorations. The picture to the right shows a fracture where all 5 surfaces are affected, but it gets entered as a 4+ surface filling.
shutterstock 1780338716 min
shutterstock 1170029320

In addition,

When a cavity is close to the nerve, we rinse the tooth with ozone water, in order to reduce any bacteria that may be in the dentin, and we place a liner in the floor of the cavity, in order to try to protect the tooth from sensitivity. No one can guarantee that any particular tooth will have no sensitivity after a filling, but it is possible to give the tooth the best chances of having no sensitivity, and that is what we strive to do. When applying etch, we selectively etch enamel first, so that there is a good enamel bond, and we make sure to give the bonding agent plenty of time to soak into the dentin tubules, with the goal of having no sensitivity. In our office, we currently do not charge for the use of ozone water.