1

I have a large Postgres/PostGIS database table with ~100 million points that I need to have available for editing (mainly, removing points). Currently, I'm trying to use a QueryLayer in QGIS using this query:

SELECT x.id, x.geom, m.data_tag
FROM xyz_master as x INNER JOIN raw_tile_metadata as m on x.fid = m.id
WHERE x.fid in (
    select n.id from raw_tile_metadata as n
    where n.tile_path like '%50E40N_%'
)

Where xyz_master is my point data table and m.data_tag refers to a data attribute necessary for editing, which comes from a metadata table (hence, the join). The where clause is just selecting a confined area so we're not editing the entire data set at a given time.

When loaded into QGIS as a query layer, feature editing is disabled (the "toggle editing" button is disabled). I double checked user permissions and write permissions are granted. I even connected as the database superuser and still could not edit.

How can I enable editing on a QGIS query layer?

  • Update: This doesn't seem to have anything to do with my query. Any query layer added to QGIS is uneditable. I have worked around this issue by loading in the points/metadata tables as layers, then configuring a join through the layer properties. This wont work as a solution, however, because this involves loading in the entire data set, which makes QGIS operations prohibitively slow. – Todd Mar 8 at 19:34
  • 1
    Update: As another workaround, I created a subset view with a INSTEAD OF trigger function that passes on all edit queries to the source table. I think this may be a solution, but it seems like a lot of complicated DBA overhead just to edit a queried layer. Please, if anyone has a simpler solution, I'd love to hear about it. Thanks. – Todd Mar 8 at 22:59
  • Hello Todd, I think it won't be possible to edit a query layer, cause it could be anything output from several joins. And which table should be then edited? As you updated first, was to add all layers and then join the attributes. In this scenario you could avoid to load the complete xyz_master table to use the filter option for that layer. There you can add your where clause ("where x.fid in (...)) to get the desired subset of data. And then the layer should be editable. – Michael Mar 9 at 20:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.