Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Senior Coder
    Join Date
    Jun 2008
    Location
    Cornwall
    Posts
    2,099
    Thanks
    297
    Thanked 12 Times in 12 Posts

    Unhappy query takes too long to execute can anyone help?

    Hi All

    this query
    PHP Code:
    SELECT cdIDcdNamecdThumbIMGcdThumbHeightcdThumbWidthcdRRPcdBinding 
    FROM tbl_cds 
    WHERE cdBinding 
    '$cSect' && cdReleaseDate <= now() 
    ORDER BY cdReleaseDate DESC
    LIMIT 3 
    takes approx 3.343secs to execute, thats not to bad i hear you say but this query is inside a loop and is ran 3 times on my page for 3 different cSects so thats 10 secs in total just for this query alone

    now the table has 73000 rows in it and its the order by which is causing the slowness without that line it takes approx 0.0754secs to execute, big difference, if i can speed up this query at all, would lead to massive improvments on my pages load speed

    many thanks
    Luke

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,561
    Thanks
    80
    Thanked 4,496 Times in 4,460 Posts
    Add an index on the cdReleaseDate field.

    Presto.

  • #3
    Senior Coder
    Join Date
    Jun 2008
    Location
    Cornwall
    Posts
    2,099
    Thanks
    297
    Thanked 12 Times in 12 Posts
    sweet thanks will give it a go

    cheers mate


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •