An upper endoscopy (EGD) is performed to examine the upper gastrointestinal tract, including the esophagus, stomach, and the first portion of the small intestine, called the duodenum. The procedure involves using a long, flexible, fiber-optic tube called an upper endoscope.