title: Entity Framework efficient querying
body: <p>Lets say I have a model, <code>Article</code> that has a large amount of columns and the database contains more than 100,000 rows. If I do something like <code>var articles = db.Articles.ToList()</code> it is retrieving the entire article model for each article in the database and holding it in memory right? </p>
  
  <p>So if I am populating a table that only shows the date of the entry and it's title is there a way to <strong>only</strong> retrieve just these columns from the database using the entity framework, and would it be more efficient?</p>
  
  <p>According to <a href="http://msdn.microsoft.com/en-us/library/cc853327.aspx" rel="nofollow noreferrer">this</a>,</p>
  
  <blockquote>
    <p>There is a cost required to track returned objects in the object
    context. Detecting changes to objects and ensuring that multiple
    requests for the same logical entity return the same object instance
    requires that objects be attached to an ObjectContext instance. If you
    do not plan to make updates or deletes to objects and do not require
    identity management , consider using the NoTracking merge options when
    you execute queries.</p>
  </blockquote>
  
  <p>it looks like I should use <code>NoTracking</code> since the data isn't being changed or deleted, only displayed. So my query now becomes <code>var articles = db.Articles.AsNoTracking().ToList()</code>. Are there other things I should do to make this more efficient?</p>
  
  <p>Another question I have is that according to <a href="https://stackoverflow.com/a/8108643/985284">this answer</a>, using <code>.Contains(...)</code> will cause a large performance drop when dealing with a large database. What is the recommended method to use to search through the entries in a large database? </p>