The procedure takes about 20 to 30 minutes. The endoscopy allows the doctor to examine the upper gastrointestinal tract, such as the stomach, esophagus, and first part of the small intestine. A gastroenterologist or a surgeon performs it.