Re: Using CTE vs temporary tables

2018-07-11 Thread Adam Brusselback
One thing to note, if this is a query you would like to run on a replica, temp tables are a non-starter. I really wish that wasn't the case. I have quite a few analytical queries I had to optimize with temp tables and indexes, and I really wish I could run on my hot standby. I in most cases I can

Re: Using CTE vs temporary tables

2018-07-11 Thread David G. Johnston
On Wed, Jul 11, 2018 at 9:35 AM, Ravi Krishna wrote: > ​Does temp tables also suffer from optimization fence we see in CTE.​ > >> ​I suppose it depends on how they end up being referenced in the query. It is not possible for the auto-vacuum daemon to vacuum/analyze them so if you aren't doing th

Re: Using CTE vs temporary tables

2018-07-11 Thread Ravi Krishna
​Does temp tables also suffer from optimization fence we see in CTE.​ >

Re: Using CTE vs temporary tables

2018-07-11 Thread David G. Johnston
On Wed, Jul 11, 2018 at 9:30 AM, hmidi slim wrote: > Hi, > I have a big query that used about 15 cte and its execution time is > acceptable. I'm trying to optimize my query because it contains about 150 > lines of code and becomes hard to understand it and add new filter or > condition easily. >