It’s a well-known issue. Search Google with key “Mobile test XPath slow”. You will get dozens of URL on that topic.
Quoting from Finding Mobile Elements with Robust Appium Locator Strategies and Selectors | by Lana Begunova | Medium
With the XCUITest driver, XPath might be very slow. This is because every time we run an XPath query, the entire app hierarchy must be recursively walked and serialized into XML, which can take a lot of time, especially if our app has many elements.
XPath as a mean to locate native Mobile elements through Appium costs a lot. You should avoid XPath.
Any alternative? Read the article above.