Re: View preformance oracle to postgresql - Mailing list pgsql-performance

From Merlin Moncure
Subject Re: View preformance oracle to postgresql
Date
Msg-id CAHyXU0ys9ZDpv91e5jZ64Br1rztBdYsaGjZ5Z_2=Zx5MqEbxUg@mail.gmail.com
Whole thread Raw
In response to View preformance oracle to postgresql  ("Reddygari, Pavan" <pkreddy@amazon.com>)
List pgsql-performance
On Tue, Jan 9, 2018 at 3:32 PM, Reddygari, Pavan <pkreddy@amazon.com> wrote:
>
> A view got converted to postgresql, performance while querying the view in postgresql is 10X longer compared to
oracle.
>
>    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))));

can you try rewriting the (more sanely formatted)
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
  );

to
FROM item_attribute_value a
JOIN item_attribute ON a.iav_iat_id = item_attribute.iat_id
JOIN
(
   SELECT max(b.iav_version) AS iav_version
   FROM item_attribute_value b
   GROUP BY iav_itm_id, iav_iat_id
) q USING (iav_itm_id, iav_iat_id, iav_version);

merlin


pgsql-performance by date:

Previous
From: Dinesh Chandra 12108
Date:
Subject: RE: Re: Unable to connect Postgres using psql while postgres is alreadyrunning.
Next
From: Igor Neyman
Date:
Subject: RE: PG 9.5 2 tables same DDL with diff size