Objective The objective of this study is to determine demographic and diagnostic distributions of physical pain recorded in the clinical notes of a mental health electronic health records database by utilising natural language processing and to examine the level of overlap in recorded physical pain between primary and secondary care. Design, Setting and Participants The data were extracted from an anonymised version of the electronic health records from a large mental community and secondary healthcare provider serving a catchment of 1.3M residents in south London. These included patients under active referral and aged 18+ at the index date of July 1, 2018, and had at least one clinical document (>=30 characters) associated with their record between July 1, 2017 and July 1, 2019. This cohort was compared to linked primary care records from one of the four catchment boroughs. Outcome The primary outcome of interest was the presence or absence of recorded physical pain within the clinical notes of the patients. This does not include mental, psychological or metaphorical pain. Results A total of 27,211 patients were retrieved based on the extraction criteria. Of these, 52% (14,202) had narrative text containing relevant mentions of physical pain. Patients who were older (OR 1.17, 95% CI 1.15-1.19), female (OR 1.42, 95% CI 1.35-1.49), of Asian (OR 1.30, 95% CI 1.16-1.45) or Black (OR 1.49, 95% CI 1.40-1.59) ethnicities, and living in deprived neighbourhoods (OR 1.64, 95% CI 1.55-1.73) showed higher odds of recorded pain. Patients with an SMI diagnosis were found to be less likely to report pain (OR 0.43, 95% CI 0.41-0.46, p<0.001). When comparing the overlap between primary and secondary care, 17% of the CRIS cohort also had records within LDN, and 31% of these had recorded pain in both records. Conclusion The findings of this study show the sociodemographic and diagnostic differences in recorded pain, and have significant implications for the assessment and management of physical pain in patients with mental health disorders.