I run a simple SELECT (noted below) in a stored procedure of a table that’s around 1,500 rows.
CREATE PROCEDURE `LoadCollectionItemProperty`(IN sId int(10))
BEGIN
SELECT *
FROM itemproperty
WHERE itemid IN
(SELECT itemid
FROM collectionitem
WHERE collectionid = sId AND removed ='0000-00-00 00:00:00');
END
This operation takes around 7 seconds. I inserted Breakpoints and used F11 to determine that upon MySqlAdapter.Fill is where the lag starts. Both my computer and the server hosting the MySQL database are NOT challenged spec wise. I’m guessing it’s the query itself.
collectionitem holds the 2 foreign keys linking an itemproperty to a collection. we feed the sproc sId(PK of collection) so that the subquery returns all the itemids from a specific collection and then we use the itemid(PK) in itemproperty.
Is there any way to speed up the process?
UPDATE
My issue was entirely due to improper indexing. Once I learned which columns to index, everything is extremely smooth! Thank you for your help.
You can try this, but it may not help much if your tables are missing indexes.