How much do CAST statements affect performance?

I have an 800+ line SELECT that I am tuning before using it as the source in an SSIS package. I have reduced the original time it took from around 19 minutes down to just under 2 minutes and now I'm running out of ideas.
My last gain was a 30 second reduction by removing all UDF calls.
There are a large number of CAST statements as my source data needs to be converted for the target table (such as casting decimal as money, varchar as nvarchar, etc.).
Is this likely to have any significant impact on the performance of my statement or not enough to bother about? Maybe using the SSIS convert option would be more efficient?
In some places I have CAST(0 as money). Would it be quicker to define a variable as money with value zero and assign that?
Nick Ryan SQL Server Developer OnePath (NZ) Ltd

There are a large number of CAST statements as my source data needs to be converted for the target table (such as casting decimal as money, varchar as nvarchar, etc.).
Is this likely to have any significant impact on the performance of my statement or not enough to bother about? Maybe using the SSIS convert option would be more efficient?
In some places I have CAST(0 as money). Would it be quicker to define a variable as money with value zero and assign that?
Nick Ryan SQL Server Developer OnePath (NZ) Ltd
As a general rule, doing CASTs or CONVERTs on items in your SELECT clause cost almost nothing.  (Note that CASTs or CONVERTs in WHERE or ON clauses can be very expensive since they will keep SQL Server from making effective use of indexes). 
The reason is it's not expensive in the SELECT clause that most SQL commands take almost all their time doing disk I/O.  But doing the CASTs in a SELECT clause is almost entirely CPU.  And since the CPU is so much faster than the I/O system, the
CASTs don't add much if any time since the CASTs on one group of rows can be done while the I/O system is retrieving the next group of rows and the CPU will finish before the I/O system and then just be sitting there waiting.  As always, there are exceptions
and your mileage may vary.  For example, you might have a server that is already CPU bound for other reasons.
As a test, I ran the following code against a Numbers table that I have that has a bigint column and contains 1,048,575 rows with the numbers from 1 to 1,048,575.
Declare @StartTime datetime2;
Declare @EndTime datetime2;
DBCC FreeProcCache
DBCC DropCleanBuffers
set @StartTime = GETDATE()
select sum(Number) From dbo.Numbers
set @EndTime = GETDATE()
select DateDiff(ms, @StartTime, @EndTime) As 'No Convert'
DBCC FreeProcCache
DBCC DropCleanBuffers
set @StartTime = GETDATE()
select sum(len(Cast(Number As nvarchar(20)))) From dbo.Numbers
set @EndTime = GETDATE()
select DateDiff(ms, @StartTime, @EndTime) As 'With Convert'
As you can see, in one case, I just summed the numbers, in the second, I converted the number, found the length and summed the lengths.  I ran it several times, sometimes the first one was faster, sometimes the second.  They were always within
less than 0.1 seconds of each other.  So the extra function calls on 1,000,000 rows essentially cost nothing.
And I definitely would not worry about CAST(0 AS money).  SQL is smart enough to figure out that that is just a money constant.  So it will just create a constant value of 0 of type money and use that.  It will not do that cast for every row.
Tom

Similar Messages

  • X301: 250 GB 5400 rpm vs 128 GB Solid State Performance - How Much Difference?

    Any idea about how much faster XP Pro will boot with the 128 GB solid state drive vs the 5400 rpm 250 GB drive?  And for apps like Word and Excel how much performance difference will there be when launching the apps (doesn't seem like it could be much more than a second or two)?  Any idea of the real world performance for writes and reads in terms of Bytes per second?  Any users have expereince with both drives using X301s?

    The answer to your implied question, "Is 128GB big enough?" is Yes, 128GB is big enough for a Boot Drive.
    Mac OS X may only take up 8 to 10GB, but developer tools adds a lot and if you install big Photo or Video Editing tools you might quickly end up at 40GB including Applications.
    Mac OS X needs a Swap file and some Paging files as well, and if you do not have enough your Mac Pro will get really weird.
    64GB is getting too close for comfort -- effectively too small.
    128GB is NOT enough to also store your Photo collection, substantial Tunes Library, or Video editing files. If you have any of those, you will need to move them to a different drive, or get a MUCH larger and more expensive drive, or keep the bulk of them on an external drive that stays on your desk.
    You also need a Backup Drive.

  • How much jvm affects space & performance of DB????

    Hi ,
    as i know , there are some objects created in system tablespace or something else in the DB after installing jvm.
    My question is how much space those object occupted and how those changes affect on the original DB ????
    Thanks
    Stephen

    If you measure the performance as the time required to allocate the initial 600 GB data file plus the time to do the load and compare that to allocating a small file and doing the load, letting the data file autoextend, it's unlikely that you'll see a noticable difference. You'll get far more variation just in moving 600 GB around than you'll lose waiting on the data file to extend. If there is a difference, allocating the entire file up front will be slightly more efficient.
    More likely, however, is that you wouldn't count the time required to allocate the initial 600 GB data file since that is something that can be done far in advance. If you don't count that time, then allocating the entire file up front will be much more efficient.
    If you may need less than 600 GB, on the other hand, allocating the entire file at once may waste some space. If that is a concern, it may make sense to compromise and allocate a 500 GB file initially (assuming that is a reasonable lower bound on the size you'll actually need) and let the file extend in 1 GB chunks. That won't be the most efficient approach and you may waste up to a GB of space but that may be a reasonable compromise.
    Justin

  • How low can mac mini storage capacity go before it affects performance?

    I have 15 GB left on my hard drive, how low can it go before it affects performance and I welcome any recommendations on how I can best expand storage space.
    Usage: I use my mac for word and excel docs, but I store a number of images and graphic files, but I don't use any designer software.
    Thanks,
    Sq1mac

    Welcome to Apple Discussions!
    There's no one answer to the question of how much free space you really need to keep on your drive before performance and system stability begins to suffer, but with 15Gb left at the present, you will only be reaching that point if you are doing things like burning disk images (because macOS grabs drive space to store the image) or syncing with MobileMe.
    In your situation I'd be careful not to go below 10Gb free.
    Expanding storage space is very easy. Buy an external drive with either USB2.0 or Firewire interface (firewire is better but more expensive) and connect it to your system. If the drive isn't set up for a MAc, it can easily be partitioned and formatted using Disk Utility on the Mac, and you are then ready to use whatever capacity the external has - including moving any or all your files, music, photos etc to the external if you wish or need to. Just about any external, even models which appear to be for PC/Windows use only, will work perfectly well on a Mac - you don't need a 'Mac compatible' drive.

  • How much performance can I get from my macbook?

    It's older then 2,5 years but still quite good for my needs. It has a 2.16 GHz Core 2 Duo and I never use all the CPU, it has 2GB 667MHz DDR2 SDRAM and I use it all. I am not using all the 120 GB of 5400 rpm HDD but I use it often and I feel how much it is slow. Intel GMA950 is slow also, but it seems to be enough for me and is able to manage my external LCD at 1920x1200 resolution.
    So I am thinking about two possible ways to have more performance:
    1. get a new macbook pro of 13" with 4GB RAM, newer disk (may be faster);
    2. upgrade my RAM, my Disk and may be my OS.
    I know that I can use only 3.3 GB of RAM if I place 2 x 2GB 667MHz so-dimms: one more GB free could make difference for me.
    About the disk, I know that my SATA is limited to 1.5 Gigabits but, using AJA System Test, I see that my internal drive is able to read and write about 29 MB/s, that seems to be even slower of my external 7200 drive that is using a Firewire 400 connection (39 MB/s).
    It seems to me that newer HDDs on market, eg. Seagate Momentus.4 5400 rpm, are able to give much better transfer rate. My SATA should be able to manage transfer rates till 180MB/s so SATA II HDD should not suffer of it. Is it right?
    Finally I could upgrade to Snow Leopard that should be a little bit faster then Leopard and with a completely new better finder.
    So my questions are:
    1. current 5400 HDD, like seagate Momentus.4, are really double or triple faster then my 2 years old hitachi? Even on my SATA controller?
    2. 667 MHz RAM compared to the new 1066MHz could be a bottleneck even at 3.3 GB?
    3. if I buy a new macbook pro, 2.53 GHz, 4GB RAM, 250GB HDD, how much performance difference will I notice between this new machine and mine with upgraded RAM, HDD & Os?
    It's a difference of about 1.280$ (1.499$ - 220$), so I would be really pleased to listen what you think and know about this kind of upgrade.
    Thanks a lot in advance.
    Fabio.

    Ok, I'll chime in with an opinion at least.
    Wait on the new book. Do a $90 ram/$29 OS upgrade and give up on spending money on a HDD.
    Ive been looking at upgrades to speed up my laptop till I can afford a new one and have decided to wait 12months till SSD prices drop to $1.75-$2.50/GB. I think I will windup with a faster computer than anything that will come out for another 12 more months. I love getting the latest and greatest, but since I wont be able to afford a whole new computer next year I will be happy with a much faster book.
    I am using 65% of my upgraded ram(4/3.3whatever), never all of my cpu and only 35% of my drive space. Also happy with my external LCD monitor.
    If this http://www.amazon.com/Intel-160GB-Mainstream-Retail-SSDSA2MH160G2R5/dp/B002IJA1E Q/ref=sr12?ie=UTF8&s=electronics&qid=1262409156&sr=8-2 hits $360 it will be a no brainer for me. The 'new computer' option will be right out the window.
    Marco

  • How much performance do I gain by enable MAT

    Hi
    I must try to ask you guys before am try to enable MAT
    I have never entered the bios before so am a little scared that I will f-up the system.
    Do anybody here at this forum with similar memory and componemts have tryed to this MAT function.
    Must it be "Turbo" or "Ultra turbo" to activate MAT?
    How much performance do I gain by this.....do I notice it in games....Battlefield 1942 for an example..or?
    If the system do not like it...what happens, shutdown or? unstable?
    Please give some advice.
    Mr Lithesteel

    MAT will give you at least a 5% increase in memory bandwidth when set to turbo mode regardless of the brand of memory you have. I own a pair of generic value ram and i see an increase of around 5 to 10 percent memory bandwidth when turbo mode is on, however my sytem fails to boot when MAT is set to ultra turbo, try to mess with the bios so you could figure out the best configuration of your system (you could measure memory bandwidth with sisoft sandra http://www.sisoftware.co.uk/), By the way your system is prepped up for hyperthreading, you own an 865pe which means your board is ready for hyperthreading, now unless you own the first generation of pentium4 procs which does not support ht, you are all set to run with hyperthreading, it would be nice if you upgrade to win xp pro or at least win2k so that you would be able to maximize your system's potential, Win XP home edition  does not support multi-threading so youre loosing a lot of performance with it. Hope i helped you with your question.

  • I need to sort very large Excel files and perform other operations.  How much faster would this be on a MacPro rather than my MacBook Pro i7, 2.6, 15R?

    I am a scientist and run my own business.  Money is tight.  I have some very large Excel files (~200MB) that I need to sort and perform logic operations on.  I currently use a MacBookPro (i7 core, 2.6GHz, 16GB 1600 MHz DDR3) and I am thinking about buying a multicore MacPro.  Some of the operations take half an hour to perform.  How much faster should I expect these operations to happen on a new MacPro?  Is there a significant speed advantage in the 6 core vs 4 core?  Practically speaking, what are the features I should look at and what is the speed bump I should expect if I go to 32GB or 64GB?  Related to this I am using a 32 bit version of Excel.  Is there a 64 bit spreadsheet that I can us on a Mac that has no limit on column and row size?

    Grant Bennet-Alder,
    It’s funny you mentioned using Activity Monitor.  I use it all the time to watch when a computation cycle is finished so I can avoid a crash.  I keep it up in the corner of my screen while I respond to email or work on a grant.  Typically the %CPU will hang at ~100% (sometimes even saying the application is not responding in red) but will almost always complete the cycle if I let it go for 30 minutes or so.  As long as I leave Excel alone while it is working it will not crash.  I had not thought of using the Activity Monitor as you suggested. Also I did not realize using a 32 bit application limited me to 4GB of memory for each application.  That is clearly a problem for this kind of work.  Is there any work around for this?   It seems like a 64-bit spreadsheet would help.  I would love to use the new 64 bit Numbers but the current version limits the number of rows and columns.  I tried it out on my MacBook Pro but my files don’t fit.
    The hatter,
    This may be the solution for me. I’m OK with assembling the unit you described (I’ve even etched my own boards) but feel very bad about needing to step away from Apple products.  When I started computing this was the sort of thing computers were designed to do.  Is there any native 64-bit spreadsheet that allows unlimited rows/columns, which will run on an Apple?  Excel is only 64-bit on their machines.
    Many thanks to both of you for your quick and on point answers!

  • Possible to check how much time an update statement on a table would take ?

    Hello @all
    I have a table with a fragmented Index, the table has an actula "user_updates" from 226'699.
    How can i find out how much time an update on this table takes ?
    i would like to check if there is any performance increase when i regroup the index (rebuild), cause the index has a fragementation of 85% now... (or should i delete the index completely) cause there are no user_seeks... only user_updates on the table...
    and i thought that indexes only makes sense if users are reading from the table... am i wrong ? (cause on every update from the table, the index (indexes) have to be updated too...
    Thanks and Regards
    Dominic

    Rebuilding the index will not likely result in a modification be quicker. At least not more than marginal. In fact, it might wven be slower, since if you currently have space on the index page for the new row and then rebuild so you *don't* have space then
    the index rebuild will make that update be slower (at least for the cases where you get page splits). 
    However if the index isn't used to find rows (any of the other three columns), then you have an index which only cost you and doesn't help you!
    Tibor Karaszi, SQL Server MVP |
    web | blog
    Tibor, check out this forum thread:
    http://social.technet.microsoft.com/Forums/sqlserver/en-US/64ad4f52-2fd8-4266-b4a4-5657c8870246/needed-more-answerers?forum=sqlgetstarted
    Ed Price, Power BI & SQL Server Customer Program Manager (Blog,
    Small Basic,
    Wiki Ninjas,
    Wiki)
    Answer an interesting question?
    Create a wiki article about it!

  • I have an older MacBook Intel 2 Duo processor 2.4Gh 4GB mem running 10.6.8.  Yahoo just informed me I must upgrade my Safari (5.1.10). How much can I upgrade from 10.6.8 without degrading performance?

    I have and older MacBook Intel 2 Duo processor 2.4 Ghz, 4GB mem, running 10.6.8 and Safari 5.1.10.  Yahoo has just informed me that they will no longer support Safari 5.1.10 and my question is how much higher than 10.6.8 can I go to get a better Safari before I start reducing performance on an older computer? It is about 6 years old but runs fine for my purposes.

    If you want to stay with 10.6, try Firefox which is still being updated.
    Firefox
    Check that your computer is compatible with Mountain Lion/Mavericks/Yosemite.
    To check the model number hold down the option/alt key, go to the Apple menu and select System Information.
    MacBook (Late 2008 Aluminum, or Early 2009 or newer) model number 5,1 or higher
    MacBook Pro (Mid/Late 2007 or newer) model number 3,1 or higher
    Your Mac needs:
    OS X v10.6.8 or OS X Lion already installed
    2 GB or more of memory (More is better - 4 GB minimum seems to be the consensus)
    8 GB or more of available space
    Check to make sure your applications are compatible. PowerPC applications are no longer supported after 10.6.      
    Application Compatibility
    Applications Compatibility (2)
    Do a backup before installing.
    Mountain Lion
    If your computer isn’t compatible, you might be able to upgrade to Lion.      
    Computer Compatibility - Lion                       Lion

  • Trying to determine how upgrades will affect performance

    I'm very unfamiliar with tech talk, so if someone can please help me out and do their best to explain this in lay terms that would be awesome.
    I am currently on the A0 cloud service instance and would like to know whether moving to the A1 cloud service instance would improve the speed performance of our web portal? I assume it would, but are there any metrics to quantify this? i.e. how much faster
    will the system be?
    Will any other aspects of the website's performance be improved, and if so, what?
    I'm trying to determine whether the upgrade would be worth the added subscription costs (price will go from $20 to $120 per month).
    Thanks!

    Hi,
    Moving from A0 VM size instance to A1 VM size will surely improve the speed performance.
    But the overall performance depends on many factors like network, website traffic , disk performance.
    Along with increasing the size, buying more bandwidth could be a good move as well.
    You May Refer to these links :
    http://azure.microsoft.com/en-in/pricing/calculator/
    https://msdn.microsoft.com/en-us/library/azure/dn197896.aspx.
    Feel free to connect with me for any more queries.
    Hope this helps.
    Thanks.

  • Will a $30 collection affect my score? If so, by how much?

    Recently started building my credit (May) with 2 secured cards. A month later I received a collection letter from AT&T for a $30 bill (which I was unaware of) - I called AT&T and told them the reason I had cancelled their service 17 months ago was because while I was doing online classes their internet connection would drop every 10 minutes - after putting me on hold the representative said he just closed the account and that the $30 was not owed anymore. After obtaining my credit reports (TU, EX, EQ) the $30 shows up on all 3 reports as a "Collection: Paid - Closed". I still can't obtain a FICO score, but when I do in another 3 months, will this $30 collection affect my score? If so, by how much? Any help would be appreciated and sorry if this is the wrong forum to be posting in.

    fixedronin wrote:
    Recently started building my credit (May) with 2 secured cards. A month later I received a collection letter from AT&T for a $30 bill (which I was unaware of) - I called AT&T and told them the reason I had cancelled their service 17 months ago was because while I was doing online classes their internet connection would drop every 10 minutes - after putting me on hold the representative said he just closed the account and that the $30 was not owed anymore. After obtaining my credit reports (TU, EX, EQ) the $30 shows up on all 3 reports as a "Collection: Paid - Closed". I still can't obtain a FICO score, but when I do in another 3 months, will this $30 collection affect my score? If so, by how much? Any help would be appreciated and sorry if this is the wrong forum to be posting in.It will definitely affect your credit score.  The $30 dollar amount really isn't as important as the collection itself is the harmful entry.  Impossible to tell how much as that is dependent on your overall credit file but it could be a significant amount.  Your best bet is to work with AT&T on a pay for delete.  If you have questions about that I would suggest visiting out rebuilding forum

  • Is there any way to know how much time swing client is on open state?

    Is there any way to know how much time swing client is on open state? My requirement is to show a message some time after the swing client open i.e., 4-5 hours.

    You could also consider using javax.swing.Timer and java.awt.event.ActionListener (or javax.swing.Action) which takes care of running the actionPerformed code on the EDT.
    db

  • Why can't there be a simple utility that shows me which device connected to my Airport is using how much of the bandwidth in a simple graphical or stats format without requiring me to be a level 10 Black Belt or Chuck Norris' paternal tooth fairy?

    Why can't there be a simple utility that shows me which device connected to my Airport is using how much of the bandwidth in a simple graphical or stats format without requiring me to be a level 10 Black Belt or Chuck Norris' paternal tooth fairy?
    I need to see who is consuming the most bandwidth and limit that user/device. A very simple and dare I say it, legal, moral, and normal wish.

    They are not overloading the Airport. They are overwhelming the capacity of your Internet connection.
    No. It's not "shared equally". That's not how packet switched networks function.
    Most consumer grade routers do not have the ability to restrict bandwidth use on a per machine basis. You need relatively expensive (but readily available) equipment to do that.
    How many people are on the network? It can't be that hard to hunt them down.

  • Buying a MacBook Pro in Seattle on a University visit. How much tax will I have to pay? I am attending the University of Washington in January so I assume I will be able to get student discount, but will I have to pay state tax - as I am not from the US?

    Buying a MacBook Pro in Seattle on a University visit. How much tax will I have to pay? I am attending the University of Washington in January so I assume I will be able to get student discount, but will I have to pay state tax - as I am not from the US?

    MarcusBooyah wrote:
    Thanks, I read somewhere that if you are not from the US you don't have to pay sales tax?
    You read wrong.

  • Hello I am coming to the united stats next month and i have a broken iphone 4 What are my options ? And could i replace it with the new iphone 5 or other apple products ? And how much will it cost me .  Thank you for you're time.

    Hello
    I am coming to the united stats next month and i have a broken iphone 4
    What are my options ?
    And could i replace it with the new iphone 5 or other apple products ?
    And how much will it cost me .
    Thank you for you're time.
    <Edited by Host>

    If that iPhone was orignally sold in the US, Out of Warranty replacement cost
    will be
    Phone 4, iPhone 3GS,
    iPhone 3G, Original iPhone
    $149
    Replacement will be an iPhone of the same color and GB. There is no option to upgrade
    using Out of Warranty replacement.

Maybe you are looking for

  • Problem deploying adf app to weblogic

    I've successfully migrated a 10.1.3.4 adf application to 11.1.1.2.0 and can run it on the integrated wls. However, I can't deploy/install to my standalone wls (10.3.2) without getting the following error during deployment/installation of the .ear: An

  • ECC document creation timing  for mismatch values in ECC and Bw report.

    hi gurus, i am extracting data from ECC at 10.pm (ist) and my process chain should start to load data at 2.30 am (ist) then in morning  i am refreshing BW report try to reconcilied from my extracted ECC but i am finding so many mismatsh values. so i

  • Output type for PO's

    We have a new PO type which we have assigned to a new Output type in transaction NACE have configured as follows. Application "EF" Purchase Order for Condition Records --> Key Combination ->Purchasing Output Determination: Document Type and tagged th

  • How to get the GTRID in string form

    Hello, I would like to include the Global Transaction Identifier (GTRID) in my application level logs. Preferrably it will be in the same format as it is in the ULOG. Is there a function to get the GTRID? Once retrieved, is there a function to conver

  • Downloading OS X Lion

    Was in the middle of downloading OS X Lion, when my wireless connection disconnected.  Now it's back up, but I can't tell if it's continuing to download or not.  And don't know how to check.  Any help is welcome!