I'm running a python script which drip-feeds data slowly into a postgres database with postgis extension. I'm using autocommit, and committing one row at a time. Horrendously slow, but I need to do it this way for a good reason :)
Once I add a postgres layer, QGIS seems to poll the database every so often and the number of features increases. This is great, and gives me visual feedback that my script is working.
If I stop my script, TRUNCATE the table using pgAdminIII and restart my script, QGIS correctly clears the display (it notices that there are no features). However, it doesn't seem to track subsequent changes to the database, and the feature count sticks at the number of rows there were, rather than 0. I need to add the postgres layer again, which can take a while.
Is this a bug, a feature, or am I doing something wrong?
(Environment: QGIS 2.12.1 Pisa, Postgres 9.3.10, PostGIS 2.1.2, Ubuntu Tahr 32 bit)
Update
It seems that once the number of features exceeds the number of features in the database before I truncated the database, QGIS starts tracking changes again.
truncate cascaded
in case the metadata was not being updated, but that didn't seem to work either.vaccum analyse
andreindex
- no joy. However I did notice this table doesn't have a primary key, which might have an impact on this.