Table: articles
+--------+------+------------+
| id | title| created |
+--------+------+------------+
| 201 | AAA | 1482561011 |
| 202 | BBB | 1482561099 |
| 203 | CCC | 1482562188 |
+--------+------+------------+
Table: taggings
+-----------+------+
| articleid | tagid|
+-----------+------+
| 201 | 11 |
| 201 | 12 |
| 202 | 11 |
| 202 | 13 |
| 202 | 14 |
+-----------+------+
Now if given 3 tag ids, what is the best index design and query to select latest 10 articles that each article match the 3 tag ids at the same time?
I know there can be several ways to do it, but I'm concerning the performance, considering there maybe tens of thousands of articles in each tag
query to select latest 10 articles
- please explain how do you definelatest article
? Is there a date column in some table, which is not shown in the question ? Or doesthe latest
mean the highest values inid
columns? – Selangor