Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gsQyY-0002EJ-DC for pgsql-general@arkaria.postgresql.org; Sat, 09 Feb 2019 11:39:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gsQyW-0003X0-W2 for pgsql-general@arkaria.postgresql.org; Sat, 09 Feb 2019 11:39:12 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gsQyW-0003Wn-I1 for pgsql-general@lists.postgresql.org; Sat, 09 Feb 2019 11:39:12 +0000 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gsQyP-0003z0-PF for pgsql-general@lists.postgresql.org; Sat, 09 Feb 2019 11:39:11 +0000 Received: by mail-wm1-x343.google.com with SMTP id t200so7918418wmt.0 for ; Sat, 09 Feb 2019 03:39:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=OTR5C7KsJE8rsEBbdHH0ppJeiBKRtvA1o5oWgUvNrBM=; b=FOg5q8QvjliuvZhqO6HXWsiuXkraVIOkAQaZ6289VntHelisNhvA5mocrnMknNp2b0 NgFGXvNF3JAQm49gC6x1mFyI28mD9V87bqVnCWqBEVRpLZuS5gZYFW1EAuO9eU52fKte 1eB2HyhlnUJ6ET8rKoTUMNFT+bs2o088BZJJ9sXMaIMqALbW6DbCUSPu/+eSC2pGYBtE /x0SuM6kYAe1pqKtdo9LoRy7PnExrIM0TIycoWPIc0gZVCjJaq5gAwvXhyIiHT27gQqX zt8G7Q5Akm2uSRIZertXapQxsl0OgRZ0KWru8XalJdcS0mM57wuQXoOmyYIR5mRHX063 T5sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OTR5C7KsJE8rsEBbdHH0ppJeiBKRtvA1o5oWgUvNrBM=; b=kPEcqvcn2byMyiSmgiLXtjv1wcMEFCV0KhdyhXBDL4f+Q/EQLm1avQktZPIr9gyZ/G lfkTJqTmBgOYTDttpOkJ1sSkdTEEf+1oYhU0kbtUYrDZPEclenN90rIVb8NLxbLzeWji KlvrBDpapobAF5NFNx43t5SfRhKQjZlclU4pxWsWBdelAhaZfSZo/Q959KIqoZYDsuJK Zzk1u9d3UwlBguO+Ttd9zy6dKQ6UThIp8NtH2uCbwW8ueu3E9lr1XQsIgIDVmi23/lhp MA6iSGMHAxaLuzbEucr/TRkQbYB+GHlw1rTseTHKUz5YJSZiWvCxf2PdfnPHSYGTto+d z1bA== X-Gm-Message-State: AHQUAuZA+/VdcWRzEBgsebHIYwLWNkF4WCMfts8jPOtarWL+1Ip7vbED fzunYd2TTc2RMc4MTvZpsGZhwhql X-Google-Smtp-Source: AHgI3IaOaADUBIiuImlXT+Z2dMfxo7MkzGZe+P6vKynOEFV+A4MTGBj1hgAWCGpxF0YarvkgZCvagQ== X-Received: by 2002:a5d:6244:: with SMTP id m4mr19744190wrv.314.1549712343743; Sat, 09 Feb 2019 03:39:03 -0800 (PST) Received: from localhost.localdomain (ppp194030245115.access.hol.gr. [194.30.245.115]) by smtp.gmail.com with ESMTPSA id o8sm2548472wrx.15.2019.02.09.03.39.02 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Feb 2019 03:39:03 -0800 (PST) From: auxsvr To: pgsql-general@lists.postgresql.org Subject: Re: FDW, too long to run explain Date: Sat, 09 Feb 2019 13:39:01 +0200 Message-ID: <2255510.6AvA7gdLTz@localhost.localdomain> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Monday, 4 February 2019 09:14:14 EET Vijaykumar Jain wrote: > Hi, Hi, > with pg v10.1 > we use writes directly to shards, and reads via FDW from all shards (RO) > our DB size is ~ 500GB each shard, and tables are huge too. > 1 table ~ 200GB, 1 ~55GB, 1 ~40GB and a lot of small tables, but large > indices on large table. > > the sharding was done based on a key to enable shard isolation at app layer > using a fact table. > select id,shard from fact_table; > > server resources are, > 32GB mem, 8 vcpu, 500GB SSD. > > the FDW connect to each other shard via FDW fronted by haproxy -> pgbouncer > -> postgresql. > Hope this is good enough background :) > > now we have some long running queries via FDW that take minutes and get > killed explain runs as idle in transaction on remote servers. (we set > use_remote_estimate = true ) > when the query is run on individual shards directly, it runs pretty > quickly, > but when run via FDW, it takes very long. > i even altered fetch_sie to 10000, so that in case some filters do not get > pushed, those can be applied on the FDW quickly. In general, the plans via FDW are not the same as the ones running locally. We're having similar issues and the reason seems to be that queries via FDW are optimized for startup cost or few rows. > Regards, > Vijay -- Regards, Peter