Painless gastroscopy is commonly performed under general anesthesia without establishing an artificial airway. This is associated with an even higher anesthetic risk than general anesthesia in the operating room due to more basic patient monitoring and life-supporting equipment, only one anesthetist to perform anesthesia, fatigue in anesthesia, the requirement for a high turnover rate, as well as limited understanding of a patient's condition. Therefore, the availability of sedatives and analgesics which can provide rapid onset, sufficient sedation and analgesia, a short recovery time and less adverse effects are the premise of performing painless gastroscopy. Currently, combined intravenous anesthesia with fentanyl and propofol, commonly used in the clinic, is still associated with a long duration of action, hypotension in some patients and prolonged recovery. Etomidate has been increasingly utilized for in-clinic diagnosis and treatment for procedures such as painless coloscopy and early induced abortion due to its rapid onset, rapid metabolism and minimal impact on the circulatory and respiratory systems. However, no study on combined intravenous anesthesia with fentanyl and etomidate for painless gastroscopy had previously been reported. The main purpose of this study is to explore the efficacy and safety of combined intravenous anesthesia with fentanyl and etomidate for painless gastroscopy compared with the combination of fentanyl and propofol in middle aged and elderly patients, and to provide reliable evidence for the implementation and promotion of comfortable medical care.