How do i optimize point-to-circle matching?
===

I have a table that contains a bunch of Earth coordinates (latitude/longitude) and associated radii.  I also have a table containing a bunch of points that i want to match with those circles, and vice versa.  Both are dynamic; that is, a new circle or a new point can be added or deleted at any time.  When either is added, i want to be able to match the new circle or point with all applicable points or circles, respectively.

I currently have a PostgreSQL module containing a C function to find the distance between two points on earth given their coordinates, and it seems to "work".  The problem is scalability -- in order for it to do its thing, the function currently has to scan the whole table and do some trig calculations against each row.  (Both tables are indexed by lat/long, but the function can't use them -- it has to do its thing before we know whether the two things match.)  New info may be posted as often as several times a second, and checking every point every time is starting to become quite unwieldy.

I've looked at Postgres's geometric types, but they seem more suited to rectangular coordinates than points on a sphere.  Whether i use them or not, i still wouldn't be getting any help from the DBMS.   :P

How can i arrange/optimize/filter/precalculate this data to make the matching faster and lighten the load?  