Skip to main content
Bumped by Community user
Bumped by Community user
Tweeted twitter.com/StackGIS/status/1309372071772860418
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
added 1 character in body
Source Link
DIV
  • 886
  • 1
  • 6
  • 18

So, I've a table in postgresql, that is joined to other spatial table.

If I've run a simple query in pgAdmin, let's say SELECT * FROM table1 WHERE "area" > '5000' and it takes less, than 1s to output a result.


Completely diffrentdifferent story is in QGIS.

I'm developing plugin, that needs to fetch some data by query. The code is simple, more less like this:

table1 = iface.activeLayer()

attribute = 'area'
size = 5000

q = "\"{}\" > '{}'".format(attribute, size)

expr = QgsExpression(q)
result = table1.getFeatures(QgsFeatureRequest(expr))
ids = [i.id() for i in result]

and it works just fine, but performance is the issue. It takes about 15-20s to run the same query, where in pgAdmin took less than 1s.

How is that possible? Is that normal, that QGIS is that slow?

At first, I thought about that join is making QGIS so slow, but I can't figure out, why it's not affecting pgAdmin, if that is the case?

My spec:
QGIS 3.4.8
PostgreSQL 10.7
PostGIS 2.5.2
pgAdmin 4

EDIT: Removed 'AND' typo as @Joseph mentioned.

So, I've a table in postgresql, that is joined to other spatial table.

If I've run a simple query in pgAdmin, let's say SELECT * FROM table1 WHERE "area" > '5000' and it takes less, than 1s to output a result.


Completely diffrent story is in QGIS.

I'm developing plugin, that needs to fetch some data by query. The code is simple, more less like this:

table1 = iface.activeLayer()

attribute = 'area'
size = 5000

q = "\"{}\" > '{}'".format(attribute, size)

expr = QgsExpression(q)
result = table1.getFeatures(QgsFeatureRequest(expr))
ids = [i.id() for i in result]

and it works just fine, but performance is the issue. It takes about 15-20s to run the same query, where in pgAdmin took less than 1s.

How is that possible? Is that normal, that QGIS is that slow?

At first, I thought about that join is making QGIS so slow, but I can't figure out, why it's not affecting pgAdmin, if that is the case?

My spec:
QGIS 3.4.8
PostgreSQL 10.7
PostGIS 2.5.2
pgAdmin 4

EDIT: Removed 'AND' typo as @Joseph mentioned.

So, I've a table in postgresql, that is joined to other spatial table.

If I've run a simple query in pgAdmin, let's say SELECT * FROM table1 WHERE "area" > '5000' and it takes less, than 1s to output a result.


Completely different story is in QGIS.

I'm developing plugin, that needs to fetch some data by query. The code is simple, more less like this:

table1 = iface.activeLayer()

attribute = 'area'
size = 5000

q = "\"{}\" > '{}'".format(attribute, size)

expr = QgsExpression(q)
result = table1.getFeatures(QgsFeatureRequest(expr))
ids = [i.id() for i in result]

and it works just fine, but performance is the issue. It takes about 15-20s to run the same query, where in pgAdmin took less than 1s.

How is that possible? Is that normal, that QGIS is that slow?

At first, I thought about that join is making QGIS so slow, but I can't figure out, why it's not affecting pgAdmin, if that is the case?

My spec:
QGIS 3.4.8
PostgreSQL 10.7
PostGIS 2.5.2
pgAdmin 4

EDIT: Removed 'AND' typo as @Joseph mentioned.

added 50 characters in body
Source Link
DIV
  • 886
  • 1
  • 6
  • 18

So, I've a table in postgresql, that is joined to other spatial table.

If I've run a simple query in pgAdmin, let's say SELECT * FROM table1 WHERE "area" > '5000' and it takes less, than 1s to output a result.


Completely diffrent story is in QGIS.

I'm developing plugin, that needs to fetch some data by query. The code is simple, more less like this:

table1 = iface.activeLayer()

attribute = 'area'
size = 5000

q = "\"{}\" > '{}' AND "'".format(attribute, size)

expr = QgsExpression(q)
result = table1.getFeatures(QgsFeatureRequest(expr))
ids = [i.id() for i in result]

and it works just fine, but performance is the issue. It takes about 15-20s to run the same query, where in pgAdmin took less than 1s.

How is that possible? Is that normal, that QGIS is that slow?

At first, I thought about that join is making QGIS so slow, but I can't figure out, why it's not affecting pgAdmin, if that is the case?

My spec:
QGIS 3.4.8
PostgreSQL 10.7
PostGIS 2.5.2
pgAdmin 4

EDIT: Removed 'AND' typo as @Joseph mentioned.

So, I've a table in postgresql, that is joined to other spatial table.

If I've run a simple query in pgAdmin, let's say SELECT * FROM table1 WHERE "area" > '5000' and it takes less, than 1s to output a result.


Completely diffrent story is in QGIS.

I'm developing plugin, that needs to fetch some data by query. The code is simple, more less like this:

table1 = iface.activeLayer()

attribute = 'area'
size = 5000

q = "\"{}\" > '{}' AND ".format(attribute, size)

expr = QgsExpression(q)
result = table1.getFeatures(QgsFeatureRequest(expr))
ids = [i.id() for i in result]

and it works just fine, but performance is the issue. It takes about 15-20s to run the same query, where in pgAdmin took less than 1s.

How is that possible? Is that normal, that QGIS is that slow?

At first, I thought about that join is making QGIS so slow, but I can't figure out, why it's not affecting pgAdmin, if that is the case?

My spec:
QGIS 3.4.8
PostgreSQL 10.7
PostGIS 2.5.2
pgAdmin 4

So, I've a table in postgresql, that is joined to other spatial table.

If I've run a simple query in pgAdmin, let's say SELECT * FROM table1 WHERE "area" > '5000' and it takes less, than 1s to output a result.


Completely diffrent story is in QGIS.

I'm developing plugin, that needs to fetch some data by query. The code is simple, more less like this:

table1 = iface.activeLayer()

attribute = 'area'
size = 5000

q = "\"{}\" > '{}'".format(attribute, size)

expr = QgsExpression(q)
result = table1.getFeatures(QgsFeatureRequest(expr))
ids = [i.id() for i in result]

and it works just fine, but performance is the issue. It takes about 15-20s to run the same query, where in pgAdmin took less than 1s.

How is that possible? Is that normal, that QGIS is that slow?

At first, I thought about that join is making QGIS so slow, but I can't figure out, why it's not affecting pgAdmin, if that is the case?

My spec:
QGIS 3.4.8
PostgreSQL 10.7
PostGIS 2.5.2
pgAdmin 4

EDIT: Removed 'AND' typo as @Joseph mentioned.

naming
Source Link
Vince
  • 20.3k
  • 16
  • 48
  • 65

So, I've a table in postgresql, that is joined to other spatial table.

If I've run a simple query in pgAdmin, let's say SELECT * FROM table1 WHERE "area" > '5000' and it takes less, than 1s to output a result.


Completely diffrent story is in QGIS.

I'm developing plugin, that needs to fetch some data by query. The code is simple, more less like this:

table1 = iface.activeLayer()

attribute = 'area'
size = 5000

q = "\"{}\" > '{}' AND ".format(attribute, size)

expr = QgsExpression(q)
result = table1.getFeatures(QgsFeatureRequest(expr))
ids = [i.id() for i in result]

and it works just fine, but performance is the issue. It takes about 15-20s to run the same query, where in pgAdmin took less than 1s.

How is that possible? Is that normal, that QGIS is that slow?

At first, I thought about that join is making QGIS so slow, but I can't figure out, why it's not affecting pgAdmin, if that is the case?

My spec:
QGIS 3.4.8
PostgresqlPostgreSQL 10.7
PostGIS 2.5.2
pgAdmin 4

So, I've a table in postgresql, that is joined to other spatial table.

If I've run a simple query in pgAdmin, let's say SELECT * FROM table1 WHERE "area" > '5000' and it takes less, than 1s to output a result.


Completely diffrent story is in QGIS.

I'm developing plugin, that needs to fetch some data by query. The code is simple, more less like this:

table1 = iface.activeLayer()

attribute = 'area'
size = 5000

q = "\"{}\" > '{}' AND ".format(attribute, size)

expr = QgsExpression(q)
result = table1.getFeatures(QgsFeatureRequest(expr))
ids = [i.id() for i in result]

and it works just fine, but performance is the issue. It takes about 15-20s to run the same query, where in pgAdmin took less than 1s.

How is that possible? Is that normal, that QGIS is that slow?

At first, I thought about that join is making QGIS so slow, but I can't figure out, why it's not affecting pgAdmin, if that is the case?

My spec:
QGIS 3.4.8
Postgresql 10.7
PostGIS 2.5.2
pgAdmin 4

So, I've a table in postgresql, that is joined to other spatial table.

If I've run a simple query in pgAdmin, let's say SELECT * FROM table1 WHERE "area" > '5000' and it takes less, than 1s to output a result.


Completely diffrent story is in QGIS.

I'm developing plugin, that needs to fetch some data by query. The code is simple, more less like this:

table1 = iface.activeLayer()

attribute = 'area'
size = 5000

q = "\"{}\" > '{}' AND ".format(attribute, size)

expr = QgsExpression(q)
result = table1.getFeatures(QgsFeatureRequest(expr))
ids = [i.id() for i in result]

and it works just fine, but performance is the issue. It takes about 15-20s to run the same query, where in pgAdmin took less than 1s.

How is that possible? Is that normal, that QGIS is that slow?

At first, I thought about that join is making QGIS so slow, but I can't figure out, why it's not affecting pgAdmin, if that is the case?

My spec:
QGIS 3.4.8
PostgreSQL 10.7
PostGIS 2.5.2
pgAdmin 4

edited tags
Source Link
DIV
  • 886
  • 1
  • 6
  • 18
Loading
Source Link
DIV
  • 886
  • 1
  • 6
  • 18
Loading