Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2003
    Location
    Brisbane, Australia
    Posts
    110

    Unanswered: Correct Index Usage

    Hi all,

    Am hoping someone can help..

    I have the following...

    Table_1 (
    col_1 int,
    col_2 varchar,
    start_datetime datetime,
    col_3 int,
    col_4 int,
    col_5 varchar
    .....
    )

    pk_index col_1, col_2, start_datetime, col_3
    indx_1 col_3
    indx_2 start_datetime, col_3
    indx_3 start_datetime


    Now I am trying to delete:

    DELETE Table_1 WHERE start_datetime < '?' AND (col_3 > ?)

    Problem is that it is using indx_1 and is painfully slow. Is it the brackets around (col_3 > ?) forcing it to use this index? I have run update stats on the entire table. Any ideas?

    If I change it to: DELETE Table_1 WHERE start_datetime < '?' AND (col_3 > ? AND col_2 != 0) it uses pk_index and runs quickly. I cannot remove the brackets in the statement.

    Ideas?

  2. #2
    Join Date
    Mar 2003
    Location
    Vienna
    Posts
    24

    Sample of data

    Hi,

    please provide a sample of your data. Like 100 records or something.

    SL
    kdb is the solution of all problems.
    Just try it, www.kx.com

Posting Permissions

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