Re: [GENERAL] Plan changes from index scan to seq scan after 5 executions

2017-09-30 Thread Tom Lane
Alexander Kukushkin writes: > Original problem has been found on 9.4.9, but I was able to reproduce it on > 10rc1. The problem here is that the generic estimate of the selectivity of "where value = $1" is 1.0, because var_eq_non_const makes the not unreasonable assumption

Re: [GENERAL] Plan changes from index scan to seq scan after 5 executions

2017-09-30 Thread Alexander Kukushkin
Hi David, sorry, absolutely forgot about important stuff like version. Original problem has been found on 9.4.9, but I was able to reproduce it on 10rc1. localhost/postgres=# select version(); version

Re: [GENERAL] Plan changes from index scan to seq scan after 5 executions

2017-09-30 Thread David G. Johnston
On Sat, Sep 30, 2017 at 10:57 AM, Alexander Kukushkin wrote: > Hi, > > Recently I've been investigating a strange behavior of one stored > procedure. > Please provide the output of: SELECT version(); David J. ​

[GENERAL] Plan changes from index scan to seq scan after 5 executions

2017-09-30 Thread Alexander Kukushkin
Hi, Recently I've been investigating a strange behavior of one stored procedure. According to the statistics its execution time was very high (15 seconds), but if I run the same statement from console it was very fast, just a few milliseconds. At the end I was able to prepare a short script,

Re: [GENERAL] Best way to allow column to initially be null?

2017-09-30 Thread Glen Huang
Good to know I’m not doing something stupid. Thanks. > On 30 Sep 2017, at 8:51 PM, Berend Tober wrote: > > Glen Huang wrote: > > I’m trying to make a column have these properties: > > > > 1. When a row is inserted, this column is allowed to be null. 2. When the > > row is

Re: [GENERAL] Best way to allow column to initially be null?

2017-09-30 Thread Berend Tober
Glen Huang wrote: > I’m trying to make a column have these properties: > > 1. When a row is inserted, this column is allowed to be null. 2. When the row is updated, no null > can be assigned to it this column. > > I initially thought I can drop the not null constraint before insertion and turn

[GENERAL] Best way to allow column to initially be null?

2017-09-30 Thread Glen Huang
Hi, I’m trying to make a column have these properties: 1. When a row is inserted, this column is allowed to be null. 2. When the row is updated, no null can be assigned to it this column. I initially thought I can drop the not null constraint before insertion and turn it back on after that,