Skip to main content
edited title
Link
underdark
  • 84.5k
  • 22
  • 233
  • 415

Problem with performance when loading PostGIS layer in QGISusing pyQGIS

ImI'm having a question on loading a PostGIS layer into the project from my QGIS plugin. The code is like this:

uri1 = qgis.core.QgsDataSourceURI()

uri1.setConnection(str(host), str(port), str(database), str(user), str(password) )

uri1.setDataSource(str(schema), "layer", "geom")

qgis.utils.iface.addVectorLayer(uri1.uri(),"layer", "postgres")

uri1 = qgis.core.QgsDataSourceURI() 
uri1.setConnection(str(host), str(port), str(database), str(user), str(password) )
uri1.setDataSource(str(schema), "layer", "geom")
qgis.utils.iface.addVectorLayer(uri1.uri(),"layer", "postgres")

itIt actually works fine but the performance is causing me lots of troubles. It takes up to 10 minutes, since there isare about a 100.,000.,000 entries in the table.

When iI load the layer manually using the PostGIS button on QGIS, there is a checkbox in the settings which says: "Geschätzte Tabellenmetadaten nutzen". In english this would be: "use"Use estimated table metadata". When checked, the layer loads in realtime.

My question is: Is there a way to load a PostGIS layer into QGIS using the estimated table metadata, and thus increase performance significantly?

Im having a question on loading a PostGIS layer into the project from my QGIS plugin. The code is like this:

uri1 = qgis.core.QgsDataSourceURI()

uri1.setConnection(str(host), str(port), str(database), str(user), str(password) )

uri1.setDataSource(str(schema), "layer", "geom")

qgis.utils.iface.addVectorLayer(uri1.uri(),"layer", "postgres")

it actually works fine but the performance is causing me lots of troubles. It takes up to 10 minutes, since there is about a 100.000.000 entries in the table.

When i load the layer manually using the PostGIS button on QGIS there is checkbox in the settings which says: "Geschätzte Tabellenmetadaten nutzen". In english this would be: "use estimated table metadata". When checked, the layer loads in realtime.

My question is: Is there a way to load a PostGIS layer into QGIS using the estimated table metadata, and thus increase performance significantly?

I'm having a question on loading a PostGIS layer into the project from my QGIS plugin. The code is like this:

uri1 = qgis.core.QgsDataSourceURI() 
uri1.setConnection(str(host), str(port), str(database), str(user), str(password) )
uri1.setDataSource(str(schema), "layer", "geom")
qgis.utils.iface.addVectorLayer(uri1.uri(),"layer", "postgres")

It actually works fine but the performance is causing me lots of troubles. It takes up to 10 minutes, since there are about a 100,000,000 entries in the table.

When I load the layer manually using the PostGIS button on QGIS, there is a checkbox in the settings which says: "Geschätzte Tabellenmetadaten nutzen". In english this would be: "Use estimated table metadata". When checked, the layer loads in realtime.

My question is: Is there a way to load a PostGIS layer into QGIS using the estimated table metadata, and thus increase performance significantly?

Removed signature as per help instructions
Source Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

Im having a question on loading a PostGIS layer into the project from my QGIS plugin. The code is like this:

uri1 = qgis.core.QgsDataSourceURI()

uri1.setConnection(str(host), str(port), str(database), str(user), str(password) )

uri1.setDataSource(str(schema), "layer", "geom")

qgis.utils.iface.addVectorLayer(uri1.uri(),"layer", "postgres")

it actually works fine but the performance is causing me lots of troubles. It takes up to 10 minutes, since there is about a 100.000.000 entries in the table.

When i load the layer manually using the PostGIS button on QGIS there is checkbox in the settings which says: "Geschätzte Tabellenmetadaten nutzen". In english this would be: "use estimated table metadata". When checked, the layer loads in realtime.

My question is: Is there a way to load a PostGIS layer into QGIS using the estimated table metadata, and thus increase performance significantly?

Thanks in advance!

Marius

Im having a question on loading a PostGIS layer into the project from my QGIS plugin. The code is like this:

uri1 = qgis.core.QgsDataSourceURI()

uri1.setConnection(str(host), str(port), str(database), str(user), str(password) )

uri1.setDataSource(str(schema), "layer", "geom")

qgis.utils.iface.addVectorLayer(uri1.uri(),"layer", "postgres")

it actually works fine but the performance is causing me lots of troubles. It takes up to 10 minutes, since there is about a 100.000.000 entries in the table.

When i load the layer manually using the PostGIS button on QGIS there is checkbox in the settings which says: "Geschätzte Tabellenmetadaten nutzen". In english this would be: "use estimated table metadata". When checked, the layer loads in realtime.

My question is: Is there a way to load a PostGIS layer into QGIS using the estimated table metadata, and thus increase performance significantly?

Thanks in advance!

Marius

Im having a question on loading a PostGIS layer into the project from my QGIS plugin. The code is like this:

uri1 = qgis.core.QgsDataSourceURI()

uri1.setConnection(str(host), str(port), str(database), str(user), str(password) )

uri1.setDataSource(str(schema), "layer", "geom")

qgis.utils.iface.addVectorLayer(uri1.uri(),"layer", "postgres")

it actually works fine but the performance is causing me lots of troubles. It takes up to 10 minutes, since there is about a 100.000.000 entries in the table.

When i load the layer manually using the PostGIS button on QGIS there is checkbox in the settings which says: "Geschätzte Tabellenmetadaten nutzen". In english this would be: "use estimated table metadata". When checked, the layer loads in realtime.

My question is: Is there a way to load a PostGIS layer into QGIS using the estimated table metadata, and thus increase performance significantly?

added 9 characters in body
Source Link
Loading
Source Link
Loading