New results with rewritten 5-step SQL. 712454 lines split with 2606 areas, ~1800 sec, adding 450533 lines Areas are very jagged, those 450533 added lines came from 83794 original lines that intersected an area. 5 steps 1. Find touching lines (only mfd_id) INSERT INTO [Touching_Ids] ( [mfd_id] ) SELECT [s_mfd_id] FROM CALL GeomOverlayTouchingPar( [Lines Drawing] ([mfd_id], [Geom]), [Area Drawing] ([mfd_id], [AreaGeom]), 0, ThreadConfig(SystemCpuCount())) WHERE [o_mfd_id] is not null group by [s_mfd_id] ; -- 83794 2. Copy Touching lines (all attributes). Also important to have drawing based on this table, because GeomOverlayTopologyIdentityPar in step 4. requires a Drawing. INSERT INTO [Touching_Lines] ([mfd_id], [Geom], <all other...>) SELECT [Lines].[mfd_id], [Geom], <all other...> FROM [Lines] JOIN [Touching_Ids] ON [Lines].[mfd_id] = [Touching_Ids].[mfd_id] ; -- 83794 3. Delete Touching lines from original. DELETE FROM [Lines] WHERE [mfd_id] in (SELECT [mfd_id] FROM [Touching_Ids]) ; -- 83794 4. Split lines (only mfd_ids and Geom) INSERT INTO [Lines Split] ( [s_mfd_id], [o_mfd_id], [Geom] ) SELECT [s_mfd_id], [o_mfd_id], [s_Geom] FROM CALL GeomOverlayTopologyIdentityPar( [Touching_Lines Drawing] ([mfd_id], [Geom]), [Area Drawing] ([mfd_id], [AreaGeom]), 0, ThreadConfig(SystemCpuCount())) ; -- 450533 -- 5. Insert split lines with original attributes copied. Add Boolean attribute [InsideArea] with obvious meaning. INSERT INTO [Lines] ( [Geom], [InsideArea], <all other...>) SELECT [Geom], , CASE WHEN [o_mfd_id] IS NULL THEN FALSE ELSE TRUE END as [InsideArea] , <all other...> FROM [Lines Split] ([Geom], [o_mfd_id], [s_mfd_id]) JOIN [Touching_Lines] ([mfd_id], <all other...>) ON [Lines Split].[s_mfd_id] = [Touching_Lines].[mfd_id] ; -- 450533 I had a small error at p5, and I didn't see the exact timing of previous steps in Log window. I think it was about 30min total. Very quick! I hope it is possible to make the first straightforward GeomOverlayTopologyIdentityPar version as quick.
|