开发者

How do you create an index across different tables

开发者 https://www.devze.com 2023-01-16 20:08 出处:网络
Table A consists of (id, fieldA, fieldB, fieldC, fieldD) Table B consists of (id, tableA-id, fieldE, fieldF, fieldG)
    Table A consists of (id, fieldA, fieldB, fieldC, fieldD)
    Table B consists of (id, tableA-id, fieldE, fieldF, fieldG)

My queries looks like this:-

1. select * from tableB b, tableA a where a.fieldA=? and a.fieldB=? and a.fieldC=? and a.fieldD=? and (b.fieldF >= '09/01/10' and b.fieldF <= '09/30/10');

2. select * from tableB b, tableA a where a.fieldA=开发者_运维问答? and a.fieldB=? and a.fieldC=? and a.fieldD=? and b.fieldE=? and (b.fieldF >= '09/01/10' and b.fieldF <= '09/30/10');

Note: fieldE is the extra parameter for [2]

How should I define my indexes to accommodate these queries


A good start would, i think, be:

create index huge_index on tableA (fieldA, fieldB, fieldC, fieldD)
create index modest_index on tableB (fieldF, fieldE);

Probably also B.tableA-id. A guru might be able to suggest if some kind of index on B including both tableA-id and other values might help.

0

精彩评论

暂无评论...
验证码 换一张
取 消