Ask a Question related to IBM DB2, Design and Development.

  1. #1

    Default Optimizing Query

    Can anybody tell me how to improve the performance of this query?

    SELECT
    NID, LEVEL, VALUE
    FROM
    DATA
    WHERE
    DID=2 AND STATUS=0

    The value of STATUS is either 0 or 1. The primary key of DATA is EID
    which I don't use in the query.

    The total cost of the query without index is 240.47
    If I put index on DID and STATUS, the total cost is 190.47.

    Thanks

    Erwin
    Erwin Guest

  2. Similar Questions and Discussions

    1. Help Optimizing Query
      Just looking to see if anyone has any pointers on how i can optimize this query... it is taking about a minute to show the data, and even though its...
    2. Help in optimizing a slow query...
      Hello, I'm trying since weeks (with no luck...) to optimize a query which is "killing" my site on peak times (100+ visitors simultaneously). I...
    3. Tools for optimizing mysql query
      I have googled a lot, but couldn't find it. But, I hope that there will be a tool for query optimization (a tool that can automatically detect the...
    4. Optimizing PDF
      Hey, I have a pdf that i am trying to optimize because it is 14 megs in size. WHen i use the pdf optimizer, i get an message that says "THe...
    5. Optimizing for CD playback
      I'm working on a Director Movie the final will be distributed on a CD as a projector file. The presentation is 4-5 minutes long and will consist...
  3. #2

    Default Re: Optimizing Query

    [email]erwin2@myrealbox.com[/email] (Erwin) wrote in message news:<43ecf6d7.0308130142.3091870d@posting.google. com>...
    > Can anybody tell me how to improve the performance of this query?
    >
    > SELECT
    > NID, LEVEL, VALUE
    > FROM
    > DATA
    > WHERE
    > DID=2 AND STATUS=0
    >
    > The value of STATUS is either 0 or 1. The primary key of DATA is EID
    > which I don't use in the query.
    >
    > The total cost of the query without index is 240.47
    > If I put index on DID and STATUS, the total cost is 190.47.
    >
    > Thanks
    >
    > Erwin
    datatype of STATUS ?
    did you a
    runstats WITH DISTRIBUTION
    on the table?, otherwise the optimizer does not know that there are
    only 2 different values for STATUS.
    Joerg Ammann Guest

  4. #3

    Default Re: Optimizing Query

    > datatype of STATUS ?

    I use SMALLINT. Actually, I need only two values for STATUS.
    > did you a
    > runstats WITH DISTRIBUTION
    > on the table?, otherwise the optimizer does not know that there are
    > only 2 different values for STATUS.
    I didn't execute RUNSTATS WITH DISTRIBUTION on the table. I try to
    execute RUNSTATS WITH DISTRIBUTION, and it works.

    Thanks :)
    Erwin 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