New answers tagged

1 vote

How do I optimize this query that gets the newest entry of each group?

You can try the following query. Adding an index on (tid, timestamp, id) should help with efficiency: SELECT a.* FROM ( SELECT DISTINCT tid FROM ast ) AS t LEFT JOIN ast AS a ON ...
0 votes

How do I optimize this query that gets the newest entry of each group?

The only efficient solution for the "newest one of the each group" is denormalization. You have to create the table of the same stucture as table storing your groups but with UNIQUE index on ...
Kondybas's user avatar
  • 4,283

Top 50 recent answers are included