Hi all, I need to optimize a query in MySQL i am retrieving a set a records from the database and populating in a grid view...but it takes around 45 sec for the grid view to be populated...This is my query:
SELECT Distinct
vc.VideoCategoryId,
video.Id as VideoId,
video.VideoTitle as Title,
video.ArticleAbstract as Description,
(video.videostatus) as Rating,
video.Duration,
video.Keywords,
video.ViewCount as ViewCount,
vc.categoryid,
video.VideoFileName as VideoFilename,
video.ImageFile as ThumbImage,
video.schoolid,
video.price,
video.password,
video.isSiteDefault,
video.otherfilename ,
vc.isapprove ,
video.isdefault,
vc.userid ,
video.IsPPV,
video.startdate,
video.enddate,
vc.approverid ,
video.UpLoadedDate,
video.LastUpdatedDate,
video.isdeleted,
video.roleid,
c.categoryname as CategoryName,
video.AutoPlay,
video.IsPrivate
from video
left outer join videocategory vc on vc.videoid = video.id
left outer join Category c on C.CategoryId=vc.categoryId
inner join categoryowner co on co.categoryid = c.categoryid
inner join user u on u.id = vc.UserID
where
case #UploadedBy# when 2 then
co.ownerid=#CategoryOwnerID#
and video.schoolid=#SchoolId#
and c.schoolid=#SchoolId#
and vc.isDeleted=0 and ( video.istranscoded=2 || video.istranscoded=0 )
else
video.schoolid=#SchoolId#
and c.schoolid=#SchoolId#
and vc.isDeleted=0 and ( video.istranscoded=2 || video.istranscoded=0 )
end
order by UpLoadedDate desc,isDefault desc,vc.isapprove asc;
Can any one pls help me optimizing this query and improve the performance of the application.....