Skip to main content
added [query-performance] to 2412 questions - Shog9 (Id=1924)
Link
added 403 characters in body
Source Link
BeginnerDBA
  • 2.2k
  • 3
  • 26
  • 53

I am trying to understand the below query being run from our developers on read only database which just runs forever.

Table here is partitioned table on partition column trickey per day.

Query is something like below

Select 
   a,
   b,
   c,
   d,
   trickey 
from 
   table 
where 
   (1=1) 
   and (1=1) and convert(varchar(10),trickey,112) BETWEEN 20190913 and 20190913

Will above query not eligible for partition key elimination OR how can i improve or tune up the above query?

Also what is the benefit of (1=1 )used in where clause and does that help or degrade performance?

@Justin- Modified query

Select 
       a,
       b,
       c,
       d,
       trickey 
    from 
       table 
    where 
       (1=1) 
       and (1=1) ---and convert(varchar(10),trickey,112) BETWEEN 20190913 and 20190913 replace this one with modified version

and trickey>=cast('2019-09-13' as date)
and trickey< cast('2019-09-14' as date)

I am trying to understand the below query being run from our developers on read only database which just runs forever.

Table here is partitioned table on partition column trickey per day.

Query is something like below

Select 
   a,
   b,
   c,
   d,
   trickey 
from 
   table 
where 
   (1=1) 
   and (1=1) convert(varchar(10),trickey,112) BETWEEN 20190913 and 20190913

Will above query not eligible for partition key elimination OR how can i improve or tune up the above query?

Also what is the benefit of (1=1 )used in where clause and does that help or degrade performance?

I am trying to understand the below query being run from our developers on read only database which just runs forever.

Table here is partitioned table on partition column trickey per day.

Query is something like below

Select 
   a,
   b,
   c,
   d,
   trickey 
from 
   table 
where 
   (1=1) 
   and (1=1) and convert(varchar(10),trickey,112) BETWEEN 20190913 and 20190913

Will above query not eligible for partition key elimination OR how can i improve or tune up the above query?

Also what is the benefit of (1=1 )used in where clause and does that help or degrade performance?

@Justin- Modified query

Select 
       a,
       b,
       c,
       d,
       trickey 
    from 
       table 
    where 
       (1=1) 
       and (1=1) ---and convert(varchar(10),trickey,112) BETWEEN 20190913 and 20190913 replace this one with modified version

and trickey>=cast('2019-09-13' as date)
and trickey< cast('2019-09-14' as date)
added 4 characters in body
Source Link
BeginnerDBA
  • 2.2k
  • 3
  • 26
  • 53

I am trying to understand the below query being run from our developers on read only database which just runs forever.

Table here is partitioned table on partition column trickey per day.

Query is something like below

Select 
   a,
   b,
   c,
   d,
   trickey 
from 
   table 
where 
   (1=1) 
   and (1=1) convert(varchar(10),trickey,112) BETWEEN 20190913 and 20190913

Will above query not eligible for partition key elimination OR how can i improve or tune up the above query?

Also what is the benefit of 1=1 in where clause being used(1=1 )used in where clause and does that help or downgradedegrade performance?

I am trying to understand the below query being run from our developers on read only database which just runs forever.

Table here is partitioned table on partition column trickey per day.

Query is something like below

Select 
   a,
   b,
   c,
   d,
   trickey 
from 
   table 
where 
   (1=1) 
   and (1=1) convert(varchar(10),trickey,112) BETWEEN 20190913 and 20190913

Will above query not eligible for partition key elimination OR how can i improve or tune up the above query?

Also what is the benefit of 1=1 in where clause being used in where clause and does that help or downgrade performance?

I am trying to understand the below query being run from our developers on read only database which just runs forever.

Table here is partitioned table on partition column trickey per day.

Query is something like below

Select 
   a,
   b,
   c,
   d,
   trickey 
from 
   table 
where 
   (1=1) 
   and (1=1) convert(varchar(10),trickey,112) BETWEEN 20190913 and 20190913

Will above query not eligible for partition key elimination OR how can i improve or tune up the above query?

Also what is the benefit of (1=1 )used in where clause and does that help or degrade performance?

added 121 characters in body
Source Link
KASQLDBA
  • 7.2k
  • 6
  • 30
  • 53
Loading
added 6 characters in body
Source Link
BeginnerDBA
  • 2.2k
  • 3
  • 26
  • 53
Loading
added 48 characters in body
Source Link
BeginnerDBA
  • 2.2k
  • 3
  • 26
  • 53
Loading
added 77 characters in body
Source Link
S3S
  • 3.6k
  • 1
  • 13
  • 25
Loading
Source Link
BeginnerDBA
  • 2.2k
  • 3
  • 26
  • 53
Loading