{"action":"created","issue":{"url":"https://api.github.com/repos/Oslandia/qgis-versioning/issues/32","labels_url":"https://api.github.com/repos/Oslandia/qgis-versioning/issues/32/labels{/name}","comments_url":"https://api.github.com/repos/Oslandia/qgis-versioning/issues/32/comments","events_url":"https://api.github.com/repos/Oslandia/qgis-versioning/issues/32/events","html_url":"https://github.com/Oslandia/qgis-versioning/pull/32","id":120880409,"number":32,"title":"More efficient QgsFeature selection","user":{"login":"ymoisan","id":7468595,"avatar_url":"https://avatars.githubusercontent.com/u/7468595?v=3","gravatar_id":"","url":"https://api.github.com/users/ymoisan","html_url":"https://github.com/ymoisan","followers_url":"https://api.github.com/users/ymoisan/followers","following_url":"https://api.github.com/users/ymoisan/following{/other_user}","gists_url":"https://api.github.com/users/ymoisan/gists{/gist_id}","starred_url":"https://api.github.com/users/ymoisan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ymoisan/subscriptions","organizations_url":"https://api.github.com/users/ymoisan/orgs","repos_url":"https://api.github.com/users/ymoisan/repos","events_url":"https://api.github.com/users/ymoisan/events{/privacy}","received_events_url":"https://api.github.com/users/ymoisan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-12-07T22:13:25Z","updated_at":"2015-12-10T13:24:04Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/Oslandia/qgis-versioning/pulls/32","html_url":"https://github.com/Oslandia/qgis-versioning/pull/32","diff_url":"https://github.com/Oslandia/qgis-versioning/pull/32.diff","patch_url":"https://github.com/Oslandia/qgis-versioning/pull/32.patch"},"body":"This PR is really a discussion type PR.  \r\n\r\nIn relation to GISeHealth#26, where tests suggest layer.selectedFeatures() may be a little heavy memorywise, this PR is about constructing a list of QgsFeature objects as small as possible.  In the current version, we get full features (with all attributes and geometry) through the call to selectedFeatures().  I don't know how much memory a QgsFeature object takes, but the current behaviour is bound to bite us when the number of features selected is large, especially when features have many attributes.\r\n\r\nWhat we are proposing here (and asking your advice on) is to filter feature objects so as to only get the PK field and no other attribute (and no geometry).  We're not quite satisfied with our proposed implementation because : \r\n\r\n- we need to use versioning_base.pg_pk to find out what the referring table's PK field is\r\n- we still have a list of QgsFeature objects\r\n\r\nIn an ideal world, we would instead use selectedFeaturesIds() because it just returns a list of ids that could then be passed on to versioning_base.checkout.  This approach is an order of magnitude faster than making up a list of feature objects (verified empirically).  Unfortunately, the keyColumn() function of a QgsDataSourceURI does NOT return the PK of the table versioned through the view object the QgsDataSourceURI points to.  If we could make it such that keyColumn() returns the actual PK of the related versioned table, we would gain a lot in terms of performance.\r\n\r\nSuggestions welcome.\r\n\r\nP.S. I also sneaked in a way to get rid of full paths for sqlite files.  That's my (and  our users') preference of course but I noticed in case of very long paths some menu icons get kicked out of sight.  You can still get them by clicking on the >> symbol, but that's not handy.  Same applies for a PG object (when database + schema + name = long) as shown in GISeHealth#1 but we're not proposing anything for that yet.  Some fixed width object would be preferable, but we don't know what yet."},"comment":{"url":"https://api.github.com/repos/Oslandia/qgis-versioning/issues/comments/163613507","html_url":"https://github.com/Oslandia/qgis-versioning/pull/32#issuecomment-163613507","issue_url":"https://api.github.com/repos/Oslandia/qgis-versioning/issues/32","id":163613507,"user":{"login":"ymoisan","id":7468595,"avatar_url":"https://avatars.githubusercontent.com/u/7468595?v=3","gravatar_id":"","url":"https://api.github.com/users/ymoisan","html_url":"https://github.com/ymoisan","followers_url":"https://api.github.com/users/ymoisan/followers","following_url":"https://api.github.com/users/ymoisan/following{/other_user}","gists_url":"https://api.github.com/users/ymoisan/gists{/gist_id}","starred_url":"https://api.github.com/users/ymoisan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ymoisan/subscriptions","organizations_url":"https://api.github.com/users/ymoisan/orgs","repos_url":"https://api.github.com/users/ymoisan/repos","events_url":"https://api.github.com/users/ymoisan/events{/privacy}","received_events_url":"https://api.github.com/users/ymoisan/received_events","type":"User","site_admin":false},"created_at":"2015-12-10T13:24:04Z","updated_at":"2015-12-10T13:24:04Z","body":"@vmora: thanx; that's what's shown [here](http://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/loadlayer.html)."}}