BTW, have you changed other codes to support gardens?
I did, many small optimization. but this one was the most disturbing problem.
select * from (
Manufacturer = (select count(*) from Manufacturer where PictureId=p.Id),
Product = (select count(*) from Product_Picture_Mapping where PictureId=p.Id),
ProductVariantAttributeValue = (select count(*) from ProductVariantAttributeValue where PictureId=p.Id),
Category = (select count(*) from Category where PictureId=p.Id),
Settings = (select count(*) from Setting where value=cast(p.Id as varchar(max)) and name like '%picture%id%')
--select column_name, table_name from information_schema.columns where column_name like '%picture%'
--select * from setting where name like'%picture%id%'