Performance issues of `fetch first n rows only` Consider a query of the form

insert into new_table (new_column)
select column as new_column
from table
where column like '%pattern'
fetch first 1000 rows only;


table has a sufficient number of entries such that at least 1000 ones satisfy the criterion. What irritates me is that with the criterion commented out, the query runs much more slower (using DB2) than with the criterion enabled. I would have expected it to run faster with less restrictions since less rows would have had to be considered. Where am I mistaken?
not sure i understand correctly. do you mean this is SLOWER or FASTER?

insert into new_table (new_column)
select column as new_column
from table
-- no WHERE clause
fetch first 1000 rows only;


in general, if there is a where-clause, any database engine must read records, and 'drop' those that don't match the where clause. the 'read-loop' must read from disk until 1000 matches are found. the best case will encounter NO non-matches; the worst case will read the complete dataset

without a where-clause, the database engine only has to read 'the first 1000 records', thus every IO operation can be used for the resultset. so, that should be faster.