Results 1 to 3 of 3

Thread: DB2 where 1=1

  1. #1
    Join Date
    Mar 2012

    Question Unanswered: DB2 where 1=1

    I build up my query in my program. To prevent some programming errors, I start the where condition in my query always with a "where 1=1" statement.

    - Does it effect the performance of my queries or is db so clever that it recognizes it.

  2. #2
    Join Date
    Apr 2012
    Provided Answers: 17
    If you are using 'where 1=1' on large-tables in a production environment *and* you have no other predicates in the WHERE clause* then it is the same as having no where clause at all.

    With the sole predicate being 1=1, you will fetch too many rows. This can stress your database and your network if the result-sets are large and/or if the row-counts in the target-tables are high.

    If you are working on a personal development environment then it does not matter.

    But if you are working on any mult-user environment with many other people sharing those resources then you really should not do this, particularly on a production environment.

  3. #3
    Join Date
    Aug 2001
    no performance impact

    Visit the new-look IDUG Website , register to gain access to the excellent content.

Tags for this Thread

Posting Permissions

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