Loadrecords query very slow

Hi,

Moving on with my synchronization routines, i have noticed that the query I am using to get the range of records to loop through for syncronisation is taking 30 seconds to run:

remotefs.loadRecords("select id from so_appointments  where expert_id=? and date_modified between ? and ?", [login_to_so_customer.id,startdate,enddate])

This actually produces 20 records (from 25,000) but takes 30 seconds to do so. I have an index on both date modified and expert_id.

In fact the expert ID should limit the records mysql searches to 3000, so i cannot see how this would take so long.

When I analyse this is sequel pro taking the query from the servoy slow query log, it appears that the database doing a complete full table scan for each record it finds.
[attachment=0]Picture 3.png[/attachment]

All getting a bit above my head, but I would have thought that this shouldn’t take so long. One other bizarre feature is if I move my first date backwards and get more records returned (200) it actually works quicker.

Any help on how to speed up this query would be appreciated.

David