qgis / QGIS-Enhancement-Proposals

QEP's (QGIS Enhancement Proposals) are used in the process of creating and discussing new enhancements for QGIS
116 stars 37 forks source link

Improve QGIS project loading time - mainly for QGIS Server #191

Open rldhont opened 4 years ago

rldhont commented 4 years ago

QGIS Enhancement: Improve QGIS project loading time - mainly for QGIS Server

Date 2020/06/03

Author DHONT René-Luc (@rldhont)

Contact rldhont at 3liz dot com

maintainer @rldhont

Version QGIS 3.16

Summary

The trust project option was created to try to improve the loading time of a QGIS project for the postgres layers.

This option forced 2 things for the postgres layers: not checking the uniqueness of the primary key and using the extent of the layer defined in the project.

Since QGIS 3, the trust option forces the use of the layer extent defined in the project for all vector layers and modifies the checkPrimaryKeyUnicity parameter of the Datasource of the postgres layers.

There is also for some layers a Datasource parameter useEstimatedMetadata allowing to accelerate the retrieval of information on the layer (grip, feature count, layer type, etc).

To improve the loading of a QGIS project, you should:

  1. Extend the use of the extent defined in the project to the Raster layers mReadExtentFromXml
  2. In the properties of the layers, have a dedicated configuration interface: definition of the extent, useEstimatedMetadata, checkPrimaryKeyUnicity, etc.
  3. Create new parameters: checkGeometryType, checkSrid, etc.

Some providers will be more impacted than others like postgres and oracle.

Proposed Solution

Extend the use of the extent defined in the project

For vector layers, we have:

QgsVectorLayer::QgsVectorLayer( const QString &vectorLayerPath,
                                const QString &baseName,
                                const QString &providerKey,
                                const QgsVectorLayer::LayerOptions &options )
  : QgsMapLayer( QgsMapLayerType::VectorLayer, baseName, vectorLayerPath )
  , mServerProperties( new QgsVectorLayerServerProperties( this ) )
  , mAuxiliaryLayer( nullptr )
  , mAuxiliaryLayerKey( QString() )
  , mReadExtentFromXml( options.readExtentFromXml )

We would have to add readExtentFromXml to QgsRasterLayer::LayerOptions struct, a private attribute mReadExtentFromXml and make the code to take it into account inQgsRasterLayer.

Management interface

In the Layer Properties window, in the Source tab, we must add a management interface for the extent defined in the project, but also for Datasource parameters such as useEstimatedMetadata and checkPrimaryKeyUnicity.

Management of the extent defined in the project

If it is possible to use the extent defined in the project for all the layers, it is necessary to be able to manage this extent.

For the moment QGIS only offers a button to calculate the extent of the layer from the data.

This extent can evolve by adding data, it would therefore be necessary for certain layers to regularly recalculate this extent or define a maximum extent integrating the maximum of data.

We propose to define an interface displaying the current extent as for the extent of the CRSes and the values of this extent.

We also propose to define several buttons allowing to carry out the following operations and reuse QgsExtentWidget:

Managing Datasource settings

Datasource parameters can no longer be modified once the layer has been created:

Define new parameters to speed up the loading of layers

By studying the source codes of providers postgres and oracle, it is possible to define new Datasource parameters that would improve the loading of the project:

Example(s)

(optional)

Affected Files

Extend the use of the extent defined in the project

Management interface

Define new parameters to speed up the loading of layers

Performance Implications

Hope to speed up the loading of layers

Further Considerations/Improvements

Better managing layer's datasource

Backwards Compatibility

none

Votes

(required)

rldhont commented 4 years ago

Open for feedback @andreasneumann @pblottiere @elpaso @mdouchin @dmarteau

rldhont commented 3 years ago

First related PR:

mdouchin commented 3 years ago

Thanks for the work. What about proposing a solution to disable also:

borysiasty commented 3 years ago

The checking of every feature field type and other properties: let's really trust the project here too ?

Btw. don't miss the recent speedup here: https://github.com/qgis/QGIS/pull/38158 . With only checking the relevant fields, it works smoothly in large databases in the end.

rldhont commented 3 years ago

The checking of every feature field type and other properties: let's really trust the project here too ?

Btw. don't miss the recent speedup here: qgis/QGIS#38158 . With only checking the relevant fields, it works smoothly in large databases in the end.

Thanks @borysiasty. this is for postgres layers. Does the same has been done for oracle or other database ?

rldhont commented 3 years ago

The trust flag only skips the extent request to the provider. For you what are the other requests to skip with this flag ?

rldhont commented 3 years ago

To enhance the trust flags: Propagate trust layer metadata flag https://github.com/qgis/QGIS/pull/38464

borysiasty commented 3 years ago

Thanks @borysiasty. this is for postgres layers. Does the same has been done for oracle or other database ?

Nope. I only touched the Postgres provider. I guess that particular issue with fetching superfluous metadata was postgres-specific.