Number of Elements - Number of records ?

15 views
Skip to first unread message

Roberto Angeletti

unread,
Feb 1, 2016, 4:10:28 AM2/1/16
to spatiali...@googlegroups.com
Hello all,


I noticed a strange behavior in QuantumGIS, when I load a SpatiaLite db.
as you can see, the "sample2015andbuffer_west"  table reports  37046  "elements", but it has, really 6795 records   ( SELECT count(*) FROM "sample2015andbuffer_West" ).

I tryed to perform a VACUUM, also, but nothing changed.

So, my question is:  from where comes that number of "elements" ?


Roberto

a.fu...@lqt.it

unread,
Feb 1, 2016, 6:00:36 AM2/1/16
to spatiali...@googlegroups.com
On Mon, 1 Feb 2016 10:10:27 +0100, Roberto Angeletti wrote:
> Hello all,
>
> I noticed a strange behavior in QuantumGIS, when I load a SpatiaLite
> db.
>
> Look at this image:
>
> https://drive.google.com/file/d/0By5p_WoL_LoFcnl6ZmNlYmVPYmM/view?usp=sharing
> [1]
>
> as you can see, the "sample2015andbuffer_west"  table reports 
> 37046  "elements", but it has, really 6795 records   ( SELECT
> count(*) FROM "sample2015andbuffer_West" ).
>
> I tryed to perform a VACUUM, also, but nothing changed.
>
> So, my question is:  from where comes that number of "elements" ?
>

ciao Roberto,

AFAIK the spatialite-qgis data provider for efficiency reasons
always queries the Statistic metatables in order to determine
the bounding box and the number of record for each vector layer.

you can directly check by yourself the Statistics by executing
the following SQL query:

SELECT * FROM vector_layers_statistics;

if the underlaying table was heavily modified since the last
statistic snapshot (e.g. many rows were deleted or updated or
inserted) then the corresponding Statistics values may easily
become inaccurate until you explicitly ask for refreshing
all them:

SELECT UpdateLayerStatistics();

or (even better)


SELECT InvalidateLayerStatistics();
SELECT UpdateLayerStatistics();

bye Sandro
Reply all
Reply to author
Forward
0 new messages