Re: Optimising a two column OR check

2019-10-14 Thread Ivan Voras
On Sat, 12 Oct 2019 at 17:46, Andrew Gierth wrote: > > "MichaelDBA" == MichaelDBA writes: > > MichaelDBA> Nope, vacuumed it and still got the bitmap index scans. > > Let's see your explains. Here's mine: > > # set enable_seqscan=false; -- because I only have a few rows > SET > # insert in

Re: Optimising a two column OR check

2019-10-13 Thread Ivan Voras
On Sat, 12 Oct 2019 at 17:16, Andrew Gierth wrote: > >>>>> "Ivan" == Ivan Voras writes: > > Ivan> SELECT user1_id,user2_id FROM friend WHERE user1_id=42 OR > user2_id=42; > > To get friends of user 42: > > SELECT user1_id FROM friend

Optimising a two column OR check

2019-10-12 Thread Ivan Voras
Hello, There's a "users" table with the following structure: CREATE TABLE "user" ( id SERIAL PRIMARY KEY, -- other fields ); and there's a "friends" table with the following structure: CREATE TABLE friend ( user1_id INTEGER NOT NULL REFERENCES "user"(id), user2_id INTEGER NOT NULL REFERE