Page 2 of 2 FirstFirst 12
Results 16 to 17 of 17

Thread: Super-Slow SQL Queries Of Slowness.

  1. #16
    Join Date
    Sep 2004
    At the corner of WALK and DONT WALK
    Quote Originally Posted by NogDog View Post
    I have heard it said that 3 simple queries often can run as fast as one complex query that joins across them -- and sometimes even faster -- so it might be a good approach
    Yeah, the three simple queries would be:

    SELECT CONCAT(`set_num`,':',`line_num`) AS `line_id` FROM `ds_lines`;
      CONCAT(`set_num`,':',`line_num`) AS `line_id`, 
      CONCAT(`set_num`,':',`line_num`,'_',`categ_id`) AS `line_cat`, 
      FROM `ds_line_categs`
      FROM `ds_categories`
    And, like I said, I'd just use PHP to sort everything out.

    *Checks speeds.* First one ran in 0.02 secondss, second in 0.09 seconds, and the third in 0.02 seconds. Yeah, this is a tad faster.

    Quote Originally Posted by NogDog View Post
    (assuming refactoring the whole database design isn't an option ). Your mileage may vary.
    What do you mean by refactoring?

  2. #17
    Join Date
    Aug 2004
    "Refactoring" is just developer speak for "re-doing in a different way". I'm not saying I know what the different way would necessarily be, but the fact that (a) certain text values are showing up in multiple tables, and (b) we're having trouble coming up with a clean way of doing things (which may in part be ignorance on my part) would tend to suggest that some database reorganization and design might solve those problems. The downside is that any code that uses it would then have to adjust to the new design; so it might not be worth the effort.

    The fact that you have a hierarchy structure in your data (with parents and grandparents) already makes things a bit more complicated than many web site databases, and such hierarchy concerns have frustrated many of us in the past. (I came up with a solution for a client many years ago that had an open number of "generations", and which I eventually got to work -- but boy was it ugly. That was before I ever heard of "nested set" database designs, which if I'd used would have made it much cleaner. Of course, now I'd have to read up on it again, as I've pretty much forgotten all the details. )
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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