Hello gunwoo,
In general we use XPath when we want to make complex constraints that we cannot perform with Database retrieval, but if you need to make a calculation I think the best way to achieve the result you want, in the most optimized way is do it with a Microflow and source from it.
In case you have some time I suggest to have a look at this learning path as it explains different data sources and their pros and cons: https://academy.mendix.com/link/paths/3/Win-at-Working-with-Data
Regards,
Fjordi