• Thanks for your post Blah Baby.

    It seems that the Row_Number() clause is the cause of the slow running, rather than the CTE itself.

    (Worrying given the subject of my article was the former, and not the latter. 🙁 )

    For example, the following is fast:

    ;WITH BookCTE (BookTitle, BookEdition)

    AS

    (

    select booktitle, max(bookedition) as bookedition from books group by booktitle

    )

    SELECT b.BookTitle, b.BookEdition, b.BookPublishDate, b.BookAuthor

    FROM dbo.Books b INNER JOIN BookCTE c ON b.BookTitle=c.BookTitle AND b.BookEdition=c.BookEdition

    The issue of why ROW_NUMBER() is signifcantly slower as data volumes increase in this case, is counter-intuitive to me, and needs additional research.

    Thanks again.

    Lawrence.