【发布时间】:2011-03-30 08:15:14
【问题描述】:
考虑以下 Python 代码,使用 psycopg2 cursor 对象(为清楚起见,更改或省略了一些列名):
filename='data.csv'
file_columns=('id', 'node_id', 'segment_id', 'elevated',
'approximation', 'the_geom', 'azimuth')
self._cur.copy_from(file=open(filename),
table=self.new_table_name, columns=file_columns)
- 数据库位于快速 LAN 上的远程计算机上。
- 使用 bash 中的
\COPY运行速度非常快,即使对于大型(约 1,000,000 行)文件也是如此。
这段代码对于 5000 行来说是超快的,但是当 data.csv 超过 10000 行时,程序会完全冻结。
有什么想法\解决方案吗?
亚当
【问题讨论】:
标签: python postgresql large-data-volumes psycopg2