笛卡尔积数据处理问题,求大神指导

表结构:tableName(cgi,lo,la,derection,city)
SQL:
SELECT
t1.cgi AS s_cgi,
t1.lo AS s_lo,
t1.derection AS s_derection,
t2.cgi AS t_cgi,
t2.lo AS t_lo,
t2.derection AS t_derection
FROM
tableName t1,
tableName t2
WHERE
t1.city = 'GZ'
AND t2.city = 'GZ'

我确实是需要这样的结果。这样的语句在数据很大的时候木有性能可言,原表8000条数据都要查好几个小时,请大神指导,整一个速度有很大提升法子,主要在数据端处理,PostgreSQL。求解决方案!!!!!!虽说没有什么分,但是还是想跟大学学习下多谢!

 先缩小结果集,在笛卡尔积
 select t1.cgi AS s_cgi,
t1.lo AS s_lo,
t1.derection AS s_derection,
t2.cgi AS t_cgi,
t2.lo AS t_lo,
t2.derection AS t_derection
from 
(select * from tableName where city = 'GZ') t1
, (select * from tableName where city = 'GZ') t2

各位大神,我想到一个方法,不知道是否可以提高性能,求指导,

先把 cgi 查出来:select DISTINCT cgi from tableName where city='GZ';

然后在 loop 循环把cgi写入一下SQL

select t1.cgi AS s_cgi,
t1.lo AS s_lo,
t1.derection AS s_derection,
t2.cgi AS t_cgi,
t2.lo AS t_lo,
t2.derection AS t_derection
from
(select * from tableName where city = 'GZ' and cgi='cgi') t1
, (select * from tableName where city = 'GZ') t2

一次遍历就处理一个cgi的数据,如果有8000个cgi是不是处理8000次就处理完了