Re: Postgres views cannot use both union and join/where

2021-10-19 Thread David G. Johnston
On Tuesday, October 19, 2021, Michael Lewis wrote: > On Tue, Oct 19, 2021 at 3:48 PM Mithran Kulasekaran < > mithranakulaseka...@gmail.com> wrote: > >> create view template_view (id, name, description, is_staged) as >> select t.id,t.name, t.description, false as is_staged >> from template t >>

Re: Postgres views cannot use both union and join/where

2021-10-19 Thread Michael Lewis
On Tue, Oct 19, 2021 at 3:48 PM Mithran Kulasekaran < mithranakulaseka...@gmail.com> wrote: > create view template_view (id, name, description, is_staged) as > select t.id,t.name, t.description, false as is_staged > from template t > left join template_staging ts on t.name = ts.name and

Re: Postgres views cannot use both union and join/where

2021-10-19 Thread Benedict Holland
I thought a union mashed together two queries. The where clause can appear in both. But the execution plan will almost certainly run the first query and the second query. It should throw an error if the types don't match or the number of columns don't match. There are so few use cases for unions t

Re: Postgres views cannot use both union and join/where

2021-10-19 Thread David G. Johnston
On Tue, Oct 19, 2021 at 2:48 PM Mithran Kulasekaran < mithranakulaseka...@gmail.com> wrote: > i think the only problem is when we try to use both union and where/join > the issue starts to happen > I'm unconvinced this is actually an issue based upon what is presented here. All I'm seeing is two

Postgres views cannot use both union and join/where

2021-10-19 Thread Mithran Kulasekaran
Hi, We are trying to use the postgres view to accommodate some of the complex workflow related operations, we perform we saw like using union in a where clause inside a view actually pushed the where clause to both subqueries and we get good performance using the index , but when used in a join it

Re: Query out of memory

2021-10-19 Thread aditya desai
Thanks Michael. I will check this further. On Tue, Oct 19, 2021 at 7:09 PM Michael Lewis wrote: > Check explain plan, change work mem to 100MBs and then check explain plan > again. If it changed, then try explain analyze. > > Work mem is limit is used per node in the plan, so especially with > p

Re: Query out of memory

2021-10-19 Thread Michael Lewis
Check explain plan, change work mem to 100MBs and then check explain plan again. If it changed, then try explain analyze. Work mem is limit is used per node in the plan, so especially with partitioned tables, that limit is way too high.

Sv: Fwd: Query out of memory

2021-10-19 Thread Andreas Joseph Krogh
På tirsdag 19. oktober 2021 kl. 07:58:46, skrev aditya desai < admad...@gmail.com >: Sending to a performance group instead of PLPGSQL. . . Hi, I am running the below query. Table has 21 million records. I get an Out Of Memory error after a while.(from both pgadmi

Re: Query out of memory

2021-10-19 Thread aditya desai
Hi Justin, Out of memory on pgadmin and psql. I executed it with explain analyze. Still going out of memory. Also currently 250 user connections are not being made. There are hardly 10 connections to database. When I run thi query it is going out of memory. Also this query is part of a view that

Re: Fwd: Query out of memory

2021-10-19 Thread Justin Pryzby
On Tue, Oct 19, 2021 at 11:28:46AM +0530, aditya desai wrote: > 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 Is the out of memory error on the client side ? Then you've simply returned more

Re: Query out of memory

2021-10-19 Thread Dave Cramer
On Tue, 19 Oct 2021 at 05:54, Adam Brusselback wrote: > That work_mem value could be way too high depending on how much ram your > server has...which would be a very important bit of information to help > figure this out. Also, what Postgres / OS versions? > WORK_MEM is definitely too high. With

Re: Query out of memory

2021-10-19 Thread Adam Brusselback
That work_mem value could be way too high depending on how much ram your server has...which would be a very important bit of information to help figure this out. Also, what Postgres / OS versions?