November 22, 2017 at 7:41 am
Jeff Moden - Tuesday, November 21, 2017 9:10 PMHmmm... I haven't tried it but perhaps a BIGINT Sequence would work here.
This might be the path I'll take. The identiy column is almost meaningless, but it's reaching the bigint limit. A looping sequence might be the best bet.
November 22, 2017 at 8:15 am
Luis Cazares - Wednesday, November 22, 2017 7:41 AMJeff Moden - Tuesday, November 21, 2017 9:10 PMHmmm... I haven't tried it but perhaps a BIGINT Sequence would work here.This might be the path I'll take. The identiy column is almost meaningless, but it's reaching the bigint limit. A looping sequence might be the best bet.
Did you try it by naming the columns in the SELECT list instead of using (*)? My (probably over simplified) testing shows that using (*) produces a CI scan (causing the whole view to materialize) whereas using the named columns (even if it's ALL the columns) produces the desired CI Seek followed by an effective range scan.
--Jeff Moden
Change is inevitable... Change for the better is not.
November 22, 2017 at 8:47 am
Jeff Moden - Wednesday, November 22, 2017 8:15 AMDid you try it by naming the columns in the SELECT list instead of using (*)? My (probably over simplified) testing shows that using (*) produces a CI scan (causing the whole view to materialize) whereas using the named columns (even if it's ALL the columns) produces the desired CI Seek followed by an effective range scan.
I did. In fact, that was how I was testing because I originally assigned the values to variables to eliminate the display of the full view (before testing the filter).
Here are the execution plans (anonymized but might give you an idea of what's happening).
November 30, 2017 at 2:17 am
If returned sets are always filtered by PVID you may use this trick:
CustomData = ROW_NUMBER() OVER (PARTITION BY PVID ORDER BY (SELECT NULL))
_____________
Code for TallyGenerator
November 30, 2017 at 9:32 am
Sergiy - Thursday, November 30, 2017 2:17 AMIf returned sets are always filtered by PVID you may use this trick:
CustomData = ROW_NUMBER() OVER (PARTITION BY PVID ORDER BY (SELECT NULL))
Thank you, but that was slower because it stills calculates number for the whole table before filtering. And, with this option, it has to sort the data.
They approved using the SEQUENCE, but I just hope I won't encounter a wild 2008 version during deployment.
November 30, 2017 at 8:01 pm
Luis Cazares - Thursday, November 30, 2017 9:32 AMSergiy - Thursday, November 30, 2017 2:17 AMIf returned sets are always filtered by PVID you may use this trick:
CustomData = ROW_NUMBER() OVER (PARTITION BY PVID ORDER BY (SELECT NULL))
Thank you, but that was slower because it stills calculates number for the whole table before filtering. And, with this option, it has to sort the data.
They approved using the SEQUENCE, but I just hope I won't encounter a wild 2008 version during deployment.
They should just put the IDENTITY column back and call it a day.
--Jeff Moden
Change is inevitable... Change for the better is not.
December 1, 2017 at 10:34 am
Jeff Moden - Thursday, November 30, 2017 8:01 PMThey should just put the IDENTITY column back and call it a day.
They don't want to keep reseeding the identity.
Viewing 7 posts - 16 through 21 (of 21 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy