I've been reading a few questions on this site and saw quite a few people advocating for creating a cluster function.
So I've decided to test this function to see if there was any notable speed increase. I've used a table with 35,000 points. Both tables have the spatial index but tableb has the cluster
create table tableb as select * from tablea
CREATE INDEX tableb_sidx ON tableb USING gist (geom);
CLUSTER tableb USING tableb_sidx
select a.*
from tablea a, inventory b
where st_dwithin(a.geom, b.geom, 200)
select a.*
from tableb a, inventory b
where st_dwithin(a.geom, b.geom, 200)
Running these st_dwithin queries result in the exact same running time of 1 minute
Am I doing something wrong or does this cluster not apply to every spatial query?
NOT NULL
, you can cluster. Most of the time, it is not null. Though granted, that's not always the case.