Neuroinflammation is associated with the development of postoperative cognitive dysfunction (POCD). Parecoxib has powerful anti-inflammatory and analgesic effects, which may reduce the occurrence of POCD. We hypothesized that parecoxib could reduce the incidence of POCD and relieve postoperative pain without increasing postoperative complications in elderly patients with gastrointestinal cancer. The study analyzed the effect of parecoxib on elderly patients undergoing elective radical resection of gastrointestinal tumors. Patients were divided into the NSAIDs group and the non-NSAIDs group according to whether parecoxib was administered. Demographic and clinical data were collected and compared. The incidence of POCD was set as the primary outcome, and postoperative pain as the secondary outcome. Among the 440 enrolled patients, the POCD incidence rates within 7 days after surgery in the NSAIDs and non-NSAIDs groups were 42.60% and 40.30%, respectively, with no statistically significant difference (P > 0.05). Patients in the NSAIDs group experienced significantly less pain on the first and second days after surgery compared to the non-NSAIDs group (P < 0.05). There were no statistically significant differences in postoperative adverse events between the two groups (P > 0.05). Parecoxib had no significant negative effect on early postoperative cognitive function, effectively alleviating early postoperative acute pain without increasing postoperative complications. The findings have implications for the broader use of parecoxib in postoperative pain management in elderly patients undergoing major surgery.