title: Querying MongoDB with JSON / HTTP / REST Interface
body: <p>I am building an ASP.Net web application and want to access data from MongoDB (remotely hosted). Any of my documents looks like this (have ensured index on Utc field);</p>
  
  <pre><code>{ 
     "_id" : { "$oid" : "509501393e8785025c10bc21" }, 
     "Index" : 1,
     "Url" : "http:...", 
     "CameraId" : 123,  
     "Utc" : { "$date" : 1351955858006 } 
  }
  </code></pre>
  
  <p>Considering the performance on user end, I want to fetch this data at max speed. One option that i have tried is calling a local Web Service via JSON on Page.aspx which uses MongoDB C# driver to query documents between two Dates (Utc). That works but seems like using  web service adds some extra milliseconds in request/response cycle (request for single document using db.foo.findOne() is served in 1.3 seconds on average). Average number of documents in that collection is 50,000 which will increase up-to 30,00,000.</p>
  
  <p>My questions are:</p>
  
  <ol>
  <li>Am i right in saying that using web services adds some delay
  (millisecs) in request/response cycle ? (because MongoDB actually
  takes few milliseconds to complete the query)</li>
  <li>Second Option is to use MongoDB's <a href="http://www.mongodb.org/display/DOCS/Http+Interface" rel="nofollow noreferrer">HTTP / REST Interface</a>. That way i might avoid web services and directly query MongoDB. Here
  i need your opinion on,  
  
  <ul>
  <li>Is there a way to query MongoDB between two Dates using HTTP/REST ?,</li>
  <li>Is there a way to query MongoDB with '>' and '&lt;' conditions using HTTP/REST ?,</li>
  <li>How does it seem, accessing DB directly on Page.aspx with security point of view ?</li>
  </ul></li>
  <li>Any other querying alternative OR optimizations for above schema?</li>
  </ol>
  
  <p>My related question is <a href="https://stackoverflow.com/questions/13207217/having-large-number-of-collections-in-mongodb-need-schema-design-suggestions">here</a>.</p>
  
  <p>Regards.</p>