Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1aOZoU-0000qz-RP for pgsql-performance@arkaria.postgresql.org; Wed, 27 Jan 2016 23:47:50 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1aOZoU-00019D-9A for pgsql-performance@arkaria.postgresql.org; Wed, 27 Jan 2016 23:47:50 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1aOZmp-0007kl-7P for pgsql-performance@postgresql.org; Wed, 27 Jan 2016 23:46:07 +0000 Received: from mail-io0-x232.google.com ([2607:f8b0:4001:c06::232]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1aOZmm-0006A7-9F for pgsql-performance@postgresql.org; Wed, 27 Jan 2016 23:46:05 +0000 Received: by mail-io0-x232.google.com with SMTP id f81so37044410iof.0 for ; Wed, 27 Jan 2016 15:46:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=user-agent:date:subject:from:to:message-id:thread-topic :mime-version:content-type; bh=WRJopXD8CqOHbriGiUwwS9J4JZHaUTX/0cQV2u6DIFs=; b=xq56rQPdi6p/hVqLm71t+lQRIhWgoAch8gd4HZRA9BHOdcFyE8DPak/Zb9BHsSWF36 S1qQKvMH0TLtIrDut/oBIUMRQ4yb28/dABiuRprKRsVOBAc/zwYaAhcwi0gKck30cvlP qvK/WdCuDUs6rWCvetXkK9FaCyskDNogUv3dOGLR33e35KaObDGfq/vt0bfOTke+CPCw fTbysJM4JSkEEC10Hpt2mfXUZC9ryRlKm+82zyY9bgAX66/ukFFIZRhor6tmV1dm7WSc ipSCTMxCUOxBUV039X43HAwbcG6vcw7S82baU91itWzK7Xnx50Qi81vDkdNByqMQant0 Xs9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:user-agent:date:subject:from:to:message-id :thread-topic:mime-version:content-type; bh=WRJopXD8CqOHbriGiUwwS9J4JZHaUTX/0cQV2u6DIFs=; b=WVHx4v9bJrzjg0033Y8jtaCFFlNtwulkYmSTsg3qJdQwPFLMrpgN8rHsUIsMTNo6K+ v3BJNB7q/8jtCeKVK57xQrQUQHDDKgIN6ro6Hc5m2tmmyXZlDiP5clW4R6RppP2kEM8M G4ngx9K7cwStG2QnAudMFOgP35G4VaVAnyLjj7t0ZHTrz8FgawKQiuKrl21BD0JGbuoV 4S7DjaWi/8vwxZiA731YbrXaiRDbea8ye3kmNi98ndZtyU/3lyWZuT3f3ep4Uus+6J/U q3u8Vvu0sZ8f4afuyYOLcIycHqNEu4lFDOlWJb1kvvAJx0OXKdLoMFBVPCDLZhXscLEW eJvg== X-Gm-Message-State: AG10YOTxV/QTGYE/miXN7XSnY/YiSHGrI2QOW4imxsd2mx35Wdn7LZwGuL0VWwfSeIvtXA== X-Received: by 10.107.198.202 with SMTP id w193mr567910iof.178.1453938363280; Wed, 27 Jan 2016 15:46:03 -0800 (PST) Received: from [10.0.0.10] (40.166.255.173.client.static.strong-in91.as13926.net. [173.255.166.40]) by smtp.gmail.com with ESMTPSA id mu8sm92121igb.16.2016.01.27.15.46.02 for (version=TLSv1/SSLv3 cipher=OTHER); Wed, 27 Jan 2016 15:46:02 -0800 (PST) User-Agent: Microsoft-MacOutlook/0.0.0.151217 Date: Wed, 27 Jan 2016 18:46:00 -0500 Subject: performance issue with inherited foreign table From: Dzmitry Nikitsin To: Message-ID: Thread-Topic: performance issue with inherited foreign table Mime-version: 1.0 Content-type: multipart/alternative; boundary="B_3536765162_1581126399" X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org > This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. --B_3536765162_1581126399 Content-type: text/plain; charset="UTF-8" Content-transfer-encoding: 7bit in postgres 9.5.0 i have partitioned table, that collect data by months, i tried to use new postgres feature foreign table inheritance & pushed one month of data to another postgres server, so i got foreign table. when i am running my query from my primary server, query takes 7x more time to execute query, then on another server where i have foreign table. i am not passing a lot of data by network, my query looking like explain analyze SELECT source, global_action, paid, organic, device, count(*) as count, sum(price) as sum FROM "toys" WHERE "toys"."container_id" = 857 AND (toys.created_at >= '2015-12-02 05:00:00.000000') AND (toys.created_at <= '2015-12-30 04:59:59.999999') AND ("toys"."source" IS NOT NULL) GROUP BY "toys"."source", "toys"."global_action", "toys"."paid", "toys"."organic", "toys"."device"; HashAggregate (cost=1143634.94..1143649.10 rows=1133 width=15) (actual time=1556.894..1557.017 rows=372 loops=1) Group Key: toys.source, toys.global_action, toys.paid, toys.organic, toys.device -> Append (cost=0.00..1143585.38 rows=2832 width=15) (actual time=113.420..1507.373 rows=76593 loops=1) -> Seq Scan on toys (cost=0.00..0.00 rows=1 width=242) (actual time=0.001..0.001 rows=0 loops=1) Filter: ((source IS NOT NULL) AND (created_at >= '2015-12-02 05:00:00'::timestamp without time zone) AND (created_at <= '2015-12-30 04:59:59.999999'::timestamp without time zone) AND (container_id = 857)) -> Foreign Scan on job_stats_201512_new (cost=100.00..1143585.38 rows=2831 width=15) (actual time=113.419..1488.445 rows=76593 loops=1) Planning time: 2.990 ms Execution time: 1560.131 ms does postgres use indexes on foreign tables ?(i have indexes defined in foreign table), if i run query directly on that server it takes - 200ms. --B_3536765162_1581126399 Content-type: text/html; charset="UTF-8" Content-transfer-encoding: quoted-printable

in postgres 9.5.0 i have p= artitioned table, that collect data by months, i tried to use new postgres f= eature foreign table inheritance & pushed one month of data to another p= ostgres server, so i got foreign table. when i am running my query from my p= rimary server, query takes 7x more time to execute query, then on another se= rver where i have foreign table. i am not passing a lot of data by network, = my query looking like

explain analyze SELECT source, global_action, paid, org= anic, device, count(*) as count, sum(price) as sum FROM "toys" WHERE "toys".= "container_id" =3D 857 AND (toys.created_at >=3D '2015-12-02 05:00:00.000000'= ) AND (toys.created_at <=3D '2015-12-30 04:59:59.999999') AND ("toys"."sour= ce" IS NOT NULL) GROUP BY "toys"."source", "toys"."global_action", "toys"."p= aid", "toys"."organic", "toys"."device";

HashAggregate (cost=3D1143634.94..1143= 649.10 rows=3D1133 width=3D15) (actual time=3D1556.894..1557.017 rows=3D372 loops=3D1)= Group Key: toys.source, toys.global_action, toys.paid, toys.organic, toys.d= evice -> Append (cost=3D0.00..1143585.38 rows=3D2832 width=3D15) (actual time=3D1= 13.420..1507.373 rows=3D76593 loops=3D1) -> Seq Scan on toys (cost=3D0.00..0.00= rows=3D1 width=3D242) (actual time=3D0.001..0.001 rows=3D0 loops=3D1) Filter: ((sourc= e IS NOT NULL) AND (created_at >=3D '2015-12-02 05:00:00'::timestamp withou= t time zone) AND (created_at <=3D '2015-12-30 04:59:59.999999'::timestamp w= ithout time zone) AND (container_id =3D 857)) -> Foreign Scan on job_stats_= 201512_new (cost=3D100.00..1143585.38 rows=3D2831 width=3D15) (actual time=3D113.419= ..1488.445 rows=3D76593 loops=3D1) Planning time: 2.990 ms Execution time: 1560.= 131 ms

does postgres use indexes on foreign tables ?(i have indexes defined i= n foreign table), if i run query directly on that server it takes - 200ms.


--B_3536765162_1581126399--