This question already has an answer here:
I have a bunch of LINESTRINGs and need to classify them based on how strait they are. My idea is to compare the length of the LINESTRING to the distance between the first and last POINTs.
I'm thinking of something along these lines (assume the srs units are in meters):
ST_Length_Spheroid(geom) - ST_Distance_Spheroid(ST_PointN(geom, 1), ST_PointN(geom, St_NumPoints(geom)))
Is there a better way to do this?