 <p>You can reverse the query on the secondary categories:</p> <pre><code>(SELECT articles.* FROM articles WHERE primary_category_id = 1) UNION DISTINCT (SELECT articles.* FROM articles_secondary_categories AS categories JOIN articles ON (categories.article_id = articles.id) WHERE categories.category_id = 1 GROUP BY articles_id) ORDER BY publish_at DESC LIMIT 10; </code></pre> <p>It should give you a decent speed boost - just make sure you index categories.articles_id</p>