April 21, 2009 at 8:42 pm
Lynn Pettis (4/21/2009)
I'm not sure why it isn't working for you. I run the above code as is and it works correctly with the test data.
Can you post the DDL and code you are trying to run?
Yes, this code works for my sample data, but as much as I try, I can't get it to work for my real data.
I know I'm probably doing something wrong, and I really wish I could post my live code.
I'm going to look at it again in the morning and see if I come up with anything.
April 21, 2009 at 8:44 pm
Bevan keighley (4/21/2009)
Hi Goldie,Do you have an index on UserID?
Yes, Non-Unique, Non-Clustered.
April 21, 2009 at 9:09 pm
The only change to my code that I could suggest is 1) make sure you have declared the clustered index properly, and 2) change the index hint from 0 to 1.
April 21, 2009 at 9:16 pm
Goldie Graber (4/21/2009)
Bevan keighley (4/21/2009)
Hi Goldie,Do you have an index on UserID?
Yes, Non-Unique, Non-Clustered.
That is the problem. For the "quirky update" to work you need a clustered index on the columns you are doing the ordered update: CLUSTERED (UserID, CheckInID)
April 22, 2009 at 7:53 am
Lynn Pettis (4/21/2009)
Goldie Graber (4/21/2009)
Bevan keighley (4/21/2009)
Hi Goldie,Do you have an index on UserID?
Yes, Non-Unique, Non-Clustered.
That is the problem. For the "quirky update" to work you need a clustered index on the columns you are doing the ordered update: CLUSTERED (UserID, CheckInID)
I did create a clustered index like that on my temp table. I thought Bevan was talking about the original table.
April 22, 2009 at 8:07 am
RBarryYoung (4/21/2009)
Goldie Graber (4/21/2009)
Also, Barry, would you be able to explain your query?Sorry Goldie, not trying to be evasive but my brain isn't at 100% right now and this technique is hard to explain.
Here is an article where it is used and explained by Itzik Ben-Gan: http://www.sqlmag.com/Article/ArticleID/93606/sql_server_93606.html
Here's another thread where it is used and Jeff and I talk about it. http://www.sqlservercentral.com/Forums/Topic646593-338-1.aspx
Thanks for the links!
April 22, 2009 at 8:17 am
Goldie Graber (4/22/2009)
Lynn Pettis (4/21/2009)
Goldie Graber (4/21/2009)
Bevan keighley (4/21/2009)
Hi Goldie,Do you have an index on UserID?
Yes, Non-Unique, Non-Clustered.
That is the problem. For the "quirky update" to work you need a clustered index on the columns you are doing the ordered update: CLUSTERED (UserID, CheckInID)
I did create a clustered index like that on my temp table. I thought Bevan was talking about the original table.
Then I'd need to see the code you are running against your temp table and the ddl for your temp table (including indexes) to see why my code isn't working against it.
April 22, 2009 at 11:46 am
Goldie Graber (4/20/2009)
As a post script, I ended up using Bevan's method.It works well on tables with up to a few million records. Takes a minute or two.
When I had to run it on a table of 22 million it took over an hour!!
We will need to run this code in our production environment every once in a while, so I would appreciate if someone could help tweak this code or come up with a different approach.
On a different note, has anyone had trouble using Jeff's running total method before?
It seems to fail on tables with a few million records.
Is the table partitioned in any way?
--Jeff Moden
Change is inevitable... Change for the better is not.
April 22, 2009 at 11:51 am
Heh.... never mind... I didn't read down far enough.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 9 posts - 31 through 38 (of 38 total)
You must be logged in to reply to this topic. Login to reply