Hello,
I have 3 tables
tableA has info regarding name and clientid
tableB has info regarding the orderids of the clients
tableC has info regarding the tradeids of the clients
And all the tables have session column
primary key for tableA is (session,client id, name)
tableB has primary key(session, orderid) and index(session, clientid)
tableC has index(session, orderid)
and here is my query
[code=mysql]
select a.name, count(distinct a.clientid), sum(c.price)
from tableA a
STRAIGHT_JOIN tableB b on a.session=b.ses sion and a.clientid=b.cl ientid
STRAIGHT_JOIN tableC c use index (primary) on b.session=c.ses sion and b.orderid=c.ord erid
group by a.name
;
[/code]
the query is taking 45 seconds to execute
and extra field of the explain plan show using filesort for tableA
My question is how I have to modify the indexes to make the tableA to use the index so that query executes faster.
Thanks in advance
I have 3 tables
tableA has info regarding name and clientid
tableB has info regarding the orderids of the clients
tableC has info regarding the tradeids of the clients
And all the tables have session column
primary key for tableA is (session,client id, name)
tableB has primary key(session, orderid) and index(session, clientid)
tableC has index(session, orderid)
and here is my query
[code=mysql]
select a.name, count(distinct a.clientid), sum(c.price)
from tableA a
STRAIGHT_JOIN tableB b on a.session=b.ses sion and a.clientid=b.cl ientid
STRAIGHT_JOIN tableC c use index (primary) on b.session=c.ses sion and b.orderid=c.ord erid
group by a.name
;
[/code]
the query is taking 45 seconds to execute
and extra field of the explain plan show using filesort for tableA
My question is how I have to modify the indexes to make the tableA to use the index so that query executes faster.
Thanks in advance
Comment