Hi GüŸnther,

> I need to join 2 tables A and B on 3 columns, ie.
>
> "select A.4, B5 where A1 = B1 and A2 = B2 and A3 = B3"
>
> the columns B1, B2, B3 are individually indexed, I also have an  
> index of
> (B1,B2,B3).

> The query is very slow, I don't understand why, can someone please  
> tell
> me where my mistake is?

You don't need the individual indexes for that query. You need an  
index on (B1, B2, B3) as well. So in all you need:

create table A (A1, A2, A3, A4, A5);
create table B (B1, B2, B3, B4, B5);
create index AI on A (A1, A2, A3);
create index BI on B (B1, B2, B3);

Your select statement looks odd to me. I guess you mean:

select A4, B5 from A, B where A1 = B1 and A2 = B2 and A3 = B3;
or:
select A4, B5 from A join B on A1 = B1 and A2 = B2 and A3 = B3;

HTH,
Tom

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to