Continuing on clustering queries

Erik Wienhold ewie at ewie.name
Thu Mar 28 15:32:46 PDT 2024


On 2024-03-28 23:05 +0100, karsten wrote:
> - In DB manager e.g. when you run a query make sure you have a unique ID and
> the correct geometry column / return value selected
> If you do not have a unique id or are unsure use the row_number to cerate
> your own on the fly
> E.g. select *, ROW_NUMBER() OVER() as gid from thetable

But beware of the performance issues when using row_number() as a poor
man's primary key:
https://www.mail-archive.com/qgis-user@lists.osgeo.org/msg30713.html

I had to fight that at work and solved it by returning an array column
instead to preserve the primary key columns of the base tables (also
depending on join conditions and GROUP BY).

-- 
Erik


More information about the postgis-users mailing list