analyze causes query planner to choose suboptimal plan for a select query in separate transaction

2019-04-25 Thread Martin Kováčik
rows=1 width=8) (actual time=0.003..0.057 rows=1000 loops=100900) -> Seq Scan on a a8 (cost=0.00..5.00 rows=1 width=8) (actual time=0.003..0.057 rows=1000 loops=100900) Planning Time: 0.522 ms Execution Time: 81483.797 ms (36 rows) What do you think, is this intended behavior or a potential bug ? Regards, Martin *Martin Kováčik* *CEO* *redByte*, s.r.o. +421 904 236 791 kova...@redbyte.eu, www.redbyte.eu <http://redbyte.eu>

Re: analyze causes query planner to choose suboptimal plan for a select query in separate transaction

2019-04-25 Thread Martin Kováčik
rwise fine select query. I was puzzled by this behavior back then but now it makes sense. *Martin Kováčik* *CEO* *redByte*, s.r.o. +421 904 236 791 kova...@redbyte.eu, www.redbyte.eu <http://redbyte.eu> On Thu, Apr 25, 2019 at 5:26 PM Michael Lewis wrote: > I assume it is in the docume

Re: analyze causes query planner to choose suboptimal plan for a select query in separate transaction

2019-04-25 Thread Martin Kováčik
ooses wrong plans. *Martin Kováčik* *CEO* *redByte*, s.r.o. +421 904 236 791 kova...@redbyte.eu, www.redbyte.eu <http://redbyte.eu> On Thu, Apr 25, 2019 at 9:28 PM Michael Lewis wrote: > > > On Thu, Apr 25, 2019, 11:34 AM Martin Kováčik wrote: > >> Turning off autova

Re: analyze causes query planner to choose suboptimal plan for a select query in separate transaction

2019-04-25 Thread Martin Kováčik
my own analyze after bulk insert as you suggested. Initially I thought that inside a transaction stats are automatically updated after the inserts because the query ran much faster than the query which was based on statistics with no rows. I did not realize the planner chooses a "default" pla

Re: analyze causes query planner to choose suboptimal plan for a select query in separate transaction

2019-04-25 Thread Martin Kováčik
ion was it is isolated like other statements. *Martin Kováčik* *CEO* *redByte*, s.r.o. +421 904 236 791 kova...@redbyte.eu, www.redbyte.eu <http://redbyte.eu> On Thu, Apr 25, 2019 at 9:58 PM Adrian Klaver wrote: > On 4/25/19 12:47 PM, Martin Kováčik wrote: > > As my example shows y

Re: analyze causes query planner to choose suboptimal plan for a select query in separate transaction

2019-04-25 Thread Martin Kováčik
I’ve got it now, thank you for the clarification. You are right. Martin Kováčik +421904236791 > On 26 Apr 2019, at 00:25, Adrian Klaver wrote: > >> On 4/25/19 1:28 PM, Martin Kováčik wrote: >> I'm not sure if I understand what you mean. My initial thought was that