It appears this is a problem on mysql because ST_Area() bombs on non-2D objects while MariaDB just returns 0.
What we actually care about is ST_Contains() and not ST_Intersects(). ST_Intersects() will return true if only an edge intersects, but ST_Contains() will ensure there's at least some amount of containment/area.
I've kept ST_Intersects() in front of ST_Contains() because the query was super slow without it. Keeping it reduces calls to ST_Contains().
It appears this is a problem on mysql because ST_Area() bombs on non-2D objects while MariaDB just returns 0.
What we actually care about is ST_Contains() and not ST_Intersects(). ST_Intersects() will return true if only an edge intersects, but ST_Contains() will ensure there's at least some amount of containment/area.
I've kept ST_Intersects() in front of ST_Contains() because the query was super slow without it. Keeping it reduces calls to ST_Contains().