Closed dsonda closed 23 hours ago
Indices are chosen at prepare time, where the is no value for :NAME
, that can start with %
.
If you replace LIKE
by STARTING
, it could use.
Or use LIKE with constant instead of parameter: LIKE 'Name%'
. In this case, Firebird will insert an implicit STARTING WITH 'Name'
making it could use an index.
This command is created by an ORM, so I'm trying to intercept and change to STARTING WITH :NAME
, until the ORM fix.
Duplicates #7912
This query does not use the index on NAME field and use a natural plan:
SELECT A.ID, A.NAME FROM PRODUCT A WHERE A.NAME LIKE :NAME || '%'