My question concerns Oracle 11gr2 and the use of indexes in SQL queries. Please help me with issue below, I am unable to use index on this query:
SELECT ListingManagerID,
FirstName,
LastName,
PrimaryPhone,
AlternatePhone,
Email,
UserName,
Password,
RecallGuid,
CustomerSince,
PWChangeRequired,
PWExpireDate,
CallingHours,
CreateDate,
CreateIPAddress,
LastLogin,
AutoRenewFlag,
LastUpdated,
UpdatedBy,
AutoRenewRemovedDate,
AutoRenewDate,
isSupplier,
PrefferedLanguage,
AboutMe,
PictureFilePath,
IsProfilePictureDisplay,
LocaleID,
Address1,
Address2,
CityID,
CountryID,
StateProvinceID,
PostalCode,
RegistrationSource,
PPCTypeID,
GhostUser,
ProfileId,
TimezoneID,
OCA
FROM ListingManager
WHERE trim(lower(LISTINGMANAGERID)) = 'e.kkagacoe4aaae7rnr9lua5'
- Created Index
SQL> CREATE INDEX IDX_LISTINGMANAGER_ID ON listingmanager (LOWER(listingmanagerid));
Index created.
- Gather Statistics
SQL> EXEC DBMS_STATS.GATHER_TABLE_STATS('INTERSHOP', 'LISTINGMANAGER' , CASCADE=>TRUE);
PL/SQL procedure successfully completed.
Index was created on Listingmanager Column
, But still Execution plan is showing full table scan. I don't know why full table scan happening still.
ListingManagerID is the primary key of the table, can I modify index created by primary key?
PLAN_TABLE_OUTPUT
--------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)|
--------------------------------------------------
| 0 | SELECT STATEMENT | | 2013 | 487K| 1784 (1)|
|* 1 | TABLE ACCESS FULL| LISTINGMANAGER | 2013 | 487K| 1784 (1)|
Predicate Information (identified by operation id):
1 - filter(TRIM(LOWER("LISTINGMANAGERID"))='e.kkagacoe4aaae7rnr9lua5' )
Thanks
TRIM
to your function based index or usingRTRIM
in your statement should both do the trick. – Lieven Keersmaekers