A system attempts to transfer thousands of rows with two spatial columns (out of a 37million row source) into table X for interactive users to work with spatial data. The two columns are different projections of the same data.
We are seeing a huge time delay when inserting the records.
- A large insert is taking up to 5 minutes to complete
- A large insert is blocks other inserts. The system/db should support at least 40 concurrent inserts
- 90% of the explain plan cost are sort operations prior to the spatial index inserts.
Most of our spatial tuning experience has been with static prepared data. Without the spatial data and indexes, the insert works fine, but lets assume that isn't an option.
A. We are not sure what is being sorted prior to spatial index inserts. The explain plan says 9 million rows, but on our test, the table X only grew to 1.5 million.
- Does the sort basically rebuild the entire index when an insert contains > 2-5% of the table records?
- Is it just sorting the selected records to insert, which sometimes can be up to 100,000.
B. Is it possible to sort the source data to match the spatial index sequence? We have an identity column on the source as the clustered key. In other static spatial tables we have generated the clustered identity values based on geography data so index lookups are likely to be in memory. The explain plan uses "GetPlanarGeometryTesselation_VarBinary" in the sort. I haven't yet seen if I can get this tessalation number from TSQL to physically order the spatial data (and reset identity clustered key on our source)
I would really like to learn how we could align the clustered key to the spatial index. I am hoping we could then use the aligned identity column to avoid sort delays during inserts.
Any advice or suggestions? Thanks