Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eZDon-00025a-7c for pgsql-performance@arkaria.postgresql.org; Wed, 10 Jan 2018 10:41:13 +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 1eZDom-0008R4-PT for pgsql-performance@arkaria.postgresql.org; Wed, 10 Jan 2018 10:41:12 +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 1eZDom-0008Qu-IU for pgsql-performance@lists.postgresql.org; Wed, 10 Jan 2018 10:41:12 +0000 Received: from mx2.mailbox.org ([80.241.60.215]) by magus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1eZDoj-0005bt-Cm for pgsql-performance@postgresql.org; Wed, 10 Jan 2018 10:41:11 +0000 Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx2.mailbox.org (Postfix) with ESMTPS id 74A3441157; Wed, 10 Jan 2018 11:41:06 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter03.heinlein-hosting.de (spamfilter03.heinlein-hosting.de [80.241.56.117]) (amavisd-new, port 10030) with ESMTP id GhjSMIuV6tVo; Wed, 10 Jan 2018 11:41:05 +0100 (CET) Message-ID: <1515580864.2848.33.camel@cybertec.at> Subject: Re: View preformance oracle to postgresql From: Laurenz Albe To: "Reddygari, Pavan" , "pgsql-performance@postgresql.org" Date: Wed, 10 Jan 2018 11:41:04 +0100 In-Reply-To: <9909AFED-314C-4AFE-AF7F-77645E7FAA2F@amazon.com> References: <9909AFED-314C-4AFE-AF7F-77645E7FAA2F@amazon.com> Organization: Cybertec Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Pavan Reddygari wrote: > A view got converted to postgresql, performance while querying the view in postgresql is 10X longer compared to oracle. > Hardware resources are matching between oracle and postgresql. > > V_item_attributes view code as below, same in oracle and postgresql. > ------------------------------------------------------------------------------------- > SELECT a.iav_id, > a.iav_itm_id, > a.iav_iat_id, > a.iav_value, > a.iav_version, > a.iav_approved, > a.iav_create_date, > a.iav_created_by, > a.iav_modify_date, > a.iav_modified_by, > item_attribute.iat_id, > item_attribute.iat_name, > item_attribute.iat_type, > item_attribute.iat_status, > item_attribute.iat_requires_approval, > item_attribute.iat_multi_valued, > item_attribute.iat_inheritable, > item_attribute.iat_create_date, > item_attribute.iat_created_by, > item_attribute.iat_modify_date, > item_attribute.iat_modified_by, > item_attribute.iat_translated > FROM (item_attribute_value a > JOIN item_attribute ON ((a.iav_iat_id = item_attribute.iat_id))) > WHERE (a.iav_version = ( SELECT max(b.iav_version) AS max > FROM item_attribute_value b > WHERE ((b.iav_itm_id = a.iav_itm_id) AND (b.iav_iat_id = a.iav_iat_id)))); > > > Oracle is using push predicate of IAV_ITM_ID column wherever item_attribute_values table being used. > Any alternatives available to reduce view execution time in postgresql database or any hints, thoughts would be appreciated. If (iav_version, iav_itm_id, iav_iat_id) is unique, you could use SELECT DISTINCT ON (a.iav_itm_id, a.iav_iat_id) ... FROM item_attribute_value a JOIN item_attribute b ON ... ORDER BY a.iav_version DESC; Yours, Laurenz Albe