Re: Bad query plan decision when using multiple column index - postgresql uses only first column then filters

2020-01-16 Thread Cosmin Prund
be able to reproduce this on a backup of the database so I can safely experiment. Until I manage to reproduce this I don't think I can make any more progress, so thank you everyone for the help. On Thu, 16 Jan 2020 at 20:55, Tom Lane wrote: > Cosmin Prund writes: > > Running the same qu

Re: Bad query plan decision when using multiple column index - postgresql uses only first column then filters

2020-01-16 Thread Cosmin Prund
On Thu, 16 Jan 2020 at 20:20, Laurenz Albe wrote: > Well, what should the poor thing do? > There is no index on "LucrareBugetDateId". > I did add an index on "LucrareBugetDateId" (before accidentally "fixing" the problem with ANALYZE) and it didn't help. > Rather, you have two indexes on ("Luc

Re: Bad query plan decision when using multiple column index - postgresql uses only first column then filters

2020-01-16 Thread Cosmin Prund
Hello Michael and hello again Tom, sorry for mailing you directly. I just hit Reply in gmail - I expected the emails to have a reply-to=Pgsql. Apparently they do not. Running the same query with a different "Ver" produces a proper plan. Here's a non-redacted example (Ver=91): EXPLAIN (ANALYZE, BU

Re: Bad query plan decision when using multiple column index - postgresql uses only first column then filters

2020-01-16 Thread Cosmin Prund
M pg_stats WHERE attname='LucrareBugetVersiuneId' AND tablename='LucrareBugetDate' ORDER BY 1 DESC; frac_mcv |tablename |attname | inherited | null_frac | n_distinct | n_mcv | n_hist | correlation --+------++---+---+--

Bad query plan decision when using multiple column index - postgresql uses only first column then filters

2020-01-16 Thread Cosmin Prund
Hello List, I'm Cosmin. This is my first post and I'll get right down to the problem. I'm using Postgresql 10 (because that's what's installed by default on Ubuntu 18.04): explain analyze select R, C, V from LBD where Ver = 92 and Id in (10,11) Index Scan using "IX_LBD_Ver_Id" on "LBD" (co