php – Calculation in base or in application?

Question:

There was a question, perhaps, silly, but nevertheless. There is an application in php and a database with a Postgresql subd with the postgis extension. Let's say the coordinates of points are stored in the database and you need to calculate the distance between two points. Where is the best place to do this distance calculation in terms of performance, at the application level or at the base level?

Answer:

I recommend using an in-memory database or an application as a cli, it is advisable to write it not in php

https://www.sqlite.org/inmemorydb.html

Scroll to Top