Thread: query faster with a foreign table

query faster with a foreign table

From
Dominique Vallée
Date:
Hello,

I have an executing time problem for a query : this time is very
different as I used a local table or a foreign table : 20 times faster
for the foreign table
On a server 9.4.1, I have 2 spatial bases  b1 (size 5.4 Go) et b2 (size
19Mo) and in the base b1 the table  tmp_obs_coordgps  (61 Mo, 502982
lignes).

When I use a JOIN construct beetwen this table  tmp_obs_coordgps and a
foreign table fao_areas (table in b2), the performance are best than
with a local table  fao_aires_local (in b1).
These 2 tables fao_areas and  fao_aires_local are identical (build with
"select * from" or with pg_dump : the results are the same)

The links to "explain analyze" are
* foreign table fao_areas : http://explain.depesz.com/s/4hO
select count(*) from  tmp_obs_coordgps o, fao_areas  f where
o.code_fao=f.f_code and st_contains(f.the_geom, o.geom);
* local table  fao_aires_local : http://explain.depesz.com/s/BvDb
select count(*) from  tmp_obs_coordgps o, fao_aires_local   f where
o.code_fao=f.f_code and st_contains(f.the_geom, o.geom);

Thanks by advance

--
Dominique Vallée
UMS 3468 Bases de données sur la Biodiversité, Ecologie, Environnement et Sociétés (BBEES)
MNHN - Muséum national d'Histoire naturelle
01 40 79 53 70