[Qgis-user] QGis checks uniqueness of primary key on startup

Florian Lohoff f at zz.de
Tue May 20 03:44:41 PDT 2014


On Tue, May 20, 2014 at 12:27:31PM +0200, Sergio Gollino wrote:
> Hi Florian,
> if you just need a primary key on your view you can add this on your view:
> 
> CREATE OR REPLACE VIEW v_kvztallength_pos AS
>  SELECT
> row_number() OVER (ORDER BY tablename.id) AS gid,
> ecc...
> ecc.. .
> FROM tablename

I'll try that - my first guess is thats it not faster ;)

> This create a column with a unique value (gid) that Qgis will recognize.

> you can choose the unique key in the table tree when you add your view in
> qgis. see -->http://i.stack.imgur.com/Da0xP.png
> 
> but I'm not sure that your problem is here, how many rows have your view?

About 20 Million IIRC - And i have told qgis what the unique key is.
My datasource has:

[...] key='id' srid=4326 type=POINT table="public"."v_kvztallength_pos" (position) sql=

> If I have understand it right, you want to edit your view, but you can't
> (in an easy way) edit a view even if you have a primary key. Its better for
> you to create a table and use spatial indices.

I dont need to edit the view i just want to display it.

Its basically a join over an address (with geocoded position) with metadata 
in a different table. The metadata references the address with a foreign key.

Flo
-- 
Florian Lohoff                                                 f at zz.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 828 bytes
Desc: Digital signature
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20140520/e4e06769/attachment.sig>


More information about the Qgis-user mailing list