Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Questions & Help Needed
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Questions & Help Needed Post any question regarding Basic4ppc.


fastest way to search in database


Reply
 
LinkBack Thread Tools Display Modes
  #11 (permalink)  
Old 10-07-2007, 11:12 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,134
Default

I've compressed one of the images and uploaded your project.
Reply With Quote
  #12 (permalink)  
Old 10-07-2007, 06:17 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,689
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

I assume that it is sub WPcheck that you want to speed up. A couple of suggestions then :-

Code:
Xdistance = WP.Cell("X",i) - utmi(1) 
If abs(Xdistance) < appr Then       
    ' carry on and check Y
End if
The single comparison is neater and faster then the code below. Also saving the distance is faster as it minimises variable accesses and computation time and you would need that result again for its' sign for a binary search (see below).
Code:
If WP.Cell("X",i) > utmi(1)-appr Then        '200m voor appr= 200
    If WP.Cell("X",i) < utmi(1)+appr Then    '200m na
        ....
    End if 
End if
If you sort the table by X (or Y)and do a binary search, rather than a linear one like you are doing at the moment, to pick out the possible X (or Y) matches and then do the other comparisons you should end up with a dramatic increase in speed on a large table. Your 1500 item table would only need about 12 of my simplified comparisons above to isolate a WayPoint or decide that you were not near enough to any of them.
Reply With Quote
  #13 (permalink)  
Old 10-07-2007, 08:37 PM
LineCutter's Avatar
Senior Member
 
Join Date: May 2007
Location: Daarsit
Posts: 117
Awards Showcase
Beta Tester 
Total Awards: 1
Default

You can cut that further by knowing the region of interest in the data so that the binary search starts inside the absolute boundaries of the list.

For the sake of argument, take the position of the first point found (search the whole database) & then use that index +&-10% of the size of the database as the limits for the next search. Remember, with GPS data at 1 second intervals there are going to be no nasty surprises jumping from one end of the database to the other.

Fewer data points to search == quicker.
Reply With Quote
  #14 (permalink)  
Old 10-10-2007, 08:17 AM
Knows the basics
 
Join Date: May 2007
Posts: 87
Default

hi agraham, LineCutter,

@ agraham,
did the binair search, and it was a big improvement, only 200 mSec maximum in 11 jumps, In place of 13 Seconds. Now I go try Your code, like you say, it seams that I lost much time going trough approch distance calculations every comparasion. Thanks very much...
Tested your code, great improvement, for 1500 point it speedup from 31 msec to 15 mSec...
@ LineCutter,
After code improvement, I see that your suggestion simply is a must, without going that way it is not possible to get result, so making regions at start with less waypoints to check, I understand, I will be busy for a while now.... Seams you are well now with the problem... and thank you also for pulling me in the right direction..

After reading carfully, I see I misunderstud : I understand now, I have to change the startpoint to search from in the waypointlist from 8 to 10 % around the actual position point every fetch of the new position... so I must only compare a few points in the enviremont.

Put claude Belgium

Last edited by Put Claude : 10-10-2007 at 12:08 PM. Reason: forgot something
Reply With Quote
  #15 (permalink)  
Old 10-10-2007, 09:53 PM
LineCutter's Avatar
Senior Member
 
Join Date: May 2007
Location: Daarsit
Posts: 117
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Quote:
Originally Posted by Put Claude View Post
After reading carfully, I see I misunderstud : I understand now, I have to change the startpoint to search from in the waypointlist from 8 to 10 % around the actual position point every fetch of the new position... so I must only compare a few points in the enviremont.
You might want to make that +/- 100 points or 10%, whichever is greater. (Or any other numbers, the choice of 100points/10% was arbitrary)

That way you won't miss nearby waypoints in a small database.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Forum search token Forum Discussion 0 07-16-2008 08:33 PM
Copy Record from one database to another database. mozaharul Questions & Help Needed 0 07-15-2008 05:47 AM
FASTEST way to make a RND number list, no doubles Stellaferox Questions & Help Needed 8 02-06-2008 01:16 PM
Fastest way to get pixel colour value? DavidN Questions & Help Needed 6 09-02-2007 07:40 AM
How to convert an Access database to a sqlite database Peter Code Samples & Tips 5 07-24-2007 04:20 PM


All times are GMT. The time now is 06:46 PM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0