Questions regarding Spatial Data performance

  • Hi

    I been concerned that there has to be a better way of getting the results that you want. You may want to try out the following, it performs extremely well compared to the geometry option.

    with ctetally as (

    SELECT ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) N

    FROM (VALUES (0),(0),(0),(0),(0),(0),(0),(0),(0),(0)) e1 (N), --10

    (VALUES (0),(0),(0),(0),(0),(0),(0),(0),(0),(0)) e2 (N), --100

    (VALUES (0),(0),(0),(0),(0),(0),(0),(0),(0),(0)) e3 (N), --1000

    (VALUES (0),(0),(0),(0),(0),(0),(0),(0),(0),(0)) e4 (N), --10000

    (VALUES (0),(0),(0),(0),(0),(0),(0),(0),(0),(0)) e5 (N) --100000

    ),

    expandGeo as (

    select ipstartint + N ipint, g.id

    from #geo2ip g

    cross apply (SELECT TOP ((ipendint - ipstartint) + 1) N - 1 N FROM ctetally) c

    )

    select f.id,

    g.id,

    ip_converted

    from #fact_table f

    left outer join expandGeo g on f.ip_converted = g.ipint;

Viewing post 16 (of 15 total)

You must be logged in to reply to this topic. Login to reply