duniyaKaRakhwala
duniyaKaRakhwala

Reputation: 35

Read and write operations Array vs multiple rows in Postgres

If I want to store 10k (sometimes less or more) string values against the same ID multiple times, should I use an array to store those string values or should I insert those string values one by one against the same ID.

Upvotes: 2

Views: 1094

Answers (1)

Dri372
Dri372

Reputation: 1321

You can do both but just have a look to this tips extract from the doc

Tip: Arrays are not sets; searching for specific array elements can be a sign of database misdesign. Consider using a separate table with a row for each item that would be an array element. This will be easier to search, and is likely to scale better for a large number of elements.

https://www.postgresql.org/docs/current/arrays.html

So I should prefer to store muliple rows.

Upvotes: 4

Related Questions