我有一个查询,它创建了一个pgRouting
pgr_drivingDistance
函数的输入:
CREATE TEMP TABLE tmp_edge AS
SELECT
e."Id" as id,
e."Source" as source,
e."Target" as target,
e."Length" / (1000*LEAST("Speed", "SpeedMin")/60) as cost
FROM "Edge" e,
"SpeedLimit" sl
WHERE sl."VehicleKindId" = 1
AND e.the_geom &&
ST_MakeEnvelope(
x1-(1000*GREATEST("Speed", "SpeedMax")/60)*13,
y1-(1000*GREATEST("Speed", "SpeedMax")/60)*13,
x1+(1000*GREATEST("Speed", "SpeedMax")/60)*13,
y1+(1000*GREATEST("Speed", "SpeedMax")/60)*13, 3857)
AND sl."RoadCategoryId" = e."CategoryId";
在WHERE
子句中,我多次计算相同的东西以获得边界框坐标。
我试图将计算FROM
部分放入计算列并使用别名,但随后整个执行时间增加了两倍。
Edge
表很大(100 万),SpeedLimit
有几十条记录。
有什么方法可以增强这个查询吗?