mySQL group by 3 columns <p>I have a query here that group by 3 columns and count the total rows</p> <pre><code>SELECT count(*) FROM ( SELECT date,bankName FROM table GROUP BY date,bankName,referenceNo ) a; </code></pre> <p>Basically, this query is used for pagination. I have two queries before this one.</p> <p>I have 166,000 rows of data now and this query taking 1.23 seconds to return the result which is not nice to use when the data grows. What should I do?</p>