SELECT * FROM TA a WHERE a.rx=264886 and
AN= (select max(AN) FROM TA where rx=a.rx)
I have a table TA with 8+ million rows and there is clustered PK on (rx, AN) columns. The count on rx=264886 is 6000+ rows. This query takes about 1 to 2 minutes to fetch data. Can anyone suggest how to improve performance and fetch data faster?
Thanks, VinnieI'd say:
SELECT TOP 1 * FROM TA WHERE rx=264886
ORDER BY an DESC
<edit>
That only works if there is only one row with an = max(an).|||that statement does not include the max(AN) for rn value. and when i just added "top 1" it did not improve any performance at all with an=(select max(an) ...) clause. Any other ideas?
Thanks, Vinnie
Wednesday, March 7, 2012
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment