|
Boost : |
From: Arkadiy Vertleyb (vertleyb_at_[hidden])
Date: 2005-10-20 17:26:44
"Calum Grant" <calum_at_[hidden]> wrote
> I frankly have no idea how I would implement that problem in SQL, but
> then this was a problem you chose to be very difficult to solve using a
> SQL notation.
I am not an SQL expert, but should be something like this (if I remember
correctly):
SELECT number, name, city, COUNT(*) AS cnt
FROM mytable a, mytable b
WHERE [the long condition based on coordinates]
GROUP BY a.number
ORDER BY cnt DESC;
Then you hope that the optimizer figures out how to not compare every
possible pair ;-)
This exact statement I modeled in RTL, but RTL also specifies HOW to do
things in addition to WHAT to do, so I was able to do a smartrer
(range-based) query.
I am thrilled with your performance results, though (although I consider
them the results of a by-hand solution). Did you completely avoid
calculating the distance? If so, I think any such solution would provide
only approximate result (although it might happen to be a pretty good
approximation).
Regards,
Arkadiy
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk