4

I am working on a project used for data capture on fields, through Qfield.

Today, with around 1100 entities, QGIS takes a lot of time to display the information, even if I use a single symbol.

Could you tell me what is slowing down QGIS ?

I have a few leads:

  • I'm using many relations (in this project, 7 for each of the 3 layers).
  • I'm referring to the relations to display labels (but disabling labels doesn't change anything)
  • I'm using a virtual field (I have read that these fields can slow down QGIS)
  • Is the CRS can have an impact ?
  • Should I create Spatial index ?

I'm only using Shapefile. I also deactivate the option "Show feature count" and I removed all the variables to control shapes and colors.

On stackexchange.com, I found several discussions with a similar subject like: Link1 Link2

I add a link to download a simplified project if you want to check. At least opening it and telling me if you have the same issue. Test_project

My computer is working under Windows 7, RAM: 16Go, CPU: Intel Core i7-7700HQ 2,80GHz.

EDIT:

I updated my project as advised. No more virtual field, which make the project faster. But now, without virtual field, I cannot get the information from relation layer(s).

I created a normal field for which I apply default value on update and I activated data dependencies on the relation layers. This field is only updated if I modify its layer.

Dependencies

EDIT 2: I uploaded a second test project with the modifications. Test project 2

4
  • 2
    I would start by converting the virtual field to a normal field
    – BERA
    Oct 5, 2022 at 16:57
  • Yes - Very slow for the amount of data. Windows 10 128GB i7
    – Cary H
    Oct 5, 2022 at 18:04
  • 1
    I exported the data as a geopackage without virtual fields and it runs very fast.
    – Cary H
    Oct 5, 2022 at 18:19
  • I converted the virtual field into a normal field, the symbols are displayed instantly, but I lost the function of the virtual field. I needed to update the field when the changes have been validated on the relation layer(s). Since I'm using a normal field, this is not working anymore (even if I apply default value on update & activate a data dependency.
    – Giene
    Oct 6, 2022 at 4:18

1 Answer 1

5

The reason your layer is slow is the virtual field. This is your expression, which is tied to the symbology of your layer. So every feature is running this every time the renderer is triggered.

CASE
    WHEN "COMPART" = 1 THEN 
        CASE 
            WHEN Attribute(Get_feature('[T]_DATA_Relation_Habitats','id',"id"),'Validite') = true THEN
                 represent_value("COMPART") || ' - '  || Attribute(Get_feature('[T]_DATA_Relation_Habitats','id',"id"),'Habitat')  ||  ' - '  || Replace("date",left("date",strpos("date",'-')+1),'')  ||  ' (V)'
            ELSE
                represent_value("COMPART") || ' - '  || Attribute(Get_feature('[T]_DATA_Relation_Habitats','id',"id"),'Habitat')  ||  ' - '  || Replace("date",left("date",strpos("date",'-')+1),'')  || ' (X)'
        END
    
    WHEN "COMPART" = 2 THEN  'Soil survey: ' || Attribute(Get_feature('[T]_DATA_Relation_Sondages','id',"id"),'id_sondage') || ' - '  || '[' || Attribute(Get_feature('[T]_DATA_Relation_Sondages','id',"id"),'Res_sond')  || ']' ||  ' - '  || Replace("date",left("date",strpos("date",'-')+1),'')

    WHEN "COMPART" >= 3 AND "COMPART" <= 9 THEN 
        CASE 
            WHEN Attribute(Get_feature('[T]_DATA_Relation_Species','id',"id"),'Validite') = true THEN
                represent_value("COMPART") || ' - '  || Attribute(Get_feature('[T]_DATA_Relation_Species','id',"id"),'Code_esp')   ||  ' - '  || Replace("date",left("date",strpos("date",'-')+1),'')  || ' (V)'
            ELSE
                represent_value("COMPART") || ' - '  || Attribute(Get_feature('[T]_DATA_Relation_Species','id',"id"),'Code_esp')   ||  ' - '  || Replace("date",left("date",strpos("date",'-')+1),'')  || ' (X)'
        END 
    WHEN "COMPART" = 10 THEN 
        CASE 
            WHEN Attribute(Get_feature('[T]_DATA_Relation_Wetlands','id',"id"),'Validite') = true THEN
                represent_value("COMPART") || ' - '  || Attribute(Get_feature('[T]_DATA_Relation_Wetlands','id',"id"),'Nom_ZH')   || ' - '  || Replace("date",left("date",strpos("date",'-')+1),'')  ||  ' (V)'
            ELSE
                represent_value("COMPART") || ' - '  || Attribute(Get_feature('[T]_DATA_Relation_Wetlands','id',"id"),'Nom_ZH')   ||  ' - '  ||Replace("date",left("date",strpos("date",'-')+1),'')  ||  ' (X)'
        END     
    ELSE
represent_value("COMPART") || ' - '  || "Other"  ||  ' - '  || Replace("date",left("date",strpos("date",'-')+1),'')
END

You'll need to save these values into non-virtual field, or find a way to condense the logic.

1
  • Indeed, thank you! I used a virtual field because it is the only way I know to update a field after closing a relation layer. Now this is not working the same and I can't get the information from the relation(s) as before.
    – Giene
    Oct 6, 2022 at 4:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.