Field order for Where clause

I found that field ordering affects Select performance. For example, I want to extract data from the V_EUQI on TPLNR (500), DATBI (1) and EQTYP (1), a sentence:

 SELECT ... FROM v_equi INTO itab WHERE eqtyp IN rg_eqtyp AND datbi IN rg_datbi AND tplnr IN rg_tplnr 

works much faster than the same choice, but the order of the field is TPLNR - EQTYP - DATBI .

How to explain this problem?

+4
source share
1 answer

This is almost certainly due to indexing. When reading from a transparent table for maximum performance, the order of the fields in the WHERE must match either the indices or the order to the left and right of the fields in the table (to use any implicit index created from the primary key (s)). Indexes cannot be defined for views, but any ones defined for base tables will certainly be used.

You must confirm this with SQL tracing and confirm which indexes are used.

+2
source

All Articles