Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YUGuR-00027P-3D for pgsql-performance@arkaria.postgresql.org; Sat, 07 Mar 2015 15:44:59 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YUGuQ-0003Kn-J0 for pgsql-performance@arkaria.postgresql.org; Sat, 07 Mar 2015 15:44:58 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YUGuP-0003Kf-Nq for pgsql-performance@postgresql.org; Sat, 07 Mar 2015 15:44:57 +0000 Received: from mail-wi0-f169.google.com ([209.85.212.169]) by magus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1YUGuL-0007RC-BV for pgsql-performance@postgresql.org; Sat, 07 Mar 2015 15:44:56 +0000 Received: by wivr20 with SMTP id r20so10139805wiv.3 for ; Sat, 07 Mar 2015 07:44:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:organization:user-agent :mime-version:to:cc:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=kBW84kBL837GSgD9d5JPexk0vq139GzYZDCb9LdLsqA=; b=eXlPXYoTf9eQUyeNig76b7gDfoHcvuLHKjiIhD3Doe+Fud9WC963tht/BjVyDYVZDV 8szOIIZGxYi1+zscV4vvN8LOkK5jNBN9QBKFmGw1UiBiBmAuZV765aAoxfhgQs4sG+uJ GTbtuHfrELiwtvdJqjMozbbxIdPnvpuTmomHK0zJP2sdztgvA+JyyKlrOSK9OWmwcAwB 6zqJ6GrFMLFFNzzax/TP+UmKfTN82s+R18R0L2RsoravgIQdfkEwOxm5jK7idAgyvNzb U5p6a2K6EpNGJiiGs8O4fxczqAnnGYEgtkMbUmx9cTLDRc6/kMW6Nbd/J49tIt/LyJeM mvJA== X-Gm-Message-State: ALoCoQkN5r3jDal20jNlx8Fv+DB5dKX4j66TA2Xqsbf/C7PoIf8Hd06rKS7mqbpNpA4FJoAjF4u0 X-Received: by 10.194.2.43 with SMTP id 11mr40714434wjr.104.1425743091468; Sat, 07 Mar 2015 07:44:51 -0800 (PST) Received: from [192.168.1.163] (ip-78-45-139-138.net.upcbroadband.cz. [78.45.139.138]) by mx.google.com with ESMTPSA id vv9sm19823504wjc.35.2015.03.07.07.44.49 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 07 Mar 2015 07:44:50 -0800 (PST) Message-ID: <54FB1CDA.1080606@2ndquadrant.com> Date: Sat, 07 Mar 2015 16:44:26 +0100 From: Tomas Vondra Organization: 2ndQuadrant User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Jeff Janes , Tom Lane CC: Kevin Grittner , "pgsql-performance@postgresql.org" , Gunnlaugur Thor Briem Subject: Re: EXPLAIN (no ANALYZE) taking an hour for INSERT FROM SELECT References: <54F9E179.4000804@2ndquadrant.com> <1407502480.21180.1425691482543.JavaMail.yahoo@mail.yahoo.com> <27245.1425692294@sss.pgh.pa.us> In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.6 (--) 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 On 7.3.2015 03:26, Jeff Janes wrote: > On Fri, Mar 6, 2015 at 5:38 PM, Tom Lane > wrote: > > But the actual query is using a seq scan, and so it would hint the > table in efficient sequential order, rather than hinting the table > haphazardly in index order like probing the endpoint does. I think this has nothing to do with the plan itself, but with the estimation in optimizer - that looks up the range from the index in some cases, and that may generate random I/O to the table. > >> Also, it's less than clear why only this particular query is >> showing any stress. Dead rows should be a hazard for anything, >> especially if there are enough of them to require hours to re-hint. >> And why wouldn't autovacuum get to them first? > > > Say the timing of this query is such that 10% of the parent turns > over between invocations of this query, and that this 10% is all at > the end of some index but random over the table heap. If autovac > kicks in at 20% turn over, then half the time autovac does get to > them first, and half the time it doesn't. It would be interesting to > know if this query is bad every time it is planner, or just > sometimes. Yeah, this might be the reason. Another possibility is that this is part of some large batch, and autovacuum simply did not have change to do the work. regards -- Tomas Vondra http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance