Skip to main content
July 24, 2008
Question

Query Optimization

  • July 24, 2008
  • 8 replies
  • 490 views
Hello~

I have a page that is running off of a fairly large database (5000 or so records), and all of this code works, but it is pretty slow. I was wondering if anyone could give me some tips on how to speed it up? Thanks!
    This topic has been closed for replies.

    8 replies

    July 30, 2008
    This is perfect, thank you so much!
    Inspiring
    July 29, 2008
    sql to create a column with only the 1st letter is db specific, but this syntax works with at least a couple of them.

    select substr(fieldname, 1, 1) as firstletter
    July 29, 2008
    OK, here is what I came up with, using loops again. This definitely works, and I am pretty happy with it, but any further suggestions are always welcome. Thanks everyone!

    KC
    July 29, 2008
    Could you maybe show some examples of how to do any of these options? I did something very simple, added <a name="#Left(lName, 1)#"> next to the looped <li>, but that adds an anchor to every single outputted link, and I have no way to separate the groups of links, or add back to top buttons. Thanks!
    Inspiring
    July 25, 2008
    I can think of a couple of ideas.

    One: You could do some SQL that would create a column with the the
    letters in it for your output.

    Two: You could do something using the left(string,1) function in your
    current loop.

    Three: You could do something a bit like your original loop over a list
    of letters and use query-of-query or query array notation to break up
    the output.

    HTH
    Ian
    July 25, 2008
    OK, I think I've made a lot of progress! The only piece of code I can't figure out is how to put the alphabetical anchors into the outputted list of links. Any suggestions? Thanks!

    KC
    Inspiring
    July 24, 2008
    semi star gazer wrote:
    > Hello~
    >
    > I have a page that is running off of a fairly large database (5000 or so
    > records), and all of this code works, but it is pretty slow. I was wondering if
    > anyone could give me some tips on how to speed it up? Thanks!

    Enable debugging and run this page. Look at the debugging information
    paying close attention what on the page is taking the time to run.

    HINT: I guarantee this page could be sped up considerable running one
    query rather then who knows how many it currently does.

    A couple of helpful topics to look up. Joining tables and the group
    attribute of the <cfoutput...> tag.
    Inspiring
    July 24, 2008
    semi star gazer wrote:
    > Hello~
    >
    > I have a page that is running off of a fairly large database (5000 or so
    > records), and all of this code works, but it is pretty slow. I was wondering if
    > anyone could give me some tips on how to speed it up? Thanks!

    Enable debugging and run this page. Look at the debugging information
    paying close attention what on the page is taking the time to run.

    HINT: I guarantee this page could be sped up considerable running one
    query rather then who knows how many it currently does.

    A couple of helpful topics to look up. Joining tables and the group
    attribute of the <cfoutput...> tag.
    Inspiring
    July 24, 2008
    I only the part of your code that was visible without horizontal scrolling, and, based on that, don't do queries inside loops.

    If you don't know what the sql keyword "in" does, I have heard good things about the book, Teach Yourself SQL in 10 Minutes by Ben Forta.