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

Sergio Gollino gollinosergio at gmail.com
Tue May 20 03:27:31 PDT 2014


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

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

OR

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?

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.

Regards

Sergio


2014-05-20 10:54 GMT+02:00 Florian Lohoff <f at zz.de>:

>
> Hi,
> i am having issues with QGis checking for uniqueness of the primary key
> on startup. The key is unique but this takes >5 Minutes.
>
> From the postgres log:
>
> 2014-05-19 17:58:19 UTC LOG:  duration: 512282.227 ms  statement: SELECT
>         count(distinct "id")=count("id") FROM "public"."v_kvztallength_pos"
>
> v_kvztallength_pos is a view joining 2 tables which share a primary key
> (via
> foreign key) so the view can not create any non uniqueness on id because it
> joins on id. From my understanding the uniqueness of the primary key is
> needed
> for editing. Can i put this layer/table to read-only and let qgis ignore
> the
> primary key?
>
> Or can i tell qgis that "the key is unique, trust me"?
>
> Currently i am fighting against QGis startup times >20 Minutes.
>
> Flo
> PS: QGis 2.0.1, Postgres 9.1, Postgis 2.0.3
> --
> Florian Lohoff                                                 f at zz.de
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (GNU/Linux)
>
> iQIVAwUBU3sYPJDdQSDLCfIvAQhBlg//YK9jc93FAkyuQkHTfWgnVjh0v9n0vrA1
> K6bz08Zrm6gq6YbgjZRwe9kCgmceuwng4Vv+VjDDOth8coQAglFkHxtEAvJjP4Cp
> 3zPSfkNBxp+XYGSmFETz9mfD+5Sbc/LPE63DQMAx/MO0UZAnt/AF47zepDa9e4LH
> Tbo4wR6e3zNM/0u2jbbTPkTcyAH7M3C0GGP/sp2Y2BGMXvQngalaC92nPfhGQ7fC
> qxf9kPHVV25X9eoyXBphvzkqFksSnGKXRgvEOq9Q97Yk/II5hcE4YTagL+qAHaCd
> ML7LWq5HHZV9hh1+hzWY2KIWxyYHAVeBVRSiV/Yc7REpvg+HeSuWdKer/RscS43L
> 77oOjPAmEQY5npAWYIO4v9o8Xf1Web/oFw7X0msJzGP94ZkIp+tKxGlzcJMiru6p
> oRF0FnH7jSqFZKQ9ESRQF3fczwZue0QLRDRnOySrv+szpNHYo3c10h5FPXele43O
> I4M8qb+fuvefzeKJ6lkrjaCD0O8W7gXTm2Lv/GnJ60hmNI5oU+xdv+SZYoEFvwFV
> Uq6dfQZj7JljiYxkheqiBB4NxegjlXDpbee6TqhDjCkvMQq+CEJ8evi2m8zynfmy
> SzHGxEXpkGl35PkxeA6kc9Xhqh8GSZtnB1CE3f0KwlAc3/lChYoT8diTvVVjADWX
> hRyG3yFamek=
> =tkIR
> -----END PGP SIGNATURE-----
>
> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-user
>



-- 
Sergio Gollino
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20140520/afb29821/attachment.html>


More information about the Qgis-user mailing list