I have a simple SQL statement: SELECT i_id, a_lname FROM item, author WHERE i_a_id=a_id and a_lname LIKE 'BABABABA%'
I have two indexes on author (a_lname, a_id) I have one index on item (i_a_id) The execution plan I got shows that it is not using index on author(a_lname) 'DBT';'AUTHOR';'';'TABLE SCAN';' 162';'';'';'';'' 'DBT';'ITEM';'I_A_ID';'JOIN VIA INDEXED COLUMN';' 970';'';'';'';'' 'DBT';'';'';' RESULT IS COPIED , COSTVALUE IS';' 1600';'';'';'';'' I read from the mailing list that if the wildcard is at the beginning of the string, then it will not use the index. But in this case, the wildcard is at the end of the sting. If I use the exact string: SELECT i_id, a_lname FROM item, author WHERE i_a_id=a_id and a_lname LIKE 'BABABABA' The the optimizer will use the index, and the execution plan is: 'DBT';'AUTHOR';'A_LNAME';'EQUAL CONDITION FOR INDEXED COLUMN';' 162';'';'';'';'' 'DBT';'ITEM';'I_A_ID';'JOIN VIA INDEXED COLUMN';' 970';'';'';'';'' 'DBT';'';'';' RESULT IS COPIED , COSTVALUE IS';' 2';'';'';'';'' Any suggestions on how I can make the optimizer use the index? Thanks, Jenny -- Jenny Zhang Open Source Development Lab Inc 15275 SW Koll Parkway - Suite H Beaverton, OR 97006 (503)626-2455 ext 31 _______________________________________________ sapdb.general mailing list [EMAIL PROTECTED] http://listserv.sap.com/mailman/listinfo/sapdb.general
