I can observe a strange behavior with my PostGIS query. I am trying to accomplish the following:
- I have one polygon layer
- I have 2 different line layers
- layer with horizontal lines
- layer with 45° lines
- the goal is to cut the lines at the polygons to get the line parts of each line per polygon
Here is an example what that looks like:

I am using a query which looks like this:
CREATE TABLE split AS
( SELECT row_number() over() AS id,
a.id AS old_id,
st_intersection(a.geom, b.geom) AS geom
FROM lines a,
polygons b
WHERE st_intersects(a.geom, b.geom) ) ;
The query takes ~3 minutes for horizontal and vertical lines but 5+ hours (cancelled there) for 45° lines.
Can anyone think of a possible cause? All layers have spatial indices, pk and so on. I am using a Postgres 9.5 with PostGIS 2.2.
I am really clueless about that behavior.
