title: Does lazy val on a Future prevent an actual database call?
body: <p>I want to conduct a query like this:</p>
  
  <ol>
  <li>Query for a record on a specific date;</li>
  <li>if (1) fails, then Query for a record on a range of dates, taking the last date.</li>
  </ol>
  
  <p>The way I'm handling this now is:</p>
  
  <pre class="lang-scala prettyprint-override"><code>
  lazy val specific: Future[Option[QueryResponse]] = // some database call
  
  lazy val range: Future[Option[QueryResponse]] = 
    // some database call returning Future[Seq[QueryResponse]]
    .map { qrs =&gt;
      if (qrs.nonEmpty) Some(qrs.maxBy(_.date)(_ compareTo _))
      else None
    }
  
  for {
    s &lt;- specific  
    r &lt;- range
  } yield {
   (s, r) // match on combination of Some/None
  }
  </code></pre>
  
  <p>Two questions:</p>
  
  <ol>
  <li>Does lazy prevent evaluation of the database call? I'd like as few calls to be made as possible. This is as much a language question as anything else. </li>
  <li>Recognizing that 1 database call must be made regardless, it's probably best to make the call for a range and then filter locally on the POJOs to find the latest date, correct?</li>
  </ol>