Ask a Question related to Dreamweaver AppDev, Design and Development.

  1. #1

    Default Indexes

    hello,
    here is my question. if you have a table called related_to
    and it has these fields:
    id
    active
    from_class_id
    from_id
    type_cid
    status_cid
    seq_num
    to_class_id
    to_id
    created_by
    create_date
    updated_by,
    update_date

    with this index:
    create index "informix".related_to_i2 on "informix".related_to
    (to_id,to_class_id,active,type_cid,seq_num,from_cl ass_id,from_id);

    and you run this sql against it:
    SELECT MAX(seq_num)
    FROM related_to
    WHERE type_cid = 3030 AND from_class_id = 74 AND from_id = 2184640
    AND ACTIVE = 1

    does it matter the order of the created index and the order of the
    fields in the sql?

    on a more general note, how do informix indexes work?
    do they have to be in the same order?
    what if there is a mismatch between all the columns in the index and
    what is in the sql?

    Thanks in advance,
    Tom
    tomL Guest

  2. Similar Questions and Discussions

    1. Multiple Indexes
      I am producing a conference program that has the names and details of all the conference attendees. I need to index these attendees both by name and...
    2. indexes in cs
      Is it possible to easily create an InDesign index from a Word document? In other words, if the Word doc comes through with a special character...
    3. using indexes
      quick question regarding proper use of indexes. there are options for asc/desc sorting for each column when creating the index - for optimal...
    4. Two indexes?
      I'm doing a book with a long contributor index as well as a standard index. Is it possible to use ID's indexing feature for both, or am I limited to...
    5. Rebuilding indexes
      I've been experimenting with so called 'Browned-Out Indexes' those that are inefficent space wise and I can't seem to get the Oracle Rebuild or...
  3. #2

    Default Re: Indexes

    tomL wrote:
    > hello,
    > here is my question. if you have a table called related_to
    > and it has these fields:
    > id
    > active
    > from_class_id
    > from_id
    > type_cid
    > status_cid
    > seq_num
    > to_class_id
    > to_id
    > created_by
    > create_date
    > updated_by,
    > update_date
    >
    > with this index:
    > create index "informix".related_to_i2 on "informix".related_to
    > (to_id,to_class_id,active,type_cid,seq_num,from_cl ass_id,from_id);
    >
    > and you run this sql against it:
    > SELECT MAX(seq_num)
    > FROM related_to
    > WHERE type_cid = 3030 AND from_class_id = 74 AND from_id = 2184640
    > AND ACTIVE = 1
    >
    > does it matter the order of the created index and the order of the
    > fields in the sql?
    >
    > on a more general note, how do informix indexes work?
    > do they have to be in the same order?
    > what if there is a mismatch between all the columns in the index and
    > what is in the sql?
    >
    > Thanks in advance,
    > Tom
    Indexes in Informix work much like indexes in any other DB.
    In general for an index to be choosen by the optimizer to solve a query there must be a condition (in the query) referencing the first index column.

    In the above case, there is no condition on to_id in the query. As such it will make a sequential scan.
    You can verify this by using the SQL instruction "SET EXPLAIN ON;" and looking at the "sqexplain.out" file in the $HOME of the user. You'll see the query plan.
    Don't forget to update statistics after creating indexes.

    Some versions of Oracle (9i I think) can eventually use an index when there are conditions on the second (and maybe others) columns of the indexes.
    Take note that I mention "eventually" because ther must be some pre-conditions for this to be true:

    1- The first column of the index must have very low selectivity (in which case you'd better think why it was chosen for index header)
    2- The table must have very good statistics collected

    and maybe others I don't remember.

    Please note that this is an exceptional situation. The normal index behavior is the mentioned first. Think about the physical structure and layout of an index and you'll understand
    why.

    Regards.

    Fernando Nunes Guest

  4. #3

    Default Indexes

    :confused; Does anyone know if it is possible to create 2 seperate indexes?
    I have one web host but would like to create 2 seperate entries one for a
    gallery fine are page (ie: [url]www.artpage.com[/url]) and another for services (ie:
    [url]www.reddog.com[/url]). Any help would be appreciated. Thanks for you time and
    assistance in advance.
    Sue

    Red Dog Art 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