Hi!

Here is a worst case i have even seem so far:

create table aa(
    some_number    int unsigned not null,
    index    aa_sn (some_number)
);

create table bb(
    min_number    int unsigned not null,
    max_number    int unsigned not null,
    range_type    char(1) not null,
    primary key (min_number, max_number)
);

now we put 25000 records into aa and 1000 into
bb and try to figure out in what range each number in aa:

select some_number, range_type from aa inner join bb on
some_number>=min_number
and  some_number<=max_number;

I use inner join because number which are not in one of the ranges are
not interesting to me.

Explain gives 25000x1000 rows to  scan and range check w/o
using index. So, the select take about 7 minutes to complete.

Is there any way to make such case faster. The problems is that
I don't know ranges until aa has all the data, so i cannot
figure out the range while inserting into aa. Tricky business.

Any ideas?
Not really impirtant, but i thought i would an interesting task.

Regards,
Artem


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to