Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cTaGp-0007Q8-LM for pgsql-general@arkaria.postgresql.org; Tue, 17 Jan 2017 20:22:19 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cTaGp-0001Za-6l for pgsql-general@arkaria.postgresql.org; Tue, 17 Jan 2017 20:22:19 +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 1cTaGn-0001Yh-Jb; Tue, 17 Jan 2017 20:22:17 +0000 Received: from mail-wm0-x22f.google.com ([2a00:1450:400c:c09::22f]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1cTaGe-00036N-Pq; Tue, 17 Jan 2017 20:22:16 +0000 Received: by mail-wm0-x22f.google.com with SMTP id c85so216395977wmi.1; Tue, 17 Jan 2017 12:22:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=2VUzCel/8W6mcS9Jcj96rJqCMlHR6rM6WeL2JFeJnqY=; b=nr9WZpPUeBHjzrgiBuOSKz9xr9McJXBQ+N/y46r/SjDdqZ87Q07AvmKr5BNJjdZapG IepPWZKa9FsO8mvASG+80/AGoGq8BxYfLhajHItcfJBsUH16K/JQpVyUACtuVZZHOLST GdT5FbKAKL6IjW8uuNNsZhDWRbSPS9CmHi1i5DDRde/PDVDBkFr/9oAtvUutp+JGsuiT YZyRCA2TvPQqzHoO8D6F6JH/G3xIcUIKDSUU6wIjq+5EHkzxe61VA2yKhxV5rpThg+um jB7GRqYYoPvP4vBUaRhh+5yFHfN7Lyxp3BB2ZV8hSYiE4Jf1uL0rK9bDbVeuezMqTlvF QItw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=2VUzCel/8W6mcS9Jcj96rJqCMlHR6rM6WeL2JFeJnqY=; b=qQNjZ4QpWfaIm6VmYO0CUkC5S0u2v3+HTtx0K4adJV1WBuC9S6cUlwvi1+vSafRmNe xXIT5yLczttsSXsJOU7kcECOw/v4BJO8gm7zncIyB45zz045ADXIqo3ZyBfpV6EPbtF4 FQI+GjwuramoiRQSVdeS/95T240kGlTesuoVwxHt4nUIC60mVQwVCCNDxhxIt9RureN2 7YIa3/AIzDFYHcg3OaMq5sYEBIjMhobD+uPS7wO91lTrhIxZ60yXwRE75Lrh3Esmnpjy 6bZt0HgZGfWeH7S61ci4pU6uS8Xw5EiDsOURLzXPOz98IOenFMr5dzJc+cQd8KT69HSQ gq+w== X-Gm-Message-State: AIkVDXIq6fwOEuVDHd2HhkCKFXBSBrjD7b88PFQtnMZEa7Qj1AVqnkwxGhbDY+nhC61mVHaEldJGJ01mxkj7Pg== X-Received: by 10.28.31.84 with SMTP id f81mr18606418wmf.94.1484684527846; Tue, 17 Jan 2017 12:22:07 -0800 (PST) MIME-Version: 1.0 Received: by 10.28.107.216 with HTTP; Tue, 17 Jan 2017 12:21:27 -0800 (PST) In-Reply-To: References: <83d13711-6431-d944-ce42-6e73bc649bf2@aklaver.com> From: Melvin Davidson Date: Tue, 17 Jan 2017 15:21:27 -0500 Message-ID: Subject: Re: Queries are taking way longer in 9.6 than 9.5 To: Ravi Tammineni Cc: Adrian Klaver , "pgsql-admin@postgresql.org" , "pgsql-general@postgresql.org" , "pgadmin-support@postgresql.org" Content-Type: multipart/alternative; boundary=001a114b2ea0e2cf090546500d11 X-Pg-Spam-Score: -2.4 (--) 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 --001a114b2ea0e2cf090546500d11 Content-Type: text/plain; charset=UTF-8 On Tue, Jan 17, 2017 at 3:12 PM, Ravi Tammineni < rtammineni@partner.aligntech.com> wrote: > Hi Adrain, > > We have deployed our databases in Heroku and we have followed the upgrade > option that they have provided to us. Here is the command. > > heroku pg:upgrade --app > > I am not sure whether they are doing the vacuum after the upgrade or not. > I have disabled the parallel execution; still execution plan is not correct. > > QUERY PLAN > ------------------------------------------------------------ > ------------------------------------------------------------------- > Aggregate (cost=3391172.70..3391172.71 rows=1 width=8) > -> Nested Loop Semi Join (cost=3218963.06..3391149.45 rows=46513 > width=0) > -> Nested Loop (cost=3218962.89..3343428.74 rows=46513 width=4) > -> Hash Join (cost=3218962.80..3323993.25 rows=46513 > width=4) > Hash Cond: (os.order_status_history_id = > osh.order_status_history_id) > -> Seq Scan on tblpuorderstatus os > (cost=0.00..96501.53 rows=11185842 width=8) > -> Hash (cost=3217108.89..3217108.89 rows=529689 > width=4) > -> Seq Scan on tblpuorderstatushistory osh > (cost=0.00..3217108.89 rows=529689 width=4) > Filter: ((cancelled_date IS NULL) AND > (cc_accept_date IS NOT NULL) AND (vip_order_type = 17)) > -> Index Scan using tblcnpatientordermap_pkey on > tblcnpatientordermap po (cost=0.09..0.41 rows=1 width=8) > Index Cond: (vip_order_id = os.vip_order_id) > -> Nested Loop Semi Join (cost=0.17..1.02 rows=1 width=4) > -> Index Scan using tblcndoctorpatientmap_pkey on > tblcndoctorpatientmap d (cost=0.09..0.39 rows=1 width=8) > Index Cond: (vip_patient_id = po.vip_patient_id) > -> Index Scan using tblcnaccounts_pkey on tblcnaccounts a > (cost=0.08..0.36 rows=1 width=4) > Index Cond: (master_user_id = d.master_user_id) > Filter: ((user_name)::text = 'rdoyleda'::text) > (17 rows) > > Thanks > ravi > > > > -----Original Message----- > From: Adrian Klaver [mailto:adrian.klaver@aklaver.com] > Sent: Tuesday, January 17, 2017 11:42 AM > To: Ravi Tammineni ; > pgsql-admin@postgresql.org; pgsql-general@postgresql.org; > pgadmin-support@postgresql.org > Subject: Re: [GENERAL] Queries are taking way longer in 9.6 than 9.5 > > On 01/17/2017 11:31 AM, Ravi Tammineni wrote: > > Hi, > > > > > > > > We have recently upgraded to 9.6 and few queries are performing very > > poorly. Query execution time has increased more 4 or 5 times in 9.6. > > Qeruy execution plan is also completely changed. I am not sure whether > > its because of Parallel feature or any bug in 9.6. There are few > > similar kind of queries and all of them are taking more time in 9.6. > > How did you upgrade from 9.5 --> 9.6? > > Did you run ANALYZE on the tables after the upgrade? > > Tend to doubt parallel query is at issue here, as it is turned off by > default: > > https://www.postgresql.org/docs/9.6/static/runtime-config- > resource.html#GUC-MAX-PARALLEL-WORKERS-PER-GATHER > > For more info: > > https://www.postgresql.org/docs/9.6/static/parallel-query.html > > > > > > > > Following query is taking 70ms in 9.5 and the same query is taking 2 > > minutes in 9.6. Execution plan is totally different in 9.6 and seems > > like there is a major flaw while generating the execution plan. > > Instead of filtering the low cardinality, its filtering from biggest > table. > > Somehow nested loop joins are screwed up. > > > > > > > > > > > > I really appreciate your help. > > > > > > > > explain analyze > > > > SELECT count(*) > > > > FROM > > > > tblCnPatientOrderMap po > > > > JOIN tblPuOrderStatus os ON po.vip_order_id = os.vip_order_id > > > > JOIN tblPuOrderStatusHistory osh ON os.order_status_history_id = > > osh.order_status_history_id > > > > WHERE > > > > exists(SELECT 1 > > > > FROM > > > > tblCnDoctorPatientMap d > > > > WHERE d.vip_patient_id = po.vip_patient_id > > > > AND exists(SELECT 1 > > > > FROM > > > > tblCnAccounts a > > > > WHERE a.master_user_id = d.master_user_id > > AND > > > > a.user_name = 'dddddd')) > > > > AND osh.vip_order_type IN (17)--assist > > > > --AND osh.tx_submit_date IS NOT NULL > > > > AND osh.cancelled_date IS NULL > > > > AND osh.cc_accept_date IS NOT NULL; > > > > > > > > > > > > ########################## 9.5 Execution plan > > > > > > > > > > QUERY PLAN > > > > ---------------------------------------------------------------------- > > ---------------------------------------------------------------------- > > --------- > > > > Aggregate (cost=1177.25..1177.26 rows=1 width=0) > > > > -> Nested Loop (cost=67.83..1177.25 rows=5 width=0) > > > > -> Nested Loop (cost=67.71..254.81 rows=1322 width=4) > > > > -> Nested Loop (cost=67.63..104.45 rows=1322 width=4) > > > > -> 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 a (cost=0.08..4.09 rows=1 width=4) > > > > Index Cond: ((user_name)::text > > = > > 'dddddd'::text) > > > > > > > > -> Index Only Scan using > > idx_tblcndoctorpatientmap on tblcndoctorpatientmap d > > (cost=0.09..62.78 > > rows=192 width=8) > > > > Index Cond: (master_user_id = > > a.master_user_id) > > > > -> Index Scan using idx_tblcnpatientordermap on > > tblcnpatientordermap po (cost=0.09..0.17 rows=7 width=8) > > > > Index Cond: (vip_patient_id = > > d.vip_patient_id) > > > > -> Index Scan using tblpuorderstatus_pkey on > > tblpuorderstatus os (cost=0.09..0.11 rows=1 width=8) > > > > Index Cond: (vip_order_id = po.vip_order_id) > > > > -> Index Scan using tblpuorderstatushistory_pkey on > > tblpuorderstatushistory osh (cost=0.11..0.69 rows=1 width=4) > > > > Index Cond: (order_status_history_id = > > os.order_status_history_id) > > > > Filter: ((cancelled_date IS NULL) AND (cc_accept_date > > IS NOT NULL) AND (vip_order_type = 17)) > > > > > > > > ###################################################################### > > ############################################################### > > > > > > > > ########################## 9.6 Execution plan > > > > QUERY > > PLAN > > > > ---------------------------------------------------------------------- > > --------------------------------------------------------------- > > > > Aggregate (cost=3185034.17..3185034.17 rows=1 width=8) > > > > -> Nested Loop Semi Join (cost=3012833.92..3185010.91 rows=46511 > > width=0) > > > > > > > > -> Nested Loop (cost=3012833.75..3137291.51 rows=46511 > > width=4) > > > > > > > > -> Hash Join (cost=3012833.67..3117860.77 rows=46511 > > width=4) > > > > Hash Cond: (os.order_status_history_id = > > osh.order_status_history_id) > > > > > > > > -> Seq Scan on tblpuorderstatus os > > (cost=0.00..96498.46 rows=11185486 width=8) > > > > -> Hash (cost=3010979.77..3010979.77 > > rows=529686 > > width=4) > > > > -> Gather (cost=1000.00..3010979.77 > > rows=529686 width=4) > > > > Workers Planned: 2 > > > > -> Parallel Seq Scan on > > tblpuorderstatushistory osh (cost=0.00..2957011.17 rows=220702 > > width=4) > > > > > > > > Filter: ((cancelled_date IS > > NULL) AND (cc_accept_date IS NOT NULL) AND (vip_order_type = 17)) > > > > > > > > -> Index Scan using tblcnpatientordermap_pkey on > > tblcnpatientordermap po (cost=0.09..0.41 rows=1 width=8) > > > > > > > > Index Cond: (vip_order_id = os.vip_order_id) > > > > > > > > -> Nested Loop Semi Join (cost=0.17..1.02 rows=1 width=4) > > > > -> Index Scan using tblcndoctorpatientmap_pkey on > > tblcndoctorpatientmap d (cost=0.09..0.39 rows=1 width=8) > > > > Index Cond: (vip_patient_id = po.vip_patient_id) > > > > -> Index Scan using tblcnaccounts_pkey on > > tblcnaccounts a (cost=0.08..0.36 rows=1 width=4) > > > > Index Cond: (master_user_id = d.master_user_id) > > > > Filter: ((user_name)::text = 'dddddd'::text) > > > > (19 rows) > > > > > > > > > > > > Regards, > > > > ravi > > > > > -- > Adrian Klaver > adrian.klaver@aklaver.com > > > -- > Sent via pgsql-general mailing list (pgsql-general@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-general > >I am not sure whether they are doing the vacuum after the upgrade or not So just run an ANALYZE on the database! -- *Melvin Davidson* I reserve the right to fantasize. Whether or not you wish to share my fantasy is entirely up to you. --001a114b2ea0e2cf090546500d11 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


On Tue, Jan 17, 2017 at 3:12 PM, Ravi Tammineni <<= a href=3D"mailto:rtammineni@partner.aligntech.com" target=3D"_blank">rtammi= neni@partner.aligntech.com> wrote:
Hi Adrain,

We have deployed our databases in Heroku and we have followed the upgrade o= ption that they have provided to us. Here is the command.

heroku pg:upgrade --app <app_name>

I am not sure whether they are doing the vacuum after the upgrade or= not. I have disabled the parallel execution; still execution plan is not c= orrect.

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 QUERY PLAN
-----------------------------------------------------------------= -------------------------------------------------------------- Aggregate=C2=A0 (cost=3D3391172.70..3391172.71 rows=3D1 width=3D8)
=C2=A0 =C2=A0->=C2=A0 Nested Loop Semi Join=C2=A0 (cost=3D3218963.06..33= 91149.45 rows=3D46513 width=3D0)
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0->=C2=A0 Nested Loop=C2=A0 (cost=3D3218962.89..3343428.74 rows= =3D46513 width=3D4)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0->=C2=A0 H= ash Join=C2=A0 (cost=3D3218962.80..3323993.25 rows=3D46513 width=3D4)
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Hash Cond: (os.order_st= atus_history_id =3D osh.order_status_history_id)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0->=C2=A0 Seq Scan on tblpuorderstatus os=C2=A0 (cost=3D0.00..9= 6501.53 rows=3D11185842 width=3D8)
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0->=C2=A0 Hash=C2=A0 = (cost=3D3217108.89..3217108.89 rows=3D529689 width=3D4)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0->=C2=A0 Seq Scan on tblpuorderstatushist= ory osh=C2=A0 (cost=3D0.00..3217108.89 rows=3D529689 width=3D4)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Filter: ((can= celled_date IS NULL) AND (cc_accept_date IS NOT NULL) AND (vip_order_type = =3D 17))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0->=C2=A0 Index Sc= an using tblcnpatientordermap_pkey on tblcnpatientordermap po=C2=A0 (cost= =3D0.09..0.41 rows=3D1 width=3D8)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0Index Cond: (vip_order_id =3D os.vip_order_id)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0->=C2=A0 Nested Loop Semi Join=C2=A0 (= cost=3D0.17..1.02 rows=3D1 width=3D4)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0->=C2=A0 Index Sc= an using tblcndoctorpatientmap_pkey on tblcndoctorpatientmap d=C2=A0 (cost= =3D0.09..0.39 rows=3D1 width=3D8)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0Index Cond: (vip_patient_id =3D po.vip_patient_id)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0->=C2=A0 Index Sc= an using tblcnaccounts_pkey on tblcnaccounts a=C2=A0 (cost=3D0.08..0.36 row= s=3D1 width=3D4)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0Index Cond: (master_user_id =3D d.master_user_id)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0Filter: ((user_name)::text =3D 'rdoyleda'= ;::text)
(17 rows)

Thanks
ravi



-----Original Message-----
From: Adrian Klaver [mailto:adrian.klaver@aklaver.com]
Sent: Tuesday, January 17, 2017 11:42 AM
To: Ravi Tammineni <rtammineni@partner.aligntech.com>; pgsql-admin@postgresq= l.org; pgsql-general@postgresql.org; pgadmin-support@postgresql.org
Subject: Re: [GENERAL] Queries are taking way longer in 9.6 than 9.5

On 01/17/2017 11:31 AM, Ravi Tamminen= i wrote:
> Hi,
>
>
>
> We have recently upgraded to 9.6 and few queries are performing very > poorly. Query execution time has increased more 4 or 5 times in 9.6. > Qeruy execution plan is also completely changed. I am not sure whether=
> its because of Parallel feature or any bug in 9.6. There are few
> similar kind of queries and all of them are taking more time in 9.6.
How did you upgrade from 9.5 --> 9.6?

Did you run ANALYZE on the tables after the upgrade?

Tend to doubt parallel query is at issue here, as it is turned off by
default:

https://www.postgresql.org/docs/9.6/static/runtime-config-= resource.html#GUC-MAX-PARALLEL-WORKERS-PER-GATHER

For more info:

https://www.postgresql.org/docs/9= .6/static/parallel-query.html
>
>
>
> Following query is taking 70ms in 9.5 and the same query is taking 2 > minutes in 9.6. Execution plan is totally different in 9.6 and seems > like there is a major flaw while generating the execution plan.
> Instead of filtering the low cardinality, its filtering from biggest t= able.
> Somehow nested loop joins are screwed up.
>
>
>
>
>
> I really appreciate your help.
>
>
>
> explain analyze
>
> SELECT count(*)
>
> FROM
>
>=C2=A0 =C2=A0 =C2=A0tblCnPatientOrderMap po
>
>=C2=A0 =C2=A0 =C2=A0JOIN tblPuOrderStatus os ON po.vip_order_id =3D os.= vip_order_id
>
>=C2=A0 =C2=A0 =C2=A0JOIN tblPuOrderStatusHistory osh ON os.order_status= _history_id =3D
> osh.order_status_history_id
>
> WHERE
>
>=C2=A0 =C2=A0 =C2=A0exists(SELECT 1
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 FROM
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 tblCnDoctorPati= entMap d
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 WHERE d.vip_patient_id =3D po= .vip_patient_id
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 AND exis= ts(SELECT 1
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0FROM
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0tblCnAccounts a
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0WHERE a.master_user_id =3D d.master_user_= id
> AND
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0a.user_name =3D '= ;dddddd'))
>
>=C2=A0 =C2=A0 =C2=A0AND osh.vip_order_type IN (17)--assist
>
>=C2=A0 =C2=A0 =C2=A0--AND osh.tx_submit_date IS NOT NULL
>
>=C2=A0 =C2=A0 =C2=A0AND osh.cancelled_date IS NULL
>
>=C2=A0 =C2=A0 =C2=A0AND osh.cc_accept_date IS NOT NULL;
>
>
>
>
>
> ##########################=C2=A0 9.5 Execution plan
>
>
>
>
> QUERY PLAN
>
> ------------------------------------------------------------= ----------
> ------------------------------------------------------------= ----------
> ---------
>
> Aggregate=C2=A0 (cost=3D1177.25..1177.26 rows=3D1 width=3D0)
>
>=C2=A0 =C2=A0 ->=C2=A0 Nested Loop=C2=A0 (cost=3D67.83..1177.25 rows= =3D5 width=3D0)
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ->=C2=A0 Nested Loop=C2=A0 (cost= =3D67.71..254.81 rows=3D1322 width=3D4)
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ->=C2=A0 Nes= ted Loop=C2=A0 (cost=3D67.63..104.45 rows=3D1322 width=3D4)
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 ->=C2=A0 HashAggregate=C2=A0 (cost=3D67.54..68.12 rows=3D192
> width=3D4)
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 Group Key: d.vip_patient_id
>
>
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 ->=C2=A0 Nested Loop=C2=A0 (cost=3D0.17..67.= 44 rows=3D192
> width=3D4)
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ->=C2=A0 Index Scan usi= ng unq_user_name on
> tblcnaccounts a=C2=A0 (cost=3D0.08..4.09 rows=3D1 width=3D4)
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Index= Cond: ((user_name)::text
> =3D
> 'dddddd'::text)
>
>
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ->=C2=A0 Index Only Sca= n using
> idx_tblcndoctorpatientmap on tblcndoctorpatientmap d
> (cost=3D0.09..62.78
> rows=3D192 width=3D8)
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Index= Cond: (master_user_id =3D
> a.master_user_id)
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 ->=C2=A0 Index Scan using idx_tblcnpatientordermap on
> tblcnpatientordermap po=C2=A0 (cost=3D0.09..0.17 rows=3D7 width=3D8) >
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 Index Cond: (vip_patient_id =3D
> d.vip_patient_id)
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ->=C2=A0 Ind= ex Scan using tblpuorderstatus_pkey on
> tblpuorderstatus os=C2=A0 (cost=3D0.09..0.11 rows=3D1 width=3D8)
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 Index Cond: (vip_order_id =3D po.vip_order_id)
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ->=C2=A0 Index Scan using tblpuor= derstatushistory_pkey on
> tblpuorderstatushistory osh=C2=A0 (cost=3D0.11..0.69 rows=3D1 width=3D= 4)
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Index Cond: (or= der_status_history_id =3D
> os.order_status_history_id)
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Filter: ((cance= lled_date IS NULL) AND (cc_accept_date
> IS NOT NULL) AND (vip_order_type =3D 17))
>
>
>
> ############################################################= ##########
> ############################################################= ###
>
>
>
> ##########################=C2=A0 9.6 Execution plan
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Q= UERY
> PLAN
>
> ------------------------------------------------------------= ----------
> ------------------------------------------------------------= ---
>
> Aggregate=C2=A0 (cost=3D3185034.17..3185034.17 rows=3D1 width=3D8)
>
>=C2=A0 =C2=A0 ->=C2=A0 Nested Loop Semi Join=C2=A0 (cost=3D3012833.9= 2..3185010.91 rows=3D46511
> width=3D0)
>
>
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ->=C2=A0 Nested Loop=C2=A0 (cost= =3D3012833.75..3137291.51 rows=3D46511
> width=3D4)
>
>
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ->=C2=A0 Has= h Join=C2=A0 (cost=3D3012833.67..3117860.77 rows=3D46511
> width=3D4)
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 Hash Cond: (os.order_status_history_id =3D
> osh.order_status_history_id)
>
>
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 ->=C2=A0 Seq Scan on tblpuorderstatus os
> (cost=3D0.00..96498.46 rows=3D11185486 width=3D8)
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 ->=C2=A0 Hash=C2=A0 (cost=3D3010979.77..3010979.77
> rows=3D529686
> width=3D4)
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 ->=C2=A0 Gather=C2=A0 (cost=3D1000.00..30109= 79.77
> rows=3D529686 width=3D4)
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Workers Planned: 2
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ->=C2=A0 Parallel Seq S= can on
> tblpuorderstatushistory osh=C2=A0 (cost=3D0.00..2957011.17 rows=3D2207= 02
> width=3D4)
>
>
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Filte= r: ((cancelled_date IS
> NULL) AND (cc_accept_date IS NOT NULL) AND (vip_order_type =3D 17)) >
>
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ->=C2=A0 Ind= ex Scan using tblcnpatientordermap_pkey on
> tblcnpatientordermap po=C2=A0 (cost=3D0.09..0.41 rows=3D1 width=3D8) >
>
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 Index Cond: (vip_order_id =3D os.vip_order_id)
>
>
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ->=C2=A0 Nested Loop Semi Join=C2= =A0 (cost=3D0.17..1.02 rows=3D1 width=3D4)
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ->=C2=A0 Ind= ex Scan using tblcndoctorpatientmap_pkey on
> tblcndoctorpatientmap d=C2=A0 (cost=3D0.09..0.39 rows=3D1 width=3D8) >
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 Index Cond: (vip_patient_id =3D po.vip_patient_id)
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ->=C2=A0 Ind= ex Scan using tblcnaccounts_pkey on
> tblcnaccounts a=C2=A0 (cost=3D0.08..0.36 rows=3D1 width=3D4)
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 Index Cond: (master_user_id =3D d.master_user_id)
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 Filter: ((user_name)::text =3D 'dddddd'::text)
>
> (19 rows)
>
>
>
>
>
> Regards,
>
> ravi
>


--
Adrian Klaver
adrian.klave= r@aklaver.com


--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-genera= l

>I am not sure whether they are doing= the vacuum after the upgrade or not
So= just run an ANALYZE on the database!




--
Melvin Davidson
I res= erve the right to fantasize.=C2=A0 Whether or not you
wish to share my= fantasy is entirely up to you.
--001a114b2ea0e2cf090546500d11--