Hey @jimsafley
So I ran them both directly in mysql and the discrepancy is there as well, with item taking about 0.3 second and media taking 3.6 seconds.
Just so I’m doing everything right. Here are the 2 queries:
Item
SELECT
r0_.id AS id_0,
r0_.title AS title_1,
r0_.is_public AS is_public_2,
r0_.created AS created_3,
r0_.modified AS modified_4,
r0_.resource_type AS resource_type_5,
r0_.owner_id AS owner_id_6,
r0_.resource_class_id AS resource_class_id_7,
r0_.resource_template_id AS resource_template_id_8,
r0_.thumbnail_id AS thumbnail_id_9
FROM
item i1_
INNER JOIN resource r0_ ON
i1_.id = r0_.id
LEFT JOIN `value` v2_ ON
r0_.id = v2_.resource_id AND(v2_.property_id = 10)
WHERE
(
v2_.value_resource_id IN(
SELECT
r3_.id
FROM
resource r3_
LEFT JOIN item i4_ ON
r3_.id = i4_.id
LEFT JOIN item_set i5_ ON
r3_.id = i5_.id
LEFT JOIN value_annotation v6_ ON
r3_.id = v6_.id
LEFT JOIN media m7_ ON
r3_.id = m7_.id
WHERE
r3_.title = "US.NN.FIT.SC.362.1.1.262.19410303"
) OR v2_.`value` = "US.NN.FIT.SC.362.1.1.262.19410303" OR v2_.uri = "US.NN.FIT.SC.362.1.1.262.19410303"
)
GROUP BY
r0_.id
ORDER BY
r0_.id ASC
LIMIT 1
Media
SELECT
r0_.id AS id_0,
r0_.title AS title_1,
r0_.is_public AS is_public_2,
r0_.created AS created_3,
r0_.modified AS modified_4,
m1_.ingester AS ingester_5,
m1_.renderer AS renderer_6,
m1_.data AS data_7,
m1_.source AS source_8,
m1_.media_type AS media_type_9,
m1_.storage_id AS storage_id_10,
m1_.extension AS extension_11,
m1_.sha256 AS sha256_12,
m1_.size AS size_13,
m1_.has_original AS has_original_14,
m1_.has_thumbnails AS has_thumbnails_15,
m1_.position AS position_16,
m1_.lang AS lang_17,
m1_.alt_text AS alt_text_18,
r0_.resource_type AS resource_type_19,
r0_.owner_id AS owner_id_20,
r0_.resource_class_id AS resource_class_id_21,
r0_.resource_template_id AS resource_template_id_22,
r0_.thumbnail_id AS thumbnail_id_23,
m1_.item_id AS item_id_24
FROM
media m1_
INNER JOIN resource r0_ ON
m1_.id = r0_.id
LEFT JOIN `value` v2_ ON
r0_.id = v2_.resource_id AND(v2_.property_id = 10)
WHERE
(
v2_.value_resource_id IN(
SELECT
r3_.id
FROM
resource r3_
LEFT JOIN item i4_ ON
r3_.id = i4_.id
LEFT JOIN item_set i5_ ON
r3_.id = i5_.id
LEFT JOIN value_annotation v6_ ON
r3_.id = v6_.id
LEFT JOIN media m7_ ON
r3_.id = m7_.id
WHERE
r3_.title = "US.NN.FIT.SC.362.1.1.262.19410303_008"
) OR v2_.`value` = "US.NN.FIT.SC.362.1.1.262.19410303_008" OR v2_.uri = "US.NN.FIT.SC.362.1.1.262.19410303_008"
)
GROUP BY
r0_.id
ORDER BY
r0_.id ASC
LIMIT 1
I ran the explain on both, but I don’t really know if I understand how to decipher it. One thing that jumped out at me is that in the first row for the Item explain it says that it uses the index but doesn’t say that for Media.
Interested to hear what you think—thanks!