Re: Efficiently searching for the most recent rows where a column matches any result from a different query

2018-02-15 Thread mkslaf
Hello Hellmuth, Thank you for your response. I've uploaded the query plan for the first query (user_id=2) here:  https://gist.github.com/anonymous/6d251b277ef71f8977b03cab91fedccdThe query plan for the second query (user_id=1) can be found here:  https://gist.github.com/anonymous/32ed485b40cce26

Efficiently searching for the most recent rows where a column matches any result from a different query

2018-02-13 Thread mkslaf
Hello, I have the following schema:     CREATE TABLE users (        id   BIGSERIAL PRIMARY KEY,        name TEXT      NOT NULL UNIQUE    );        CREATE TABLE friends (        user_id        BIGINT NOT NULL REFERENCES users,        friend_user_id BIGINT NOT NULL REFERENCES users,        UNIQUE