title: Optimizing a PostgreSQL SELECT query (sqlfiddle)
body: <p>I have 2 tables named <code>player</code> and <code>team</code>, which are tied together in a many-to-many relationship via a third table named <code>player_team</code>.</p>
  
  <p>The table structure &amp; current query can be found: <a href="http://sqlfiddle.com/#!2/e6db4/18" rel="nofollow">http://sqlfiddle.com/#!2/e6db4/18</a></p>
  
  <p>I need a query, that returns the player's data, along with <code>team.id</code>, which includes the player's maximum rating. Also, if the rating is <code>&lt;= X</code>, then that player should be excluded.</p>
  
  <p>The example query returns the correct results, but is quite inefficient.</p>
  
  <p>Obviously, the same results can be achieved by accessing each table's rows only once, but the question is how to achieve this? (I'd prefer replies that are in PostgreSQL dialect)</p>