subselect losing the index when where clause includes coalesce()
----------------------------------------------------------------

                 Key: CORE-4640
                 URL: http://tracker.firebirdsql.org/browse/CORE-4640
             Project: Firebird Core
          Issue Type: Bug
          Components: Engine
    Affects Versions: 2.5.2 Update 1
         Environment: Win8.1, Firebird 2.5.2.26540 (x64)
            Reporter: Omacht AndrĂ¡s
         Attachments: FB_TEST.ZIP

See the attached database.

When running 

select t3.id,
       (select first 1 v1.id
          from v1
          where v1.vc1 = 'A' and v1.i2 = 1000 and v1.i1 = coalesce(t3.i1_1, 
t3.i1_2))
  from t3

no indicies were found for view v1:

Plan
PLAN (V1 T1 NATURAL)
PLAN (V1 T2 NATURAL)
PLAN (T3 NATURAL)

The engine should use T1_UK and T2_UK:
Plan
PLAN (V1 T1 INDEX (T1_UK1))
PLAN (V1 T2 INDEX (T2_UK1))
PLAN (T3 NATURAL)


Without coalesce in then where clause it works fine:

select t3.id,
       (select first 1 v1.id
          from v1
          where v1.vc1 = 'A' and v1.i2 = 1000 and v1.i1 = t3.i1_1)
  from t3

Plan
PLAN (V1 T1 INDEX (T1_UK1))
PLAN (V1 T2 INDEX (T2_UK1))
PLAN (T3 NATURAL)

and

select t3.id,
       (select first 1 v1.id
          from v1
          where v1.vc1 = 'A' and v1.i2 = 1000 and v1.i1 = t3.i1_2)
  from t3

Plan
PLAN (V1 T1 INDEX (T1_UK1))
PLAN (V1 T2 INDEX (T2_UK1))
PLAN (T3 NATURAL)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://tracker.firebirdsql.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to