Re: query plan using partial index expects a much larger number of rows than is possible

2020-10-29 Thread Michael Lewis
On Wed, Oct 28, 2020 at 5:30 PM Tom Lane wrote: > "Olivier Poquet" writes: > > Looking at it in more detail, I found that the planner is assuming that > I'll get millions of rows back even when I do a simple query that does an > index scan on my partial index: > > We don't look at partial-index

Re: query plan using partial index expects a much larger number of rows than is possible

2020-10-28 Thread Olivier Poquet
Thanks Tom, That makes perfect sense. I'd already gone the route of materializing the condition but I didn't even realize that generated columns was an option (I'd done the same with triggers instead). So thanks a lot of that too! -- Olivier Poquet opoq...@plumdev.com On Wed, Oct 28, 2

Re: query plan using partial index expects a much larger number of rows than is possible

2020-10-28 Thread Tom Lane
"Olivier Poquet" writes: > Looking at it in more detail, I found that the planner is assuming that I'll > get millions of rows back even when I do a simple query that does an index > scan on my partial index: We don't look at partial-index predicates when trying to estimate the selectivity of a

query plan using partial index expects a much larger number of rows than is possible

2020-10-28 Thread Olivier Poquet
Hello, I have a large table (about 13 million rows) full of customer order information. Since most of that information is for orders that have already been fulfilled, I have a partial index to help quickly zero in on rows that have not been fulfilled. This works well, but I noticed today when jo