Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eMCVe-0006zW-Hn for pgsql-bugs@arkaria.postgresql.org; Tue, 05 Dec 2017 12:39:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eMCVd-0002En-Nq for pgsql-bugs@arkaria.postgresql.org; Tue, 05 Dec 2017 12:39:37 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eMCVd-0002EV-Cg for pgsql-bugs@lists.postgresql.org; Tue, 05 Dec 2017 12:39:37 +0000 Received: from mail-qt0-x22a.google.com ([2607:f8b0:400d:c0d::22a]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1eMCVZ-0008Jv-SW for pgsql-bugs@postgresql.org; Tue, 05 Dec 2017 12:39:36 +0000 Received: by mail-qt0-x22a.google.com with SMTP id e2so273476qti.0 for ; Tue, 05 Dec 2017 04:39:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=1AFRdhTe9LldFtwtuvrJRnRecgfz4xCYGewbP0Z+xZ4=; b=kW+U0i/1yZ2ZXv9gEDYgn8SR5EBSeleE+1iZStNRJw82MgT5tSDDF7v9rdN7bcNIib d3vT4sjXPOP3TjPgwBEh8ae2IjeWwOKEvs+FKpLoWQVSPDiabUzTbMzR1jFFSGpzfkLN cZGToRLTQN5hvYQj+L0rAUGUhUqRWSe2M6TQTe9H/H3AEEP0OmBJ1dJKC7NoHfauOfCS /IyJXxwv/2ZJe7ZOfhTfHNcmIttgQfB7+x4XqZo0rJk8g5rTeYDZE8UFY6QoYA2Bnh9Z il3EGfTs1yyMr8v2hWsAHvCpwVp3BopCNfxe+W/IU74p8v+Ou+Zf1FqygD5XaPbqTKyh g7aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=1AFRdhTe9LldFtwtuvrJRnRecgfz4xCYGewbP0Z+xZ4=; b=CGi1sXJLtgfdCD8F7b/3pawQtFS6Ts3//lT6H03oEtnUPbxQt7DAIhoHttEQ6R/JUR vZLq18orkfM+pzm0zC05xrekd/Clju+ExK8oQ6OCVjwtbjaccliRFwHJOnLJNcBk1PK3 3hGrMdAQ9QLS+X2n8ewpNLimAqZvPDL2l3WTlox45KdYr4JptdB17kao8NFEdHkbPUjX HEAFNdnq62S0ERquea5nduu0mNWkgzAq1eG90tvDGi6dr1ytf7KAjJxjaRpAtbtuBCDw 67gJttl4sMisXKMViFCGsnA5V93qQdEh9fgJ2KRDrKMkPqg73Su6J7BA0QwE9Rwxo2WZ 0AsQ== X-Gm-Message-State: AKGB3mLi3QOE656E1ulpbiBBcZMivgA/zqKwAV/pSqNsVR6BwzO1TEoD 0IY0xakFIwfJBjLn9VKwtj/5gQ== X-Google-Smtp-Source: AGs4zMbyaAL4bxHgVcRoCFtpwVO0kiCpieDGNhMPn9YvhDRJ+69s09lpHhVHfkJ8m0EXh0dMh2hvRQ== X-Received: by 10.237.57.202 with SMTP id m68mr2109245qte.185.1512477571989; Tue, 05 Dec 2017 04:39:31 -0800 (PST) Received: from alvin.alvh.no-ip.org ([179.57.113.18]) by smtp.gmail.com with ESMTPSA id r55sm40218qta.57.2017.12.05.04.39.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Dec 2017 04:39:31 -0800 (PST) Received: by alvin.alvh.no-ip.org (Postfix, from userid 1000) id 8118712D1; Tue, 5 Dec 2017 09:39:29 -0300 (-03) Date: Tue, 5 Dec 2017 09:39:29 -0300 From: Alvaro Herrera To: jasc@gmx.net Cc: pgsql-bugs@postgresql.org Subject: Re: BUG #14948: cost overflow Message-ID: <20171205123929.pwc6jqvptrdslflr@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20171205105924.27108.93509@wrigleys.postgresql.org> User-Agent: NeoMutt/20170306-137-4415bd-dirty (1.8.0) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi Jan, it seems pretty likely that these are indeed overflows. However, because of the whitespace mangling these plans are pretty much impossible to read. Would you mind pasting these again, as text/plain attachment instead? Does the query actually take 6ms in the system with the funny explain, and 5s on the other? Thanks jasc@gmx.net wrote: > Full EXPLAIN (ANALYSE BUFFERS) on the funny looking system: > > GroupAggregate > (cost=-25142102027752040829944596389028691968.00..-25142102027752040829944596389028691968.00 > rows=1600000000 width=254) (actual time=1.640..1.640 rows=0 loops=1) > Group Key: "*SELECT* 1".sendid_fk, "*SELECT* 1".campaign_fk, > ('-1'::smallint), (('-1'::smallint)::integer) > Buffers: shared hit=11 > -> Sort > (cost=-25142102027752040829944596389028691968.00..-25142102027752040829944596389028691968.00 > rows=16812456500 width=120) (actual time=1.638..1.638 rows=0 loops=1) > Sort Key: "*SELECT* 1".sendid_fk, "*SELECT* 1".campaign_fk, > ('-1'::smallint), (('-1'::smallint)::integer) > Sort Method: quicksort Memory: 25kB > Buffers: shared hit=11 > -> Append > (cost=329985.38..-25142102027752040829944596389028691968.00 rows=16812456500 > width=120) (actual time=1.621..1.621 rows=0 loops=1) > Buffers: shared hit=11 [...] > Planning time: 7.154 ms > Execution time: 6.358 ms > ############## > # On a different system it looks like this (much more sane): > ############## > > GroupAggregate (cost=384347.08..414413.11 rows=37349 width=254) (actual > time=5343.214..5417.604 rows=1194 loops=1) > Group Key: "*SELECT* 1".sendid_fk, "*SELECT* 1".campaign_fk, > ('-1'::smallint), (('-1'::smallint)::integer) > Buffers: shared hit=421793 read=26153, temp read=1561 written=1717 > -> Sort (cost=384347.08..385280.81 rows=373491 width=120) (actual > time=5343.180..5351.390 rows=55816 loops=1) > Sort Key: "*SELECT* 1".sendid_fk, "*SELECT* 1".campaign_fk, > ('-1'::smallint), (('-1'::smallint)::integer) > Sort Method: external merge Disk: 2880kB > Buffers: shared hit=421793 read=26153, temp read=1561 written=1717 > -> Append (cost=140964.58..319780.25 rows=373491 width=120) > (actual time=2319.179..5287.481 rows=55816 loops=1) > Buffers: shared hit=421787 read=26153, temp read=1201 > written=1356 > Planning time: 635.005 ms > Execution time: 5423.894 ms -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services