Soft delete does not automatically set an index as far as I can see at this moment.
It does:
public function softDeletes($column = 'deleted_at', $precision = 0)
{
return $this->timestamp($column, $precision)->nullable();
}
So it could be worth a shot to add an index on it. It feels strange that this isn't done by default.
It is hard to see from here what you could do. Just to clearfiy, we are talking about the actual query that returns the records right? Not the count() query that you cached. What do you define as slow at this moment?
You could try using the EXPLAIN method on a full query (including the limit that the pagination would add).
Something like:
EXPLAIN select `id`, `position`, `company`, `source`, `industry`, `work_location`, `salary_avg` from `job_descriptions` where `country` = ? and `salary_avg` > ? and `salary_avg` < ? and `job_descriptions`.`deleted_at` is null LIMIT 20000, 100
@newbie360 deleted records should not be moved to another table. That would create a architectural nightmare for different reasons. Deleted records should be deleted or marked as deleted (in the same table).