 <p>If there is a <code>FOREIGN KEY</code> constraint from <code>activity</code> to <code>item</code> (and assuming that <code>user_id</code> is in table <code>activity</code>), then your query is equivalent to:</p> <pre><code>SELECT COUNT(*), COUNT(DISTINCT user_id) FROM activity WHERE item_id = 3839 AND created_at &gt;= DATE_SUB(NOW(), INTERVAL 30 DAY) ; </code></pre> <p>which should be more efficient as it has to get data from only one table or just one index. An index on <code>(item_id, created_at, user_id)</code> would be useful.</p>