1

I'm about to start an application that will need a simple distance query to order results. After some search I've discovered some functions that seems to do this work pretty easily without needing PostGIS, what seems to be too much for my task.

My question is: what would be better from a performance point of view, using a POINT datatype to store lat/long or two DOUBLE fields, separately? Would they have any difference?

Bonus question: is the approach from that link a nice idea indeed?

2
  • Sorry Erwin, I saw you replied but forgot to read :B Do you have any opinion over the functions on the link I cited? Commented Sep 22, 2015 at 7:44
  • 1
    I don't know the author of that blog. The cube and earthdistance modules have been around for more than 10 years and are solid. If approximate results are good enough, that's a valid option. The GiST index is the key feature. I would start by reading the manual on the two modules. Commented Sep 22, 2015 at 13:01

1 Answer 1

2

A point consist of two double precision values. You store the same information, same size on disk and in RAM. But with a slightly different set of constraints.

Two separate columns can be NULL or not independently. A point can only be NULL as a whole:

You can use geometric functions and operators for points. But you can easily construct a point from two numbers on the fly: point(x, y). In reverse, you can easily access coordinates of a point as double precision numbers: p[0], p[1] (0-based index!)

It's basically a matter of taste and style while you don't use the more sophisticated types geometry or geography provided by PostGis.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.