I have a database which consists of 50 million records and I am trying to execute the following query.
SELECT q FROM q GROUP BY q ORDER BY t DESC LIMIT 100;
But, because of the size of the database, this query takes about 10 seconds to execute. So, how do I optimize this query for faster execution? How does database indexing work? I referred to this page for an answer, it suggests to use indexing but doesn't exactly tell how? I am new to this, I need a quick solution to this problem as my site is loading very slow.