MySQL says in the docs for ST_Distance_Sphere
Calculations use a spherical earth and a configurable radius. The optional radius argument should be given in meters. If omitted, the default radius is 6,370,986 meters. If the radius argument is present but not positive, an
ER_WRONG_ARGUMENTS
error occurs.
PostGIS says in the docs of ST_Distance_Sphere
, (though the docs aren't accurate anymore)
Uses a spherical earth and radius of 6370986 meters.
Where did they get the default 6,370,986 meters from? WGS84 says major-axis radius is 6,378,137.0 m. PostGIS which now uses a Average Radius essentially uses 6371008.
Looking at the code
#define WGS84_MAJOR_AXIS 6378137.0
#define WGS84_INVERSE_FLATTENING 298.257223563
#define WGS84_MINOR_AXIS (WGS84_MAJOR_AXIS - WGS84_MAJOR_AXIS / WGS84_INVERSE_FLATTENING)
#define WGS84_RADIUS ((2.0 * WGS84_MAJOR_AXIS + WGS84_MINOR_AXIS ) / 3.0)
that means
-- SELECT 6378137.0 - 6378137.0 / 298.257223563;
WGS84_MINOR_AXIS = 6356752.314245179498
-- SELECT ( 2.0 * 6378137.0 + ( 6378137.0 - 6378137.0 / 298.257223563) ) / 3.0;
WGS84_RADIUS = 6371008.771415059833
Newer versions are much less efficient, more complex, and use Pro4j but they seem to do the same thing.
Still where does 6370986 come from?
(2*minorAxis+majorAxis)/3
... though that value for WGS84 is still a few meters larger (6,371,008.771)