Skip to main content

VECTOR_MANHATTAN_DISTANCE

Returns the Manhattan, or L1 distance, between two vectors. The Manhattan distance measures the total distance by moving strictly along orthogonal axes, similar to navigating streets in a city grid. It is calculated as the sum of absolute differences between corresponding elements of two vectors. Alias: l1_distance (aligned with pgvector for compatibility)

Syntax

Parameters

Notes

Both input array arguments must have the same number of elements.

Return Type

DOUBLE

Examples

The following code returns the Manhattan distance between two vectors. The Manhattan distance is calculated as the sum of absolute differences: |3 - 1| + |2 - 4| = 4.

Rows: 1Execution time: 5.30ms