Hi ,
I am running this query :
select
case when p2.age < 15 then '0-15'
when p2.age between 15 and 25 then '15-25'
when p2.age between 26 and 39 then '26-39'
when p2.age between 40 and 64 then '40-64'
when p2.age > 64 then 'over 64' end as Age_Range,
p2.gender,
count(*)
from places1 p1 join people2 p2 on 1=1
where
distance(p1.lan,p1.lat,p2.lan,p2.lat) < 100 and
country in ('Thailand','Vietnam','china','Malaysia')
group by 1,2;
The distance < 100 condition is actually a cross join and its taking me too long .
Any idea how can i do it more efficient ?
Thanks !
Or.
↧