Postgres OIDs and box2d, box2df, box3d, and gidx: differences and usage?

Paul Ramsey pramsey at cleverelephant.ca
Fri Jun 7 11:34:56 PDT 2024


Hi Tom,

On Fri, Jun 7, 2024 at 1:49 AM Tom Payne <twpayne at gmail.com> wrote:
> Right now PostGIS registers six types:
>   https://github.com/postgis/postgis/blob/2773d7419c4ada598847e1b5ac9b292cbd409846/libpgcommon/lwgeom_pg.c#L192-L197
>
> PostGIS registers box2df, but there's also box2d:
>
> obstacledb=# SELECT typname, oid FROM pg_type WHERE typname IN ('box2d', 'box2df', 'box3d', 'gidx');
>  typname |   oid
> ---------+---------
>  box3d   | 5248539
>  box2d   | 5248543
>  box2df  | 5248547
>  gidx    | 5248551
> (4 rows)
>
> I have the following specific questions:
>
> - If PostGIS registers box2df, where does box2d come from?

PostGIS also registers box2d (see postgis.sql.in)

> - If I understand correctly, box2df should be a box2d with single-precision floats rather than double-precision floats. Is this correct?

Yes, that's what it is.

> - Are box2df's ever sent over the wire? What would be a query that returns a box2df as opposed to a box2d?

No, they are entirely internal to PostGIS, used as index keys in the
2d GIST index. You'll note the in/out functions for them are no-op
errors. It is not possible to create them from SQL.

> - If I understand correctly, the text serialization format for box2d is a string "BOX(minX minY,maxX maxY)", and there is no serialization for box2df. Is this correct?

Correct.

> - If I understand correctly, there is no binary serialization format for box2d or box2df. Is this correct?

Correct, the send/recv slots are empty in the type definition.

CREATE TYPE box2d (
    internallength = 65,
    input = box2d_in,
    output = box2d_out,
    storage = plain
);


> - If I understand correctly, gidx is a box3d with single-precision floats, and, like box2df, is never sent over the wire. Is this correct?

Correct, gidx serves the same purpose as box2df, for the case of
indexes with flexible dimensionality, and cannot be created via SQL
nor created by an end user.

> Many thanks for any clarification here,

Thanks for your work!

P

>
>
>


More information about the postgis-devel mailing list