Hi

I have a very simple database with three tables. I require joining the
three tables together.

I am trying to optmise a query which joins all three and sorts the
results. I cannot tell if sqlite uses my indeces or not. Is there a way
to tell what indexes are used in a query ? I join by the first PK, but
the sort is by additonal columns.

How can I go about optimising this query? Any ideas? I just cant see
how to tell if changes are helping espeicially with disk caching etc...

My tables are like this, and the query follows:

Products:
  Region: PK Integer
  Product: PK Integer
  Rank: TEXT
  name: TEXT

Customers:
  Region: PK Integer
  Customer: pK Integer;
  Rank: TEXT
  name: TEXT

Targets:
  Region: PK Integer
  Customer: pK Integer;
  Product: PK Integer

Select *
from
  Targets t,
  Customers c,
  Products p
where
  t.Region = c.REgion and
  t.Customer = c.Customer and
  T.REgion = p.region and
  t.product = p.product and
  t.region = 1
order by
  c.rank,
  c.name,
  c.customer,
  p.rank,
  p.name,
  p.product
Thanks,

Reply via email to