I have a question about join relationships. Let's...
# community-help
n
I have a question about join relationships. Let's say I have collection_A and collection_B collection_A has a a document with id "1" and collection_B has a bunch of documents that have a field that is a join reference to collection_A. If I delete the collection_A document that the documents in collection_B refer to, but I don't delete them in collection_B, will this cause a problem? Finally, if I want to drop this join/referencing column from collection_B, and say collection_B is a huge table, will this operation take a very long time?
f
Joining happens on search-time, so it won't take a performance impact on dropping collections. As for cascading deletions / behavior after dropping a referenced document, @Harpreet Sangar has more context, but there shouldn't be problem in regular search, and when you will re-index a document with the referenced id, it will match it when JOINing
n
Thanks. For my last question, I was wondering about a schema change -- if I drop the reference definition from the schema, will it take a long time?
h
If I delete the collection_A document that the documents in collection_B refer to, but I don't delete them in collection_B, will this cause a problem?
We cascade delete all the documents that reference a particular document.
For my last question, I was wondering about a schema change -- if I drop the reference definition from the schema, will it take a long time?
No. It would take the exact same time as if deleting a normal field.
n
Thanks @Harpreet Sangar For a large collection, does dropping a column take a long time? Is the collection blocked during during this time? I've never run a schema change on a large collection before so I'm not sure what to expect.
And sorry, one more question, if I drop the join/reference condition from the schema, I should be able to delete without dealing with the cascade delete happening?
h
For a large collection, does dropping a column take a long time? Is the collection blocked during during this time?
I'm not sure, I'll let you know.
if I drop the join/reference condition from the schema, I should be able to delete without dealing with the cascade delete happening?
Cascade deletion happens when you delete a document that is referenced in some other collection. Say collection_A document is deleted in you case. When you drop the reference field (collection_B in your case), no cascade deletion will be triggered.
For a large collection, does dropping a column take a long time? Is the collection blocked during during this time?
During this time the collection will only be blocked for write operations.
n
@Harpreet Sangar Thank you for your answers