V
V
Vyacheslav Ptsarev2017-03-28 14:17:35
PostgreSQL
Vyacheslav Ptsarev, 2017-03-28 14:17:35

How to store large arrays of id in database?

I need to store large arrays of id's (social group members). And so I think how best to organize it so that you can not only store, but also efficiently receive data, for example:

  • find all groups of one member
  • get intersections of participants between groups
  • compare the new array with the one in the database for new members

I'm using PostgreSQL as my main database and it has an array field type that has no limit and is indexed. I'm thinking of creating a separate group_memebers table with group_id::int, member_ids::array. How is this the optimal solution? After all, there can be 10 million users in a group. The index will be gigantic. Perhaps ElasticSearch, MongoDB or other products have some advantages over Postgres in this case?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question