What data type can I use for very large text fields that are database agnostics?

In my Rails application, I want to preserve the geographical boundaries of the field column columns in the database. For example, the border of New York is represented as a polygon: an array of arrays.

I announced that my model serializes polygons, but I'm not sure that I should store them even that way. The size of these serialized polygons easily exceeds 100,000 characters, and MySQL can store about 65,000 characters in a standard TEXT field.

Now I know that MySQL also has a LONGTEXT field. But I really want my application to be database aggregated. How does Rails handle this on its own? Will it automatically switch to LONGTEXT fields? How about when I start using PostgreSQL?

+5
source share
4 answers

At this stage, I suggest you ask yourself: do I need to store this data or store it in a database in this format?

I suggest 2 possible solutions:

  • Store your polygons in the file system and link to them from the database. Such large data elements are of little use in a database - it is practically pointless to query them as text. The file system stores files well - use it.

  • , . polygon, point, , .

, .

+3

Postgresql PostGIS, , . , postgresql , . text[], . hstore.

+2

: Rails 65535, .

, , . MySQL Rails * TEXT. MySQL 1GB .

, benzado thomasfedb, , , , .

+2

, URL- - .

If in a database you can load 64K of data into memory when you are not going to use it, simply because you are accessing something in this table. And it's easier to scale a collection of read-only files (using something like Amazon S3) than a database table.

+1
source

All Articles