Re: Optimizing `WHERE x IN` query

2019-07-11 Thread Michael Lewis
Did you create a GIN index on subscriptions column to support the && operator?

Re: Optimizing `WHERE x IN` query

2019-07-11 Thread Omar Roth
> We had big performance issues with queries like that, and we modified > them to use && (see > https://www.postgresql.org/docs/current/functions-array.html ), > resulting in a big perf boost Much appreciated! Unfortunately I'm having trouble turning your suggestions into a working query. `cv

Re: Optimizing `WHERE x IN` query

2019-07-09 Thread Nicolas Charles
Le 07/07/2019 à 16:33, Thomas Kellerer a écrit : Omar Roth schrieb am 07.07.2019 um 15:43: Currently, the query I'm using to generate a user's feed is: ``` SELECT * FROM channel_videos WHERE ucid IN (SELECT unnest(subscriptions) FROM users WHERE email = $1) ORDER BY published DESC; ``` You

Re: Optimizing `WHERE x IN` query

2019-07-09 Thread Omar Roth
The suggested query indeed appears to be faster. Thank you. > Did you try if a properly normalized model performs better? I've tested the below schema, which doesn't appear to perform much better but has a couple other advantages for my application: ``` create table subscriptions ( email te

Re: Optimizing `WHERE x IN` query

2019-07-07 Thread Thomas Kellerer
Omar Roth schrieb am 07.07.2019 um 15:43: Currently, the query I'm using to generate a user's feed is: ``` SELECT * FROM channel_videos WHERE ucid IN (SELECT unnest(subscriptions) FROM users WHERE email = $1) ORDER BY published DESC; ``` You could try an EXISTS query without unnest: select cv