I'd like to store some geometric positions in my MySQL database. For this I use the POINT datatype. Almost everywhere I read that the function GeomFromText
should be used to insert data in the table.
However, I found out that POINT(X,Y)
also works. I didn't find any description why GeomFromText
should be used instead of POINT
.
For example I have the following simple relation:
CREATE TABLE Site (
SiteID BIGINT UNSIGNED,
Position POINT
);
And I can insert values using the following two variants:
INSERT INTO Site (
1,
GeomFromText( 'POINT(48.19976 16.45572)' )
);
INSERT INTO Site (
2,
POINT(48.19976, 16.45572)
);
When I view the table (SELECT * FROM Site
) I see the same binary blob for the location, and when I view the coordinates (SELECT *, AsText(Position) FROM Site
) I also see the same values.
So why should GeomFromText be used? Are there any (known) performance differences between these two variants? How is this solved in other database systems than MySQL?
INSERT INTO Site (Position) SELECT POINT(latitude, longitude) FROM tmp
is simpler than...SELECT GeomFromText(CONCAT('POINT(',latitude,' ',longitude,')' )) ...