We identified 115,234 THA patients and 195,355 TKA patients, 12.4% and 15.6% with T2DM, respectively. We matched 10,777 and 26,640 pairs of diabetic and nondiabetic patients. In T2DM patients who had undergone THA, the incidence of urinary tract infection was higher than in nondiabetic patients (1.50% vs 1.09%, P = .007), as was that of “any IHPC” (9.68% vs 8.98%, P = .038). In patients who had undergone TKA, the incidence of postoperative anemia was significantly higher in diabetic patients (4.90% vs 4.53, P = .040), as was that of urinary tract infection (0.80% vs 0.53%, P = .025) and “any IHPC” (7.30% vs 6.76%, P = .014). In both procedures, mean length of hospital stay was significantly higher in diabetic patients; for TKA, in-hospital mortality was higher in diabetic patients (0.09% vs 0.02%, P = .002). Previous comorbidities, age, and obesity predict a higher incidence of IHPC among diabetic patients.