Foreign Key Array Fields: Is there a max. array length to plan to use this feature for?

#1

If I want a field on a Type that looks like:

entity type TypeA {
collectionFieldA: [TypeB](typeA, id)
}

Is there a suggested limit for how many instances of TypeB I should expect to have their typeA field equal to the same TypeA instance?

Essentially, what are the limits/guidelines to creating an instance of TypeA where the collectionFieldA array length is 10, 100, 1,000, 10,000, 1,000,000?

I realize the large numbers are unrealistic, but what is the best practice here?

0 Likes

#2

I may be wrong but I don’t think there is any limit here. Fkey array fields are not persisted; they are essentially an instruction for the database to perform a join. So you are looking at a query like select * from type_a left join type_b where type_b.ref_id = type_a.id. This can work at any a/b ratio, the only limitations are those that apply to the data store itself (i.e. if you have a trillion rows in a Postgres table, this will not work well).

0 Likes