Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cTc86-0004sb-Ju for pgsql-general@arkaria.postgresql.org; Tue, 17 Jan 2017 22:21:26 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cTc86-0003qv-3a for pgsql-general@arkaria.postgresql.org; Tue, 17 Jan 2017 22:21:26 +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_2) (envelope-from ) id 1cTc85-0003qp-IG for pgsql-general@postgresql.org; Tue, 17 Jan 2017 22:21:25 +0000 Received: from mail-wm0-x229.google.com ([2a00:1450:400c:c09::229]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1cTc82-0005Eo-PL for pgsql-general@postgresql.org; Tue, 17 Jan 2017 22:21:24 +0000 Received: by mail-wm0-x229.google.com with SMTP id r144so245641941wme.1 for ; Tue, 17 Jan 2017 14:21:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=M4UXF3ZZgOCkbapv+yIiJa28c3YLNexWRgOCN1XwQsg=; b=VBgF329/YIqNz7XuMRE47JPpEOaU+q1UZmjxRu3c7xBiXHvCjTJZ/oOcbWTit5KOpl /e/qL9zRZhAV3sExSH9AYOCaOjZFs3zLAqpH4gHVEFrd8/OMzX8j70fjf496WRUQDDl2 MwdLJtrvQm+Wx0HYOFYSWbHYtCNzXIzR2thtrZSMOJAbcYNSRaSU8Loeqf2DVAxG0qen +j4vDcb3Yz2DWkIGQtCg8rC0ekidm9e2VoSr2gsrFWsG7fOgo+KTOaWHGGRaHaBiO65j fThsPCb8Hc2Hg3lnLAebPO7DyyBvgtUYE0DtpFg1pCwKFeWYnGRu8nXSIDXgO6AAZiqt 6zOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=M4UXF3ZZgOCkbapv+yIiJa28c3YLNexWRgOCN1XwQsg=; b=b/SlvWN/jT19DTw1vILVnsq5WUyElO0j5K1NX5ZgGDc/xiq4v25NrNx4C3IPiKgdQ+ nYQwJfQXNheju7K6oTkssXvUI4RtQLLlHUstYFrWsTD+r5ahKCv1RI6Ri2Zt/J05FEnv J//wc6pTiFycKTtt+ed7xw5kH2SfPV2fzPifuzmebnX+INkiMGOc0TWqvVt1B/DfD2cc 0otKqYK65qvcvrYp1zwDfadmxtCix+Tyaj3VRGTPQIh5Cc03WPpNs+sQ4ckXnfc0CZTF gK+DqJBAf6/G/G6Rmb5plmOmfmAGSrcqEKWX+EporzwjdYp9wRwwpuQhil1No0kg+j/4 8UwQ== X-Gm-Message-State: AIkVDXJHhLmeO1AngwqwAuDFsqZbcPKfekWmzobZlydesJP+VLqBNPNWHeUdvCEen0vlc1mn9IJYA+heXaorOzaMUTU/efhJSIBiDQXEl4Ix+qRAWak8xU5sellPEy/J4qHFceIg7t5hBuUoOKuiqUmzIDtF5kzYnZ12HNXVtZ8NkG5PQsFFmguWHLAHFWc91hTOdm8ifXLv X-Received: by 10.28.91.16 with SMTP id p16mr276431wmb.111.1484691680549; Tue, 17 Jan 2017 14:21:20 -0800 (PST) Received: from [10.137.2.17] (ip-89-177-46-65.net.upcbroadband.cz. [89.177.46.65]) by smtp.gmail.com with ESMTPSA id y65sm36784211wmb.5.2017.01.17.14.21.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Jan 2017 14:21:20 -0800 (PST) Subject: Re: Queries are taking way longer in 9.6 than 9.5 To: Ravi Tammineni , Chris Mair References: Cc: "pgsql-general@postgresql.org" From: Tomas Vondra Message-ID: <70190c66-cf64-4741-1cd7-a6cf08f4101f@2ndquadrant.com> Date: Tue, 17 Jan 2017 23:21:15 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed 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-general Precedence: bulk Sender: pgsql-general-owner@postgresql.org Hi, after looking at the explain plans again, I very much doubt those come from the same query. The reason is the 9.5 plan contains this part: -> HashAggregate (cost=67.54..68.12 rows=192 width=4) Group Key: d.vip_patient_id -> Nested Loop (cost=0.17..67.44 rows=192 width=4) -> Index Scan using unq_user_name on tblcnaccounts ... Index Cond: ((user_name)::text = 'dddddd'::text) -> Index Only Scan using idx_tblcndoctorpatientmap ... Index Cond: (master_user_id = a.master_user_id) while the 9.6 plan does not include anything like that, i.e. there's only a single aggregate at the top level, without any group keys. Also, the SQL query you've provided does not include any GROUP BY clause, so I claim that those plans are from two different queries. regards Tomas -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general