73 ms to 5000 ms jump in query for no reason?

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default 73 ms to 5000 ms jump in query for no reason?

    I have a table that connects entries by 2 categories category_id (cid) and
    associated_category_id (acid)

    so the first entry is cid = 1 and acid=0 then the next connected to that is
    cid=1 acid=2 and the next connected to that is cid=2 acid=3. So here is my
    issue. when I am getting information from the second tier i'll do WHERE
    tier2.category_id=1 and using left outer join, i can also get the infromation
    in the tier1 category. This query takes about 78 ms:

    (tier1=cat tier2=cat2 tier3=cat3)

    SELECT
    cat.category_id, cat.category_name, cat.sort_order as 'category_sort',
    cat.mktg_browser_title as 'browser_title', cat2.mktg_browser_title as
    'browser_title2',
    cat2.category_id AS lev2_category_id, cat2.category_name AS
    lev2_category_name, cat2.sort_order AS 'lev2_category_sort', cat2.description
    AS 'lev2_description',
    cat3.category_id AS lev3_category_id, cat3.category_name AS
    lev3_category_name, cat3.sort_order AS 'lev3_category_sort', cat3.description
    AS 'lev3_description'
    FROM cm_categories cat
    LEFT OUTER JOIN cm_categories cat2
    ON cat2.associated_category_id = cat.category_id
    LEFT OUTER JOIN cm_categories cat3
    ON cat3.associated_category_id = cat2.category_id
    WHERE cat2.category_id = #variables.category_id#

    And, if i want to get something from cat3 i do practically the same WHERE
    call because everything is connected using outer joins so with a small
    motification the query now looks like this:

    SELECT
    cat.mktg_browser_title as 'browser_title', cat2.mktg_browser_title as
    'browser_title2',
    cat3.mktg_browser_title as 'browser_title3',
    cat.category_id, cat.category_name, cat.sort_order as 'category_sort',
    cat2.category_id AS lev2_category_id, cat2.category_name AS
    lev2_category_name, cat2.sort_order AS 'lev2_category_sort', cat2.description
    AS 'lev2_description',
    cat3.category_id AS lev3_category_id, cat3.category_name AS
    lev3_category_name, cat3.sort_order AS 'lev3_category_sort', cat3.description
    AS 'lev3_description',
    cat3.associated_category_id as lev3_associated_categegory_id
    FROM cm_categories cat
    LEFT OUTER JOIN cm_categories cat2
    ON cat2.associated_category_id = cat.category_id
    LEFT OUTER JOIN cm_categories cat3
    ON cat3.associated_category_id = cat2.category_id
    WHERE cat3.category_id = #variables.category_id#

    except that this query takes 5000 ms . WHY? I have absolutely no idea. I have
    done the query without the WHERE and I get about 1000 entries. When I scan the
    list I can usually find the cat3.category_id in about 3-4 seconds, WHY does the
    computer do it in 5? There really seems to be nothing different between the
    WHERE cat3.category_id=variable and the cat2.category call. I am wondering if
    anyone has some insight to this issue because it is driving me absolutely nuts.



    phubaba Guest

  2. Similar Questions and Discussions

    1. Qlogic ISP 2200, DL-380 and EVA 5000 SAN; how?
      Hello I am trying to use a HP EVA 5000 SAN through a Qlogic ISP 2200 PCI FC-AL Adapter on a HP DL-380 (dmesg inline at the end), and so far I've...
    2. Fuji S-5000 in stock!
      Fuji S-5000 In Stock Now (29-8-03)! 10 x Optical Zoom 3/6 Megapixels Will Probably Replace The S-602 It looks Similar But A Slightly Smaller...
    3. selling my NIKON 5000
      with 48 mb compact card, MB-E5000 BATTERY PACK. And booklet with CD about the Nikon 5000. In Excellent to Mint cond. Asking $480 with shipping...
    4. Help, Please - again - CP 5000
      Hi, I was so pleased, I used the web site supplied for updating the firmware to 1.7 on my CP 5000 and so, I had to try a "Raw" shot. To my...
    5. Xircom REX 5000 with OS X?
      Is anyone using a Xircom REX 5000 with OS X? I know it can sync with Outlook and all things Windows but I'm hoping there's a way to use it with...
  3. #2

    Default Re: 73 ms to 5000 ms jump in query for no reason?

    At first glance, the first thing that comes to mind is, what is the ID fields
    datatype? If it is not a number it can take longer. If it is something other
    than an integer you can try indexing the field column. But, it usually does not
    do much good indexing if the column is already a integer.

    rmorgan Guest

  4. #3

    Default Re: 73 ms to 5000 ms jump in query for no reason?

    Yes it is an int. Good idea though, I just wish there was some way I could see
    what the stupid query was actually doing, so I could pinpoint where the heck it
    was messing up. There seems to be <<<<zero>>>>> debugging in sql which is so
    rotten

    phubaba Guest

  5. #4

    Default Re: 73 ms to 5000 ms jump in query for no reason?

    Have you tried running the query in Query Analyzer? You can go to the "Query"
    menu and select "Show Execution Plan" and you will know how the query is being
    executed and where the bottleneck is. A table scan is often times the culprit
    in terms of execution cost.

    To view the execution plan click on its tab at the bottom of the query results
    pane.

    sblue Guest

  6. #5

    Default Re: 73 ms to 5000 ms jump in query for no reason?

    Assuming you are using SQL Server of course... ;)
    sblue Guest

  7. #6

    Default Re: 73 ms to 5000 ms jump in query for no reason?

    how would you run one of those say using like sqlyog? or is there a query code
    for it.

    btw I figured out the problem, all i had to do was make the category an index.
    but i would still like to know how to do an analyzer query. thanks

    phubaba Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139