Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YVkrG-0003b7-RI for pgsql-performance@arkaria.postgresql.org; Wed, 11 Mar 2015 17:55:50 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YVkrG-0000Cr-Ak for pgsql-performance@arkaria.postgresql.org; Wed, 11 Mar 2015 17:55:50 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YVkrF-0000Cl-D9 for pgsql-performance@postgresql.org; Wed, 11 Mar 2015 17:55:49 +0000 Received: from mail-wg0-f49.google.com ([74.125.82.49]) by makus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1YVkr4-0004og-G7 for pgsql-performance@postgresql.org; Wed, 11 Mar 2015 17:55:47 +0000 Received: by wggx12 with SMTP id x12so10968924wgg.13 for ; Wed, 11 Mar 2015 10:55:36 -0700 (PDT) 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=HUOiEyzqDYOvBKivFzdsak+0pM27mtdVEmXeZLE/otA=; b=kJ7eu24GFdRxWOABITX9XM1JNrO5Rgb+yaToFlGE2bgYbPTWUkO9cA4Xb3juerj24Q Wnjpovr+LQ85N46kbgbanH3u5nyMSpYbGy7UGCRASMgh+VGHATqbGvFujJM2Vd3KOrjy N7DfPAaULJIS+h+9T2sZXExpN8ii0iYca3PrY3PpsHyJlI4UrzulQcFSIcDF0PKxx3L1 ZAuvWfN3uzD7y/+/qVmCasvrivg/AblMSy3aPzKJuiI6qv6XYwp7Jf1+bjZeOcWlJyI3 5nJqN18MaWWCwoO0unF/hn3EItv1Om36OB+YOx791XDyT9rB+DLl/i96W3tGNaq0plTf +ahQ== X-Gm-Message-State: ALoCoQlyuESJpw8Y76p45+hZ4S7qRS5mDQVPeM5Fy4gg5Mg3yEe9Lf+oUqhdq7aOApp2lQbDgcEx X-Received: by 10.180.149.206 with SMTP id uc14mr123948802wib.57.1426096536188; Wed, 11 Mar 2015 10:55:36 -0700 (PDT) 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 n1sm25768169wib.11.2015.03.11.10.55.34 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Mar 2015 10:55:35 -0700 (PDT) Message-ID: <5500817C.3030609@2ndquadrant.com> Date: Wed, 11 Mar 2015 18:55:08 +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 CC: Tom Lane , 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> <54FB1CDA.1080606@2ndquadrant.com> 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 11.3.2015 18:30, Jeff Janes wrote: > On Sat, Mar 7, 2015 at 7:44 AM, Tomas Vondra > > wrote: > > 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. > > > Right. Tom was saying that the work needs to be done anyway, but it is > just that some ways of doing the work are far more efficient than > others. It just happens that the executed plan in this case would do it > more efficiently, (but in general you aren't going to get any less > efficient than having the planner do it in index order). Oh! Now I see what you meant. I parsed is as if you're suggesting that the theory does not match the symptoms because the plan contains sequential scan yet there's a lot of random I/O. But now I see that's not what you claimed, so sorry for the noise. -- 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