Let's say I have this that produces 50,000 lines:
SELECT photoID FROM photoSearch WHERE photoID BETWEEN 1 AND 50000;
I was about to run this request with the photo id just returned.
SELECT COUNT(people) AS totalPeople, people FROM people INNER JOIN photopeople ON photoPeople.peopleID = people.PeopleID WHERE photoid IN ('ID from results') GROUP BY people ORDER BY totalPeople DESC
But I understand from others and resources that the IN clause will not work well, especially since I can have 100,000 plus photo IDs.
Is it good to store the photo ID from the top query in another table (resultsTbl) or in a very long row? If so, either am I using a join or subselect to request these IDs (in the bottom query) instead of using IN? Or ... is there any other way that will do the job considering performance?
Any help on this would be greatly appreciated.
source share