Very slow queries on server - copying to tmp table

You can avoid using temp tables on disk, if you not using BLOB or TEXT columns, unless your mysql will create a temp table on disk every time.

Another possibility is to set the temp tables location to a memory filesystem. That can help a lot too.