Joel Reymont <joelr1(at)gmail(dot)com> wrote:
> I'm calculating distance between probability vectors, e.g. topics
> that a document belongs to and the topics of an ad.
>
> The distance function is already a C function. Topics are
> float8[150].
>
> Distance is calculated against all documents in the database
There's probably a way to index that so that you don't need to do a
full calculation against all documents in the database each time.
It may even be amenable to knnGiST indexing (a new feature coming in
9.1), which would let you do your select with an ORDER BY on the
distance.
PostgreSQL has a lot of very cool features you just don't have in
any other product! :-)
-Kevin