Re: [sqlite] What is the most efficient way to get the close by numbers?

2010-08-22 Thread Peng Yu
On Sat, Aug 21, 2010 at 10:45 PM, ve3meo wrote: > "Eric Smith" ... >> I haven't used it myself, but I'm pretty sure this is what the R*tree >> module was designed for: > > I have not used it either but was intrigued by your suggestion. Looking into > it, my sense was that it would be advantageous

Re: [sqlite] What is the most efficient way to get the close by numbers?

2010-08-21 Thread ve3meo
"Eric Smith" ... > I haven't used it myself, but I'm pretty sure this is what the R*tree > module was designed for: I have not used it either but was intrigued by your suggestion. Looking into it, my sense was that it would be advantageous for a 2-dimension or more search and I think this was bo

Re: [sqlite] What is the most efficient way to get the close by numbers?

2010-08-21 Thread Peng Yu
Thank you! I don't find which sqlite document describes 'between ... and ...'. Would you please point to me where it is documented? On Fri, Aug 20, 2010 at 6:06 PM, Jim Morris wrote: >  If there is an index on (name, position) the a where like below might > use it. > > A1.name=A2.name and A2.posi

Re: [sqlite] What is the most efficient way to get the close by numbers?

2010-08-20 Thread Eric Smith
Peng Yu wrote: > I have the following code to search for neighboring positions > (distance <=10). But it is slow for large data set. I'm wondering what > is the most efficient query for such a search. Note that I don't > create an index, as I'm not sure what index to create on table A. I haven't

Re: [sqlite] What is the most efficient way to get the close by numbers?

2010-08-20 Thread Simon Slavin
On 20 Aug 2010, at 11:54pm, Peng Yu wrote: > select * from A as A1, A as A2 where A1.name=A2.name and > abs(A1.position - A2.position) <= 10 and A1.position != A2.position; If you're doing this a lot, work out which chunks of 20 each point is in. You only need to compare a point with points in

Re: [sqlite] What is the most efficient way to get the close by numbers?

2010-08-20 Thread Jim Morris
If there is an index on (name, position) the a where like below might use it. A1.name=A2.name and A2.position between( A1.position - 10, A1.position + 10 ) On 8/20/2010 3:54 PM, Peng Yu wrote: > Hi, > > I have the following code to search for neighboring positions > (distance<=10). But it is

[sqlite] What is the most efficient way to get the close by numbers?

2010-08-20 Thread Peng Yu
Hi, I have the following code to search for neighboring positions (distance <=10). But it is slow for large data set. I'm wondering what is the most efficient query for such a search. Note that I don't create an index, as I'm not sure what index to create on table A. $ cat main.sql #!/usr/bin/env