Results 1 to 1 of 1
  1. #1
    Join Date
    Jan 2016
    Posts
    1

    Unanswered: Need way to avoid checking each row

    With DB2 10.5.6 x64 on Ubuntu 14.04.3, In the case of a SELECT from DML in a CTE where you just want the INSERT done but not return any rows to the CTE like:

    Code:
    cte1 (null) as
       (select null
          from final table
               (insert into ... col1 not null ...)
    >>no WHERE clause here returns null row for each row in final table to cte1 but I don't want to return any rows<<
       )
    According to db2batch timing runs, both of the below WHERE clauses are much faster (and have equal times) than no WHERE clause because it reduces the rows returned to 0, which is great!!
    WHERE 0 = 1
    WHERE col1 is null

    but because they both have equal times doesn't that mean that WHERE 0=1 is checking each row? Isn't there an always false predicate, or some other magic that tells the optimizer to not return any rows AND to not bother searching each row as well?

    thanks!!
    Last edited by amcintyre; 01-08-16 at 16:55.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •