Query help needed

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • BCC

    #1

    Query help needed

    Hi I have two tables:

    T1
    ---------
    sequence start end

    T2
    ---------
    id pos

    T1 is a small table (~1000 rows) and T2 is large (~5 million rows)

    The tables are indexed properly, but the following query is extremely slow:

    select * from T2, T1 where pos >= start and pos <= end;

    Is there a better way to do this query? I dont believe mysql uses
    indexes with a query like this (?).

    Thanks,
    Bryan
  • Bill Karwin

    #2
    Re: Query help needed

    BCC wrote:[color=blue]
    > Is there a better way to do this query? I dont believe mysql uses
    > indexes with a query like this (?).[/color]

    What makes you believe it isn't using your indexes (besides the lengthy
    amount of time it takes to generate a result)? Have you tried using the
    EXPLAIN statement to analyze the query?

    Regards,
    Bill K.

    Comment

    Working...