I'd like to get a list of `threads` of a `forum`, ordered by the latest activity:

* created thread
* created post

**Desired output**:

```
Thread name  | Timestamp (Thread) | Timestamp (latest post)
-----------------------------------------------------------
Thread A     | 1                  | 10                 <- old thread, newest post (newer than newest thread)
Thread C     | 3                  | -                  <- newest thread, no post
Thread B     | 2                  | 5                 

```

**EDIT / possible solution:**

```
SELECT
    t.*,
    IFNULL
    (         
        (
            SELECT p.timestamp 
              FROM posts p 
             WHERE p.thread_id = t.id 
             ORDER BY p.timestamp DESC LIMIT 1
        ),
        t.timestamp
    ) AS sorting 
FROM 
    threads t
WHERE t.forum_id = 1
ORDER BY sorting DESC

```

Does anyone have performance advices? Thanks everybody!