SELECT IN for a large set

In my web application, I want to find out which of the user's Twitter friends already exist on the system ... I am currently working on getting a list of Twitter IDs that the user executes (Twitter API returns 5000 IDs at a time) and execution:

SELECT userId FROM users WHERE userId IN (COMMA_SEPARATED_LIST_OF_IDs);

I don’t like this query, because as the user table grows, this may turn out to be a bottleneck. I don’t want to optimize too, prematurely, is there any other way I have to do this?

Update: I am using MySQL.

+3
source share
4 answers

Two approaches:

  • SELECT IN (expr) SELECT expr. .

  • .

+3

Twitter, . , , . API Twitter .

+2

, user.userId . , , . , COMMA_SEPARATED_LIST_OF_IDS ?

+1

EXISTS, Transact SQL. , EXISTS , SQL Server.

http://msdn.microsoft.com/en-us/library/ms188336.aspx

0

Source: https://habr.com/ru/post/1758044/


All Articles