query faster with a foreign table

From: Dominique Vallée <dominique(dot)vallee(at)mnhn(dot)fr>
To: pgsql-performance(at)postgresql(dot)org
Subject: query faster with a foreign table
Date: 2015-03-26 10:46:55
Message-ID: 5513E39F.2070503@mnhn.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

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

Browse pgsql-performance by date

  From Date Subject
Next Message Tomas Vondra 2015-03-26 12:44:19 Re: Index only scan sometimes switches to sequential scan for small amount of rows
Previous Message Feike Steenbergen 2015-03-26 08:26:11 Re: Index only scan sometimes switches to sequential scan for small amount of rows