Re: Query out of memory - Mailing list pgsql-sql

From aditya desai
Subject Re: Query out of memory
Date
Msg-id CAN0SRDEV9+6Pee-ZqjkSFPU9NsHDSwVRCoQW+=XiCpXtLCKLqw@mail.gmail.com
Whole thread Raw
In response to Query out of memory  (aditya desai <admad123@gmail.com>)
List pgsql-sql
This is how I received a query from the App Team. They have migrated from Oracle to Postgres. I see in Oracle where it is working fine and also has the same joins. Some of the developers increased the work_mem. I will try and tone it down. Will get back to you. Thanks.

On Tue, Oct 19, 2021 at 1:28 AM Geri Wright <geri.w123@gmail.com> wrote:
Hi,
It looks like you have Cartesian joins in the query.   Try updating your where clause to include

And g.columnname = t.columnname 
And t.columnname2 = a.columnname2

On Mon, Oct 18, 2021, 12:43 PM aditya desai <admad123@gmail.com> wrote:
Hi,
I am running the below query. Table has 21 million records. I get an Out Of Memory error after a while.(from both pgadmin and psql). Can someone review DB parameters given below.

select t.*,g.column,a.column from
gk_staging g, transaction t,account a
where
g.accountcodeis not null AND
g.accountcode::text <> '' AND
length(g.accountcode)=13 AND
g.closeid::text=t.transactionid::text AND
subsrting(g.accountcode::text,8)=a.mask_code::text

Below are system parameters.
shared_buffers=3GB
work_mem=2GB
effective_cache_size=10GB
maintenance_work_mem=1GB
max_connections=250

I am unable to paste explain plan here due to security concerns.

Regards,
Aditya.

pgsql-sql by date:

Previous
From: Guillaume Lelarge
Date:
Subject: Re: Query out of memory
Next
From: Jian He
Date:
Subject: create a procedure based on column data change in postgrersql