Re: [PERFORM] Selectivity for lopsided foreign key columns

2015-12-17 Thread Mikkel Lauritsen
On 2015-12-17 16:23, Tom Lane wrote: Mikkel Lauritsen writes: The schema contains two tables, t1 and t2. t2 has two fields, an id and a tag, and it contains 146 rows that are unique. t1 has two fields, a value and a foreign key referring to t2.id, and it contains 266177 rows. The application

Re: [PERFORM] Selectivity for lopsided foreign key columns

2015-12-17 Thread Tom Lane
Mikkel Lauritsen writes: > The schema contains two tables, t1 and t2. > t2 has two fields, an id and a tag, and it contains 146 rows that are > unique. > t1 has two fields, a value and a foreign key referring to t2.id, and it > contains 266177 rows. > The application retrieves the rows in t1 tha

[PERFORM] Selectivity for lopsided foreign key columns

2015-12-17 Thread Mikkel Lauritsen
Hi all, I have an application that runs in production in multiple instances, and on one of these the performance of certain queries suddenly became truly abysmal. I basically know why, but I would much appreciate if I could obtain a deeper understanding of the selectivity function involved and