> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wherobots.com/llms.txt
> Use this file to discover all available pages before exploring further.

# ST_Contains

Return true if A fully contains B. Polymorphic over input type:

* `(Geometry, Geometry)` — topological containment via JTS.
* `(Geography, Geography)` — topological containment via S2.
* `(Box2D, Box2D)` — closed-interval bbox containment on both axes (PostGIS `~` on `box2d`). Throws `IllegalArgumentException` on inverted bounds. See [Box2D optimization](#box2d-optimization) below.
* `(Box3D, Box3D)` — closed-interval bbox containment on all three axes. Throws on inverted bounds on any axis.

<img src="https://mintcdn.com/wherobots/fqh3gPDE0J25Lra_/images/sql-functions/ST_Contains/ST_Contains_true.svg?fit=max&auto=format&n=fqh3gPDE0J25Lra_&q=85&s=6123733a4210cdbace093aadd78757d4" alt="ST_Contains returning true" width="400" height="300" data-path="images/sql-functions/ST_Contains/ST_Contains_true.svg" />

<img src="https://mintcdn.com/wherobots/fqh3gPDE0J25Lra_/images/sql-functions/ST_Contains/ST_Contains_false.svg?fit=max&auto=format&n=fqh3gPDE0J25Lra_&q=85&s=e93c638c0728b1f97e84be5cd2177a65" alt="ST_Contains returning false" width="400" height="300" data-path="images/sql-functions/ST_Contains/ST_Contains_false.svg" />

## Signatures

```sql theme={"system"}
ST_Contains (A: Geometry, B: Geometry)
```

```sql theme={"system"}
ST_Contains (A: Geography, B: Geography)
```

```sql theme={"system"}
ST_Contains (A: Box2D, B: Box2D)
```

```sql theme={"system"}
ST_Contains (A: Box3D, B: Box3D)
```

## Parameters

<ParamField body="A" type="Geometry | Geography | Box2D | Box3D" required>
  The containing input. `Box2D` / `Box3D` inputs use closed-interval semantics.
</ParamField>

<ParamField body="B" type="Geometry | Geography | Box2D | Box3D" required>
  The contained input, of the same type family as `A`.
</ParamField>

## Return type

<ResponseField type="Boolean">
  `true` if A fully contains B.
</ResponseField>

## Example

```sql theme={"system"}
SELECT ST_Contains(ST_GeomFromWKT('POLYGON((175 150,20 40,50 60,125 100,175 150))'), ST_GeomFromWKT('POINT(174 149)'))
```

```
false
```

Box2D example:

```sql theme={"system"}
SELECT ST_Contains(
    ST_MakeBox2D(ST_Point(0.0, 0.0), ST_Point(10.0, 10.0)),
    ST_MakeBox2D(ST_Point(2.0, 2.0), ST_Point(5.0, 5.0)))
```

```
true
```

For `Box3D` inputs containment must hold on all three axes — a box contained within another's XY footprint but extending past it in Z is **not** contained:

<img src="https://mintcdn.com/wherobots/XpQVzmvmMISOboEb/images/sql-functions/box3d/st_contains_box3d_true.svg?fit=max&auto=format&n=XpQVzmvmMISOboEb&q=85&s=347cb28e161663123f718227cc20428b" alt="Box3D ST_Contains returning true: B lies fully inside A" width="340" height="285" data-path="images/sql-functions/box3d/st_contains_box3d_true.svg" />

<img src="https://mintcdn.com/wherobots/XpQVzmvmMISOboEb/images/sql-functions/box3d/st_contains_box3d_false.svg?fit=max&auto=format&n=XpQVzmvmMISOboEb&q=85&s=1403cfc8d04abd720b3691fa645fe9ba" alt="Box3D ST_Contains returning false: B is inside in XY but extends past A in Z" width="340" height="285" data-path="images/sql-functions/box3d/st_contains_box3d_false.svg" />

## Box2D optimization

`ST_Contains(box_col, lit_box)` over a `Box2D` column and a literal `Box2D` (and the reversed form) is recognized by Sedona's spatial optimizer:

* **Filter pushdown.** When the column is a `Box2D` stored in GeoParquet, the predicate translates to Parquet row-group inequalities on the `xmin` / `ymin` / `xmax` / `ymax` leaves. See [Box2D filter pushdown](/reference/wherobots-db/geometry-data/optimizer#box2d-filter-pushdown).
* **Spatial join.** `ST_Contains(a, b)` between two `Box2D` columns is planned as a range or broadcast-index join with `COVERS` semantics (closed-interval containment). See [Box2D spatial join](/reference/wherobots-db/geometry-data/optimizer#box2d-spatial-join).
