GaryMoore
20th June 2002, 11:20
I've been using query.extension in BaaN IV to limit the database reads that are taking place on alternate-key fields (i.e. secondary indices).

I've tried coding the following:

query.extension = "cseer962._index2 = {:clno}"

(this is a local table rather than a standard BaaN table).

The query takes some time to run, and after the DBA analyzed the select statement being called, it was using the main index (index1). This is the select statement produced:
SQL> SELECT /*+ FIRST_ROWS INDEX(a tcseer962321$idx1) */ a.t$adva,a.t$amex, etc
FROM baan.tcseer962321 a WHERE a.t$clno = :1 AND (a.t$vono >= :2) ORDER BY 116
Can anyone offer any suggestion as to why the index is not being used when I coded it, and perhaps offer a suggestion as to how I could force the script to use this index?

shah_bs
21st June 2002, 02:22
When the session was generated, it was probably generated based on index1.

I am not sure if this will work, but you may change the index which is used as start index by going into Maintain Sessions and choosing the <Change Key> option to make suitable changes. It may be necessary to create runtime DD for the session only, exit the bshell and try running again to see if there is any effect.

Let me know if this works.

P.S. It is possible that you may have to modify the form also to suit the index, especially if it was a TYPE 3 form.

OmeLuuk
24th June 2002, 13:17
add the order by clause to read using index 2
select *
from *
where *
order by table._index2