I have a table comment
like :
id article_id approved created_at
7 104506 1 2019-12-02 09:36:32
6 104452 0 2019-12-02 09:31:35
5 104498 1 2019-12-02 09:27:56
4 104506 1 2019-12-02 09:05:45
3 104511 1 2019-12-02 08:58:56
2 104501 1 2019-12-02 08:52:57
1 104552 1 2019-12-02 08:50:10
What I would like:
104506
104498
104511
104501
104552
and I would like to get a distinct list of article_id approved order by created_at desc
So I just do this:
SELECT article_id FROM comment WHERE approved = 1 GROUP BY article_id ORDER BY created_at DESC LIMIT 30
But on a 400k rows table, it takes 1,28 secs.
Any idea to have a faster query? Thanks!