Objective To investigate the effects of remifentanil combined with different doses of dexmedetomidine on cognitive function, plasma insulin, and blood glucose in elderly diabetic patients undergoing painless gastrointestinal endoscopy. Methods This prospective study selected 179 elderly diabetic patients who underwent painless gastrointestinal endoscopy at Xidian Group Hospital from January 2020 to January 2024. Patients were randomly divided into a low-dose group (89 cases) and a high-dose group (90 cases) using a random number table method. In the low-dose group, there were 48 males and 41 females, with an average age of (68.64±7.35) years and a diabetes duration of (8.35±1.46) years. In the high-dose group, there were 46 males and 44 females, with an average age of (67.46±8.23) years and a diabetes duration of (8.74±1.35) years. The low-dose group received intravenous remifentanil at 0.2 mg/kg + dexmedetomidine at 0.5 µg/kg, while the high-dose group received intravenous remifentanil at 0.2 mg/kg + dexmedetomidine at 1.0 µg/kg. General data for both groups were collected. Hemodynamic parameters, blood glucose, plasma cortisol, and adrenaline levels were statistically analyzed and compared at five time points: after admission (T0), at the start of anesthesia induction (T1), upon completion of anesthetic drug administration (T2), 2 minutes after endoscopy (T3), and 2 minutes after recovery (T4). Additionally, the time to disappearance of the eyelash reflex, Ciprofol dosage, recovery time after anesthesia, and gastrointestinal function were compared between the two groups. The cognitive function (Mini-Cog score), recovery quality [ Richmond sedation-agitation scale (RASS), visual analogue scale (VAS) score ] and adverse reactions during the examination were statistically compared between the two groups before and after the examination. Statistical analyses were conducted using χ², t, and F tests. Results The mean arterial pressure (MAP), heart rate (HR), peripheral blood oxygen saturation (SpO2), and respiratory rate (RR) at T0, T1, T2, T3, and T4 showed statistically significant differences (all P<0.05). There were significant differences in MAP, HR, SpO2 and RR between the two groups at T1, T2, T3 and T4(F=76.565, 31.402, 11.852, 24.236, all P<0.001). The trends in changes of MAP, HR, SpO2, and RR between the two groups were statistically significant (all P<0.05). Comparisons of blood glucose, insulin, plasma cortisol, and adrenaline levels at different time points also showed statistically significant differences (all P<0.05). The levels of blood glucose, insulin, plasma cortisol, and adrenaline at T1, T2, T3 and T4 in the high-dose group were lower than those in the low-dose group (F=156.364, 1 208.490, 91.566, 46.861, all P<0.001), with smaller fluctuations. The trends in changes of blood glucose, insulin, plasma cortisol, and adrenaline levels between the two groups were statistically significant (all P<0.05). The disappearance time of eyelash reflex in the high-dose group was shorter than that in the low-dose group [(2.60±0.45) min vs. (2.78±0.55) min], and the dosage of propofol in the high-dose group was less than that in the low-dose group [(81.35 ±13.24) mg vs. (122.45±23.13) mg]. The time to call for eye-opening and the time to regain orientation in the high-dose group were (10.76±1.21, 19.67±1.23) min, both longer than those in the control group [(7.56±1.68, 17.12±0.98) min], with statistically significant differences (all P<0.05). The recovery time of bowel sounds, time to pass gas, and time to defecate in the high-dose group were (2.01±0.77) d (16.75±5.31) h, and (2.12±0.44) d, respectively, all longer than those in the low-dose group [(1.26±0.43) d, (7.13±4.11) h, (1.21±0.57) d] (all P<0.05). The Mini-Cog scores in the high-dose group were lower than those in the low-dose group [(2.68±0.96) points vs. (3.03±0.67) points]. The Ramsay sedation scores in the high-dose group were higher than those in the low-dose group [(1.73±0.13) points vs. (1.60±0.12) points], while the RASS and VAS scores were lower in the high-dose group [(1.66±0.12)points vs. (1.82±0.11) points, (1.85±0.21) points vs. (1.96±0.27) points)], with statistically significant differences (t=2.826, 6.950, 9.296, 3.044, all P<0.05). Conclusion Ciprofol combined with different doses of dexmedetomidine in painless gastrointestinal endoscopy for elderly diabetic patients shows that the high-dose group has advantages in maintaining stable hemodynamic indices, lower blood sugar and insulin levels, and quicker functional recovery without increasing the risk of adverse reactions. This indicates that the dosage can be adjusted according to the specific clinical situation of patients to optimize treatment effects and patient safety.