Below the Radar
Below the Radar

Reputation: 7635

Postgres - What column type to use to store nested arrays

In my nodeJs application I need to store and retrieve nested arrays that represents coordinates of features geometry (point, lines, polygon) but not in a format usually used by postgis.

For instance the arrays would look like this:

[[0, 0, 0, 1, 0, 2, ...], [1, 0, 1, 1, 1, 2, ...], ...]

or conceptually:

[[x0, y0, x1, y1, x2, y2, ...], [x0, y0, x1, y1, x2, y2, ...], ...]

I dont want to transform those arrays into a postgis geom structure.

I want to be able to store and retrieve thoses arrays in the simplest way.

What postgres column type would you suggest?

Edit: those arrays could be large

Edit2: In the example above, the numbers are small int but in reality they would be float

Upvotes: 2

Views: 867

Answers (1)

Dmitri
Dmitri

Reputation: 9157

Use text.

Really, if you're not going to manipulate them in the database (eg search by coordinates) text will be smaller (and compress better), and easier to work with than either json/jsonb or SQL arrays (which can be multidimensional, just for the record).

Upvotes: 3

Related Questions