I’m in the process of developing a number of App Services functions that will be used by database triggers. One function needs to retrieve a document from another collection based on a foreign key found in an updated document. Currently I do not have a schema defined in the database, but can see that if I generate/define JSON schemas for my collections, I can define foreign key relationships.
Does defining a schema and relationships improve query performance at all, or are they really only used for document validation? Our data model is really defined in Go structs in our external application, and I’m not quite sure I see the need to additionally define schemas on the collections within Atlas if we’re sticking with a flexible schema approach. Or would defining a schema with relationships improve query performance?