Geopandas to_postgis Taking Hours

Viewed 241

I'm currently trying to write a geopandas dataframe to a postgres database. The dataframe has a little over 11 million rows of just geometry like so:

       loc_id        geometry
0        1      POLYGON ((4 12, 8 25, ...
1        2      POLYGON ((5 42, 6 63, ...
2        3      POLYGON ((1 16, 2 73, ...
3        4      POLYGON ((2 26, 9 25, ...
4        5      POLYGON ((6 37, 3 34, ...

I'm then trying to write that geopandas dataframe to my postgres database like so:

df.postgis.to_postgis(con=eng, table_name='tb_nm', geometry='Polygon', if_exists='append', chunksize=20000)

But it has been running for about 2 hours now. Is there anyway to speed up this process?

Thank you

0 Answers
Related