Query optimization help required

Applications
Applications covers the world of Teradata apps, including apps offered by Teradata (such as TRM or DCM), as well as best practices and methodologies for building your own Teradata-connected apps.
New Member

Query optimization help required

SyntaxEditor Code Snippet

i've the below sel query to be optimized containing cd(code) and discritption from different tables and cd should not exist in other union. Can this be simplified in any way  its taking to much of spool since it goes on for another 3 more tables.
        
        sel
        cd,
        dsc
        from site
        
        union all
        
        sel
        cd,
        dsc
        from bldg
        where column = 'condition'
        and not exists
        (sel * from
        (
        sel    cd,dsc    from site
        )
        )
        
        Union ALL
        
        sel
        cd,
        dsc
        from plnt
        where column = 'condition'
        and not exists
        (sel * from
            (
            sel    cd,dsc    from site
            union
            sel cd,dsc from bldg where column = 'condition'
            )
        )

 

  • SQL
  • Teradata