0

I'm gonna need to match several ID's that aren't on my DB with ID values that are in my DB, something like:

SELECT ... WHERE idfield IN (123454, 12312312, 1223123, 12313123 ...., 99923412)

Can WHERE IN hold this many strings for matching? Sometimes I'm gonna match something like 200 IDs, other times, 600, as max as 2000 IDs.

Is there a better way to do it? Im really worried about memory and speed.

EDIT: Ok, one of my questions was answered, there are no limits to the WHERE IN and the query will be faster if the field I'm matching with is indexed. (MySQL IN condition limit)

But, I'm also looking for alternatives here, so if anyone have another technique on this match function, that would be great.

Community
  • 1
  • 1
Antonio Max
  • 8,627
  • 6
  • 43
  • 42
  • Possible duplicate of http://stackoverflow.com/questions/4275640/mysql-in-condition-limit - although one wonders why you're comparing a string of integers instead of using a simple join from somewhere. – Strawberry Dec 12 '13 at 14:37
  • @Strawberry I don't have the integer group CSV on my DB for matching. I'm taking this outside 200 id lists in CSV format and I must match with a column on my DB that may/may not have a match with this CSV – Antonio Max Dec 12 '13 at 14:52
  • Load ID values from CSV file into another table, then write a SELECT query to find differences. – Devart Dec 12 '13 at 14:55
  • @Devart is it faster to insert 2k ids in another table and write a JOIN than it is to compare using this CSV with a WHERE IN? Any references on this? – Antonio Max Dec 12 '13 at 14:58
  • 2k - is it a lot? No. About SELECT+JOIN - ID fields have to be indexed. – Devart Dec 12 '13 at 15:05

0 Answers0