<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">greetings - <div class=""><br class=""></div><div class="">I have noticed for a long time, that despite checking the  “use estimated metadata” box when adding PostGIS layers, QGIS seems to issue 2 full-table scan queries. Although I do notice a number of queries to pg_stats, etc looking for various things, NET/NET is 2 full table scans looking like:</div><div class=""><pre class="prettyprint prettyprinted lang-xml"><code class="">SELECT count(distinct ("block_id"))=count(("block_id")) FROM "christest"."block_th_view"
SELECT st_extent("the_geom") FROM "christest"."block_th_view" </code></pre><pre class="prettyprint prettyprinted lang-xml">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 such a huge table very usable ... ONCE given a chance… The user KNOWS it’s extent is the whole world and the primary key is indeed unique. But there seems to be no way to “just add it”… </pre><pre class="prettyprint prettyprinted lang-xml">For tables with many hundreds of millions of objects, this is an unreasonable operation to perform every time that layer is added. </pre><pre class="prettyprint prettyprinted lang-xml">I am a complete newbie to the QGIS source, but am wondering if </pre><pre class="prettyprint prettyprinted lang-xml"><font face="Menlo" class=""><span style="font-size: 11px;" class="">QgsPostgresProvider::extent() might be enhanced, or perhaps more generally QgsVectorDataProvider::extent() , to store some metadata in the local sqlite database, and recognize a new “extent” tag on a maplayer within a project, and a “skip metadata checks” preference to just trust these values. Similarly for </span></font><span style="font-family: Menlo; font-size: 11px;" class="">QgsPostgresProvider::uniqueData() .</span></pre><pre class="prettyprint prettyprinted lang-xml"><font face="Menlo" class=""><span style="font-size: 11px;" class="">Helping user avoid unneeded full data table scans will make QGIS *-far-* more usable.</span></font></pre><pre class="prettyprint prettyprinted lang-xml"><font face="Menlo" class=""><span style="font-size: 11px;" class=""><br class=""></span></font></pre><pre class="prettyprint prettyprinted lang-xml"><font face="Menlo" class=""><span style="font-size: 11px;" class="">thank you</span></font></pre><pre class="prettyprint prettyprinted lang-xml"><font face="Menlo" class=""><span style="font-size: 11px;" class="">Chris Nicholas</span></font></pre><div class=""><br class=""></div><div class=""><div class=""><br class=""></div></div></div></body></html>