I am not a MySQL expert, but it looks like the primary keys of MySQL are clustered - you want to make sure the case with your primary keys; clustered indexes will definitely help speed up the process.
One thing, however - I do not believe that you can have two "primary" keys on any table; for this reason, the table of your URLs looks rather suspicious. First of all, you need to make sure that these two columns in the table of URLs are indexed by the handle - for each of them there must be one index index, because you join them, so the DBMS must know how to quickly find them; this may be what happens in your case. If you look at full tables that have many rows, then yes, you could sit there for a while while the server tries to find everything that you requested.
I also suggest removing this CONCAT function from the select statement and see how this affects your results. I would be amazed if this were not some factor. Just extract both columns and handle the concatenation later, and see how this happens.
Finally, do you understand where the bottleneck is? A simple connection to three tables with several million rows should not take a lot of time (I would expect, maybe, a second or so, just looking through your tables and query) if the tables are correctly indexed. But if you click these lines on a slow or already attached network adapter, on an application server with a puzzle, etc., then slowness may not have anything to do with your request, but instead of what happens after the request. Seven million rows is quite a lot of data that needs to be collected and moved, no matter how long these rows are searched for. Try to select only one line instead of seven million, and see how it looks the other way around. If itβs fast, then the problem is not the query, this is the result.
Chris nunciato
source share