Hi all,
I have a case that cause performance issue as example below:
Table A:
Col1(PK)---Col2---IsActive
1------------C1-----1
2------------C2-----0
Table B:
Col1B(PK)---Col2B---Col3B(FK from table A)
1B-------------C1-----1
2B-------------C2-----NULL
When I use LEFT JOIN:
select B.* from table B left join table A on B.Col3B = A.Col1 where isnull(A.IsActive, 1) = 1
That means I need to get data in table B where A.IsActive = 1 or NULL.The above query have a problem with ISNULL function because with this function, we can not use the INDEX and when we have a BIG data, the performance is very BAD.
Is there any solution for this?
Thanks all
I have a case that cause performance issue as example below:
Table A:
Col1(PK)---Col2---IsActive
1------------C1-----1
2------------C2-----0
Table B:
Col1B(PK)---Col2B---Col3B(FK from table A)
1B-------------C1-----1
2B-------------C2-----NULL
When I use LEFT JOIN:
select B.* from table B left join table A on B.Col3B = A.Col1 where isnull(A.IsActive, 1) = 1
That means I need to get data in table B where A.IsActive = 1 or NULL.The above query have a problem with ISNULL function because with this function, we can not use the INDEX and when we have a BIG data, the performance is very BAD.
Is there any solution for this?
Thanks all
No comments:
Post a Comment