I have a few huge PostGIS tables, and despite setting 'use estimated metadata' when creating the underlying datasource, it STILL issues these incredibly frustrating 'queries of death' at both layer addition and loading saved projects causing full table scans:
SELECT count(distinct ("block_id"))=count(("block_id")) FROM "christest"."block_th_view" SELECT st_extent("the_geom") FROM "christest"."block_th_view"
Can't we just add a bounding box metadata tag on a layer definition, and trust that it is indeed using a unique primary key, and optionally have QGIS just blindly trust the project file on start-up?
Consider a well-indexed table with billions of GPS points with a free running counter as its unique key, that only allows display up to a zoom scale of 1:1000. Good GIST indexing and fast RAID disks make it very usable ... once given a chance... BUT..not one, but TWO (!!!) full table scans are required each time to load the layer, that yields the same obvious results: one billion unique keys and the entire world. It is an utter waste of both the user's and the database's precious resources to recalculate this, much as it would be to recalculate pi to a million places every time you wanted to use that function on your calculator.
Add a new tag "boundingBox" or "extents" child XML node under a maplayer, within QGIS project files, that is blindly trusted when a global preference is set, rather than "figuring it out" on the fly by performing a full table scan with SELECT st_extent() during load, and optionally skip the unique key check. Furthermore, add an additional dialog box to optionally set this manually when the layer is first added, as is done in GRASS GIS.
This will make QGIS -far- more useable for very large database layers.