title: Parse Server - Saving objects with many fields - Schema Validation takes too long (enforceFieldExists)
body: <p>We're using ParseServer to migrate a CloudCode based application to Heroku.
  Using versions:</p>
  
  <ul>
  <li>parse@1.8.5</li>
  <li>parse-server@2.2.16</li>
  </ul>
  
  <p>We noticed (its hard not to notice) that saving some is unreasonably slow. These objects are typically saved a few at a time - between 2 to 6 objects (using an <code>Parse.Object.saveAll</code> which fires a REST call to <code>/1/batch</code></p>
  
  <p>Saving each of these objects now takes anything between 4 to 12 seconds. Digging into Parse code, it was easy to see that schema validation is the cause.</p>
  
  <pre><code>SchemaController.validateObject() {
  ...
  SchemaController.enforceFieldExists()
  </code></pre>
  
  <p>We are using triggers for simple validation, but as per the logic in <code>RestWrite.js</code> this causes schema validation to be executed twice - once before trigger and once after.</p>
  
  <p>The problem lies in that our collection has about 40 fields. <code>SchemaController.enforceFieldExists()</code> loads  the entire schema twice while attempting to validate <strong>each field</strong>. Moreover, it always attempts to write to the schema document (again, <strong>for each field</strong>), only to fail usually because all fields are already listed in the schema. </p>
  
  <p>this means that we get an overhead of about 240 round trips to the database for each object, and we store up to 5 objects typically in each invocation. that adds up to over 1000 round trips to the database. so we easily go beyond the Heroku router timeout limit of 30 seconds. </p>
  
  <p>My questions are:</p>
  
  <ol>
  <li>Is there anything I can do to speed up this validation? (did not find documentation or settings for that)</li>
  <li>Is there a fix for this redundant implementation planned or available anywhere?   </li>
  <li>Can I safely castrate <code>enforceFieldExists()</code> to do nothing without anything else breaking on me assuming we don't add fields often? What is this collection (<code>_SCHEMA</code>) used for other tan to draw the tables in Dashboard UI?</li>
  <li>I'm currently thinking about patching this function to do nothing with an npm postinstall script. Does that sound like a good approach?</li>
  </ol>
  
  <p>Appreciate any help on this,
  Ron</p>