已有一分区表:
create table par_test(
  ID int,
  saledate date,
  areaid int, 
  personid int,
  productid int
  otherdata
)
parition by range(saledate)
(...)create index index_1 on par_test(areaid, personid, productid) local;然后统计:
select 
  A.areaid, --b.areaname,
  A.personid, --c.personname,
  count(1)
from par_test
where 
   saledate between date'xxxx' and date'xxxx'
and a.areaid = 'area001' 
and a.personid 'm001'    --in (select personid from person_table where dept = 'd001')
and a.productid = 'p001' --in (select productid from product where xxxx)
group by areaid, personid上面SQL:
在where中,如果a.personid/a.指定的话,则在分析计划用到了索引index_1,如果像上面写的用in/exists操作,就全表扫描不知有什么方法用到索引不?因为有些查询条件各不相同,还可能areaid/person/productid, 或者其中一个,或者全有,全无请问如何建索引了,
谢谢各位。