Can the database handle an array with millions of entries (32bytes strings)?

Hey there,

Context:
My app is pretty much an instagram clone.

I’ve a “Posts” class and a “Followers” class.
Every user can have any number of posts and any number of followers.

Problem:
I would like to be able to query all the “posts” of the users I’m currently following.

I could first query the “Followers” class and fetch all the users I’m following and then fetch their posts.

However saving users ID’s to an array would reduce the number of queries to 1 and make the job a bit easier.

Let’s say I’m following 1 million users. Would it be ok to keep all theirs usernames in a array in my “User” class under a column named “following”?

Can the database handle that? Can this create problems? If this is not recommended for any reason then I won’t implement it this way.

The usernames are 32bytes in the worse case scenario

What’s in your opinion the best solution?

Hi @pwnedev

You should not use Array to store this kind of data. Array field type on Parse is not designed and does not perform well if too many elements are stored into an Array type field. Parse has a dedicated field type “Relation” to handle your use case.

Here the JS doc example: JavaScript Developers Guide | Parse

The Parse Server Auto Generated GraphQL APi is also well suited for your use case to easily retrieve Followers and Post in a single query, some example doc:GraphQL API Guide | Parse

1 Like