Test custom relationships using the ST_Relate method

For best performance, you should always use methods like ST_Within, or ST_Touches to test single, specific relationships between geometries. However, if you have more than one relationship to test, ST_Relate can be a better method, since you can test for several relationships at once. ST_Relate is also good when you want to test for a different interpretation of a predicate such as within (ST_Within). For example, when testing if a point is within another geometry, ST_Within returns false if the point falls on the boundary of the other geometry. The interpretation of within you want to test for, however, may include having a point on a boundary. In this case, you perform a custom relationship test using ST_Relate to test for the condition.

The most common use of ST_Relate is as a predicate, where you specify the exact relationship(s) to test for. However, you can also use ST_Relate to determine all possible relationships between two geometries.

 Predicate use of ST_Relate
 Non-predicate use of ST_Relate
 See also