I have a PostGIS dataset with around 3 million shapes. I only need to view about 1,500 of these shapes at any given time, but the shapes I need to see depends on which feature is selected in a different dataset.

My question is: what is the speed difference between filtering my large dataset within PostGIS and then serving it up to QGIS, vs loading the entire dataset into QGIS and then using the baked-in layer filtering? I'm running PostGIS 2 and QGIS 1.8.

I assume PostGIS is faster, but how much faster? I'd like a second opinion before I spend my time coding for one solution over the other. Thanks!


Filtering (ie. using Layer / Query or the Query Builder in layer properties) in QGIS justs adds a where clause to the query that is executed. So that shouldn't be different to you want to do "in" PostGIS. Although I'm not sure what you intent to do there.

  • So, does that mean that the layer filter in QGIS is actually filtering at the database level, or is there something happening under the hood in the program? I had assumed there was a difference. Jun 23 '12 at 23:44
  • 1
    Yes, on database level. Although there are a few places where you might expect that QGIS also filters on database level, but doesn't (eg. when searching in the attribute table). But that happens after the "query filter" is already applied on database level.
    – jef
    Jun 24 '12 at 0:00

Your Answer

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

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