[Solved] If to put a dummy condition in sql query like between \'mindate\' and \'maxdate\', would efficiency of query be reduced?

EverSQL Database Performance Knowledge Base

If to put a dummy condition in sql query like between \'mindate\' and \'maxdate\', would efficiency of query be reduced?

Database type:

In SQL Server 2008,

select * from OneTable

compare to

select * from OneTable where OneTable.SomeDate between 'MINDATE' and 'MAXDATE'

which one is fast or they are same fast?

How to optimize this SQL query?

The following recommendations will help you in your SQL tuning process.
You'll find 3 sections below:

  1. Description of the steps you can take to speed up the query.
  2. The optimal indexes for this query, which you can copy and create in your database.
  3. An automatically re-written query you can copy and execute in your database.
The optimization process and recommendations:
  1. Avoid Selecting Unnecessary Columns (query line: 2): Avoid selecting all columns with the '*' wildcard, unless you intend to use them all. Selecting redundant columns may result in unnecessary performance degradation.
The optimized query:
SELECT
        * 
    FROM
        OneTable

Related Articles



* original question posted on StackOverflow here.