ORDERBY timestamp performance issue
This is normal situation


when You run query without ORDER BY - LIMIT 30; work perfect - it stop query after first 30 records, any 30 records
When You add ORDER BY - MySQL first send all records to temporary table (if dataset big), than sort it, and then return to You 30 correct records


So on huge dataset - it work as expected.
Solution really only one - analyse query and reduce number of total records returned by query, how - depend from business logic

For example - posts.created_at &lt;= '2016-10-24 10:30:53' (it mean yesterday) return all records from 5 000 000, but if add posts.created_at >= '2016-09-24 10:30:53' it return only month of data and etc - any legal ways for reduce number of records.

Second recommendation depend from Your table structure, some time replace SELECT * to the SELECT "WHAT REALLY NEED" could dramatically increase speed - for example one of column BLOB or TEXT, so exclude this column from SELECT - reduce size of data before sort for many. many times.
Even if this BLOB column need for You - You can request it by ID (single record) by second query from the page