Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/310.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用服务器端游标和psycopg2选择带有顺序的显式列时,Postgres查询暂停_Python_Postgresql_Psycopg2 - Fatal编程技术网

Python 使用服务器端游标和psycopg2选择带有顺序的显式列时,Postgres查询暂停

Python 使用服务器端游标和psycopg2选择带有顺序的显式列时,Postgres查询暂停,python,postgresql,psycopg2,Python,Postgresql,Psycopg2,我有一个简单的查询,它连接两个相当大的表,并使用服务器端游标迭代结果: select * from tableA a join tableB b on (a.fid = b.id) order by a.id; 这个查询很好,我可以使用fetchmany在块中迭代结果 但是,只要我将查询更改为 select a.id from tableA a join tableB b on (a.fid = b.id) order by a.id execute调用暂停,我无法迭代结果 两个表上的id列

我有一个简单的查询,它连接两个相当大的表,并使用服务器端游标迭代结果:

select * from tableA a join tableB b on (a.fid = b.id) order by a.id;
这个查询很好,我可以使用fetchmany在块中迭代结果

但是,只要我将查询更改为

select a.id from tableA a join tableB b on (a.fid = b.id) order by a.id
execute调用暂停,我无法迭代结果

两个表上的id列都是通过BTREE索引进行索引的,fid列也是通过BTREE索引的,并且是tableB.id的约束。id和fid是整数


我需要迭代所有行的原因是因为我正在创建一个数据库导出,而这不能通过copy命令完成,因为它需要一个join。

有问题的回溯吗?您从调试错误日志中学到了什么?能否使用EXPLAIN Analysis向我们展示这两个查询计划?请将它们发布在表定义中,这也会有很大的帮助…,什么是a.fid,您有密钥吗?对于select*查询:对于select a.id查询:@Ali AkberSaifee:我没有看到任何计时,您使用过EXPLAIN或EXPLAIN ANALYSE吗?