I have a table with 3.7 million rows. It has a boolean value (called bool_value below) that already has a value for all rows.
I am using this query to udpate bool_value:
DROP INDEX IF EXISTS table_bool_value_idx;
UPDATE table
SET bool_value = (
st_contains(st_setsrid((SELECT geom FROM gis.cntys04_3081 WHERE gid=57), 3081), the_geom)
AND st_contains((SELECT geom_3081 FROM gis.stratmap_city_poly_v4 WHERE gid = 127), the_geom)
);
This query has run for about 12 hours so far. For the entire time, my hard drive has 100% utilization.
I don't understand this hard drive utilization as the table has been vacuumed within the past month, bool_value already has a record for each row, and I dropped the index. Both of the tables in the gis namespace (referenced in the query) are indexed on their gid field. Those gis namespace tables are not views. They are just SHPs that I imported using PostGIS's PostGIS 2.0 Shapefile and DBF Loader Exporter. Nothing else significant is happening on the computer.
Per Task Manager, CPU utilization is next to nothing, even on the postgres.exe process. I assume this is due to the extreme hard drive activity.
The computer has 8GB total. Almost half of that is free. There are 14 concurrent postgres.exe processes open, and they have between 2.8 MB and 9 MB each. Only one of the processes is showing much activity.
Here's the one thing I wonder about: the geom_3081 from the second st_contains is 1.0 MB long. It's a PostGIS MULTIPOLYGON representing the city limits of Dallas, TX. I imagine this would be cached by, if nothing else, the Windows disk cache, preventing repeated hard drive accesses. geom_3081 is not indexed, although I don't see why indexing it would help as it's not being used to determine which rows to return; the gid field is doing that.