# Loadrecords query very slow

**URL:** <https://forum.servoy.com/t/loadrecords-query-very-slow/11342>\
**Category:** Classic Servoy\
**Created:** [October 30, 2009, 12:44pm UTC](https://forum.servoy.com/t/loadrecords-query-very-slow/11342 "2009-10-30T12:44:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dpearce](https://avatars.discourse-cdn.com/v4/letter/d/e95f7d/32.png) [@dpearce](https://forum.servoy.com/u/dpearce)\
**Post date:** [October 30, 2009, 12:44pm UTC](https://forum.servoy.com/t/loadrecords-query-very-slow/11342/1 "2009-10-30T12:44:38Z")

</div>

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:

```auto
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

 ![Picture 3.png](https://canada1.discourse-cdn.com/flex010/uploads/servoy/original/2X/f/fe1543225a23bddbb50a79fc8c4ac3bf5d8f3ec1.png)
