Spatial query on large table with multiple self joins performing slow

后端 未结 4 1663
刺人心
刺人心 2021-01-13 15:38

I am working on queries on a large table in Postgres 9.3.9. It is a spatial dataset and it is spatially indexed. Say, I have need to find 3 types of objects: A, B and C. The

4条回答
  •  误落风尘
    2021-01-13 16:01

    Does it make any difference if you use explicit joins?

    SELECT a.id as a_id, a.name as a_name, a.geog as a_geog,
           b.id as b_id, b.name as b_name, b.geog as b_geog,
           c.id as c_id, c.name as c_name, c.geog as c_geog
    FROM table1 a
    JOIN table1 b ON b.type = 'B' AND ST_DWithin(a.geog, b.geog, 100)
    JOIN table1 c ON c.type = 'C' AND ST_DWithin(a.geog, c.geog, 100)
    WHERE a.type = 'A';
    

提交回复
热议问题