I currently have 2 tables, one is idtracker which has around 30,000 rows and the other is download_tracker that has around 150,000 rows. I am writing an SQL query that compares the uuid and pluginId column in the two tables and returns the matches that were found. Here is what I currently have :
SELECT idtracker.uuid
FROM idtracker, download_tracker
WHERE idtracker.uuid = download_tracker.pluginId
The issue is that this command pretty much shuts down my apache server when I try to run it. I’m guessing the reason for this is that there are so many rows and comparing each one to every row in the opposite table takes a lot of time. Is there any way to try to work around this and get the same results, or is there just no way to compare columns in tables once they have gotten this big.
Also all that I really need is the count so I have tried using the COUNT (DISTINCT …) and that did not seem to help out the timing.
That is not a lot of data and it shouldn’t shut down your server. It should return in seconds.
Try adding indexes on both tables: