Skip to content

How to order by distance? #778

Closed
Closed
@nlassaux

Description

@nlassaux

I'm using distance operators in the ORDER BY, because those use geographic indexes better than their function equivalents:

SELECT
    id
FROM
    house h
ORDER BY
    ST_SetSRID(ST_MakePoint(%s, %s), 4326) <-> h.point

Unfortunately, I don't seem to find a correct way to define that custom distance. It looks like defining a custom function assumes a prefix expression notation function_name(param1, param2), when I'd like a postfix version.

Has anyone covered a similar case? Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions