SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Handling NULL in existing project


Handling NULL in existing project

Author
Message
raju.tanneeru
raju.tanneeru
SSC-Enthusiastic
SSC-Enthusiastic (199 reputation)SSC-Enthusiastic (199 reputation)SSC-Enthusiastic (199 reputation)SSC-Enthusiastic (199 reputation)SSC-Enthusiastic (199 reputation)SSC-Enthusiastic (199 reputation)SSC-Enthusiastic (199 reputation)SSC-Enthusiastic (199 reputation)

Group: General Forum Members
Points: 199 Visits: 124
Hi,

I have moved recently to a project, which is running fine in production for last 3 yrs.

now when i am handling the performance issues, i have observed that there are lot code in vb.net files and lot code in script i.e. in stored procedures. most of the columns are defined as allow nulls, due to lack of proper requirement/coding, now there is lot of data with NULLs
to handle these nulls in the script(sp), written case statements.

So could any one help me out now, what is the better way to tune this issues, from the vb.net code and script of the stored procedures.

Thanks
Grant Fritchey
Grant Fritchey
SSC Guru
SSC Guru (98K reputation)SSC Guru (98K reputation)SSC Guru (98K reputation)SSC Guru (98K reputation)SSC Guru (98K reputation)SSC Guru (98K reputation)SSC Guru (98K reputation)SSC Guru (98K reputation)

Group: General Forum Members
Points: 98491 Visits: 33014
I'm not sure I understand the question. Are you trying to tune queries where there is a lot NULL columns?

If so, yes, this can be an issue in 2005 and prior version because NULL values and indexes don't mix will to arrive a selective indexes. SQL Server 2008 has a filtered index that could help you here.

If that's not the kind of information you're looking for, please clarify your concerns. Thanks.

----------------------------------------------------
The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood...
Theodore Roosevelt

The Scary DBA
Author of: SQL Server Query Performance Tuning and SQL Server Execution Plans
Product Evangelist for Red Gate Software
raju.tanneeru
raju.tanneeru
SSC-Enthusiastic
SSC-Enthusiastic (199 reputation)SSC-Enthusiastic (199 reputation)SSC-Enthusiastic (199 reputation)SSC-Enthusiastic (199 reputation)SSC-Enthusiastic (199 reputation)SSC-Enthusiastic (199 reputation)SSC-Enthusiastic (199 reputation)SSC-Enthusiastic (199 reputation)

Group: General Forum Members
Points: 199 Visits: 124
Thanks for your reply,

Yeah as you mentioned i have read some article on 2005 , as this is an issue for indexing & Null .

But my major problem is there is huge data i have with NULLs, now i want to tune the queries, such that the query should handle the nulls before sending the result back to UI. Right now i am achieving this by writing the "case" statement for each field like this.

Case when Column1 is NULL then ''
when Column1 is NOT NULL then Column1 end

like this the script is written for all the columns in each table. Which i causing script to increase in 100's lines and also getting difficult to edit/fix any issues

Can any one provide better way to handle this.
Grant Fritchey
Grant Fritchey
SSC Guru
SSC Guru (98K reputation)SSC Guru (98K reputation)SSC Guru (98K reputation)SSC Guru (98K reputation)SSC Guru (98K reputation)SSC Guru (98K reputation)SSC Guru (98K reputation)SSC Guru (98K reputation)

Group: General Forum Members
Points: 98491 Visits: 33014
I wouldn't recommend using this method in the WHERE or JOIN clauses of your queries, but for the SELECT list, instead of CASE statements, try this:

SELECT COALESCE(MyColumn,'') AS MyColumn
...



That will do what you're trying to do with a lot less overhead.

----------------------------------------------------
The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood...
Theodore Roosevelt

The Scary DBA
Author of: SQL Server Query Performance Tuning and SQL Server Execution Plans
Product Evangelist for Red Gate Software
Steve Hall
Steve Hall
SSCertifiable
SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)

Group: General Forum Members
Points: 5161 Visits: 11869
Another option is the ISNULL function, which I use to remove NULL values from the output.

Steve Hall
Linkedin
Blog Site
Atif-ullah Sheikh
Atif-ullah Sheikh
SSCertifiable
SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)

Group: General Forum Members
Points: 5078 Visits: 5204
Its much better to set Default Values for such columns where NULLs can be inserted. This resolves many conversion issues.

----------------------------------------------------------------------------------------------------------------------------------------------------------------------

Sometimes, winning is not an issue but trying.

You can check my BLOG here


raju.tanneeru
raju.tanneeru
SSC-Enthusiastic
SSC-Enthusiastic (199 reputation)SSC-Enthusiastic (199 reputation)SSC-Enthusiastic (199 reputation)SSC-Enthusiastic (199 reputation)SSC-Enthusiastic (199 reputation)SSC-Enthusiastic (199 reputation)SSC-Enthusiastic (199 reputation)SSC-Enthusiastic (199 reputation)

Group: General Forum Members
Points: 199 Visits: 124
YEAH,

Exactly i was thinking in the same way, using the default values.

I am just waiting for the default values for those fields from client.

Thanks every one for your responses.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search