Even with appropriate indexes, the following query is slow:
Without the order by statement, it is a ton faster (even though there is an index on datecreated). I believe the performance issue is a combination of the inner join + the order by - something about that making the index not be in use. The following variation works very performantly:
Here we join on a subset of the trail where we just select an ID from the audit log ordered by datecreated and limited to our subset count.