Re: using sequential scan instead of index for join with a union

2019-05-17 Thread Kent Tong
Hi, Sergei Thanks! I've just double checked and they are the same: \d notice id | bigint | | not null | nextval('notice_id_seq'::regclass) mbct_id| bigint | | | \d news id | bigint

Re: using sequential scan instead of index for join with a union

2019-05-17 Thread Sergei Kornilov
Hi Please check datatypes in union all part. Possible, notice.id or notice.mbct_id datatypes does not match with other tables. regards, Sergei

using sequential scan instead of index for join with a union

2019-05-17 Thread Kent Tong
Hi, I am joining the union of three tables with another table. Postgresql uses the index when only two tables are in the union. If I add one more table to the union, it switches to seq scan. Apparently it also uses the index when only one table is joined. The SQL is: select * from ( SELECT 'NEWS'