OSM data is in webmercator projection by default (EPSG 3857), which is a good projection for display but that introduces severe distortions (about 40% at 45 degrees of latitude). You can look at this article for the explanations.
To compute the distance, you have two choices:
1) you can transform the data to a projection that is suitable to your area and that does not distort the data too much (UTM or alike might be good candidates).
2) you transform your data to geography, meaning it is not projected on a flat ground, but it is rather kept on a round earth surface. This approach is easy but it considers great-arcs instead of straight lines between two points. Unlike 4326, the unit of the geography type is meters, not degrees.
The doc says
The basis for the PostGIS geometry type is a plane. The shortest path
between two points on the plane is a straight line. That means
calculations on geometries (areas, distances, lengths, intersections,
etc) can be calculated using cartesian mathematics and straight line
vectors.
The basis for the PostGIS geographic type is a sphere. The shortest
path between two points on the sphere is a great circle arc. That
means that calculations on geographies (areas, distances, lengths,
intersections, etc) must be calculated on the sphere, using more
complicated mathematics. For more accurate measurements, the
calculations must take the actual spheroidal shape of the world into
account, and the mathematics becomes very complicated indeed.
Assuming your data is in EPSG 3857, you could compute the area using:
SELECT
name, ST_Area(ST_Transform(way, 4326)::geography) AS m2,
ST_Area(ST_Transform(way, 4326)::geography)/10000 as ha
FROM
planet_osm_polygon
ORDER BY ha DESC
LIMIT 1;
geographyor provide a proper syntax for theST_Transform(placing it inside theST_Area) – Vince Sep 27 '18 at 15:42