{"id":111191,"date":"2026-06-03T12:19:31","date_gmt":"2026-06-03T12:19:31","guid":{"rendered":"https:\/\/www.red-gate.com\/simple-talk\/?post_type=collection&#038;p=111191"},"modified":"2026-06-03T12:25:30","modified_gmt":"2026-06-03T12:25:30","slug":"window-function-performance-in-sql-server-a-complete-guide","status":"publish","type":"collection","link":"https:\/\/www.red-gate.com\/simple-talk\/collections\/window-function-performance-in-sql-server-a-complete-guide\/","title":{"rendered":"Window function performance in SQL Server: a complete guide"},"content":{"rendered":"\n<p><strong>Learn everything you need to know about window function performance in SQL Server with SQL veteran Fabiano Amorim&#8217;s detailed three-piece guide series. Everything is covered, including (but not limited to):<\/strong><\/p>\n\n\n<div class=\"block-core-list\">\n<ol class=\"wp-block-list\">\n<li>The basics of window functions &#8211; the history, what they are, etc;<br><br><\/li>\n\n\n\n<li>Why window functions are powerful (and so important to use);<br><br><\/li>\n\n\n\n<li>Window functions in various iterations of SQL Server over the years;<br><br><\/li>\n\n\n\n<li>The window function and window frame;<br><br><\/li>\n\n\n\n<li>Execution plans for running aggregates.<\/li>\n<\/ol>\n<\/div>\n\n\n<p>And much more! Here are the three guides for you to enjoy:<\/p>\n\n\n\n<section id=\"articles-list-block_90e76c721474a7575f19ec33fce7dab4\" class=\"articles-list my-5xl\">\n    <div class=\"grid gap-3xl\">\n        <div class=\"@container\">\n    <article class=\"flex gap-2xl items-center flex-col @md:flex-row-reverse\">\n        <div class=\"w-full @md:w-1\/3 flex items-center justify-center peer\">\n            <a href=\"https:\/\/www.red-gate.com\/simple-talk\/databases\/sql-server\/window-functions-in-sql-server-part-3-questions-of-performance\/\" aria-label=\"SQL Server Window Function Performance: Execution Plans for Running Aggregates, LEAD, LAG, FIRST_VALUE, LAST_VALUE\" class=\"no-underline relative aspect-3\/2 bg-gray-100 border border-gray-100 dark:border-gray-800 flex items-center justify-center flex-col gap-md w-full p-md\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t<span class=\"font-display-slab text-2xl text-base-black text-center w-full hyphens-auto\">SQL Server<\/span>\n\t\t\t\t\t\t\t\t\t\t\t<img loading=\"lazy\" decoding=\"async\" class=\"w-24\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/themes\/simple-talk-theme-2024\/assets\/images\/logos\/st-logo.svg\" alt=\"Simple-Talk Logo\" width=\"153\" height=\"33\">\n\t\t\t<\/a>        <\/div>\n        <div class=\"w-full @md:w-2\/3 overflow-auto group\/content-text\">\n            \n<div class=\"block mb-md align-middle\">\n            \n        <a\n        href=\"https:\/\/www.red-gate.com\/simple-talk\/author\/fabiano-amorim\/\"\n        class=\"group\/author inline align-middle no-style min-w-fit\"\n        rel=\"author\"\n    >\n        <img decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/11\/IMG-20240328-WA0020-Copy-2-150x150.jpg\"\n            alt=\"Image of author: Fabiano Amorim\" \n            class=\"rounded-full align-middle w-6 h-6 duration-200 inline-block object-cover\"\/>\n        <span class=\"group-hover\/author:text-brand-600 peer\/ftr-image:text-brand-600 group-hover\/author:dark:text-brand-400 peer\/ftr-image:dark:text-brand-400 group-hover\/author:underline min-w-fit align-middle duration-200\">Fabiano Amorim<\/span>\n    <\/a>\n\n        <span class=\"card__categories align-middle\">\n                                                        <span class=\"text-gray-600 align-middle dark:text-gray-400\">in<\/span>\n                    <a\n                    class=\"inline align-middle no-underline hover:text-brand-600 hover:dark:text-brand-400 hover:underline\"\n                    href=\"https:\/\/www.red-gate.com\/simple-talk\/databases\/sql-server\/\">\n                            SQL Server                    <\/a>\n                                        <\/span>\n<\/div>\n<a class=\"no-underline group\/content-text-lower\" href=\"https:\/\/www.red-gate.com\/simple-talk\/databases\/sql-server\/window-functions-in-sql-server-part-3-questions-of-performance\/ \">\n    <div>\n        <h1 class=\"\n            duration-200 mt-0 mb-1 text-xl\n            \n            peer-hover:group-[]\/content-text:text-brand-600\n            group-hover\/content-text-lower:text-brand-600\n\n            peer-hover:group-[]\/content-text:dark:text-brand-400\n            group-hover\/content-text-lower:dark:text-brand-400\n            \n            peer-hover:group-[]\/content-text:underline\n            group-hover\/content-text-lower:underline\n            \n        \">\n            SQL Server Window Function Performance: Execution Plans for Running Aggregates, LEAD, LAG, FIRST_VALUE, LAST_VALUE        <\/h1>\n                    <p class=\"mb-0\">\n                Performance analysis of SQL Server window functions &#8211; comparing execution plans for running aggregations (OVER + ORDER BY), LEAD and&#8230;            <\/p>\n            <\/div>\n            <div class=\"flex items-center gap-1 mt-md\">\n            <time>04 January 2012<\/time>\n            <span class=\"w-1 h-1 bg-current\tinline-block my-auto rounded-full\"><\/span>\n            <span>12 min read<\/span>\n                    <\/div>\n    <\/a>        <\/div>\n    <\/article>\n<\/div>\n\n\n<div class=\"@container\">\n    <article class=\"flex gap-2xl items-center flex-col @md:flex-row-reverse\">\n        <div class=\"w-full @md:w-1\/3 flex items-center justify-center peer\">\n            <a href=\"https:\/\/www.red-gate.com\/simple-talk\/databases\/sql-server\/window-functions-in-sql-server-part-2-the-frame\/\" aria-label=\"Window Functions in SQL Server: Part 2-The Frame\" class=\"no-underline relative aspect-3\/2 bg-gray-100 border border-gray-100 dark:border-gray-800 flex items-center justify-center flex-col gap-md w-full p-md\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t<span class=\"font-display-slab text-2xl text-base-black text-center w-full hyphens-auto\">SQL Server<\/span>\n\t\t\t\t\t\t\t\t\t\t\t<img loading=\"lazy\" decoding=\"async\" class=\"w-24\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/themes\/simple-talk-theme-2024\/assets\/images\/logos\/st-logo.svg\" alt=\"Simple-Talk Logo\" width=\"153\" height=\"33\">\n\t\t\t<\/a>        <\/div>\n        <div class=\"w-full @md:w-2\/3 overflow-auto group\/content-text\">\n            \n<div class=\"block mb-md align-middle\">\n            \n        <a\n        href=\"https:\/\/www.red-gate.com\/simple-talk\/author\/fabiano-amorim\/\"\n        class=\"group\/author inline align-middle no-style min-w-fit\"\n        rel=\"author\"\n    >\n        <img decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/11\/IMG-20240328-WA0020-Copy-2-150x150.jpg\"\n            alt=\"Image of author: Fabiano Amorim\" \n            class=\"rounded-full align-middle w-6 h-6 duration-200 inline-block object-cover\"\/>\n        <span class=\"group-hover\/author:text-brand-600 peer\/ftr-image:text-brand-600 group-hover\/author:dark:text-brand-400 peer\/ftr-image:dark:text-brand-400 group-hover\/author:underline min-w-fit align-middle duration-200\">Fabiano Amorim<\/span>\n    <\/a>\n\n        <span class=\"card__categories align-middle\">\n                                                        <span class=\"text-gray-600 align-middle dark:text-gray-400\">in<\/span>\n                    <a\n                    class=\"inline align-middle no-underline hover:text-brand-600 hover:dark:text-brand-400 hover:underline\"\n                    href=\"https:\/\/www.red-gate.com\/simple-talk\/databases\/sql-server\/\">\n                            SQL Server                    <\/a>\n                                        <\/span>\n<\/div>\n<a class=\"no-underline group\/content-text-lower\" href=\"https:\/\/www.red-gate.com\/simple-talk\/databases\/sql-server\/window-functions-in-sql-server-part-2-the-frame\/ \">\n    <div>\n        <h1 class=\"\n            duration-200 mt-0 mb-1 text-xl\n            \n            peer-hover:group-[]\/content-text:text-brand-600\n            group-hover\/content-text-lower:text-brand-600\n\n            peer-hover:group-[]\/content-text:dark:text-brand-400\n            group-hover\/content-text-lower:dark:text-brand-400\n            \n            peer-hover:group-[]\/content-text:underline\n            group-hover\/content-text-lower:underline\n            \n        \">\n            Window Functions in SQL Server: Part 2-The Frame        <\/h1>\n                    <p class=\"mb-0\">\n                Fabiano continues his introduction to SQL Server&#8217;s implementation of the window functions by giving a history of what got implemented&#8230;            <\/p>\n            <\/div>\n            <div class=\"flex items-center gap-1 mt-md\">\n            <time>24 November 2011<\/time>\n            <span class=\"w-1 h-1 bg-current\tinline-block my-auto rounded-full\"><\/span>\n            <span>13 min read<\/span>\n                    <\/div>\n    <\/a>        <\/div>\n    <\/article>\n<\/div>\n\n\n<div class=\"@container\">\n    <article class=\"flex gap-2xl items-center flex-col @md:flex-row-reverse\">\n        <div class=\"w-full @md:w-1\/3 flex items-center justify-center peer\">\n            <a href=\"https:\/\/www.red-gate.com\/simple-talk\/databases\/sql-server\/window-functions-in-sql-server\/\" aria-label=\"Window Functions in SQL Server\" class=\"no-underline relative aspect-3\/2 bg-gray-100 border border-gray-100 dark:border-gray-800 flex items-center justify-center flex-col gap-md w-full p-md\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t<span class=\"font-display-slab text-2xl text-base-black text-center w-full hyphens-auto\">SQL Server<\/span>\n\t\t\t\t\t\t\t\t\t\t\t<img loading=\"lazy\" decoding=\"async\" class=\"w-24\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/themes\/simple-talk-theme-2024\/assets\/images\/logos\/st-logo.svg\" alt=\"Simple-Talk Logo\" width=\"153\" height=\"33\">\n\t\t\t<\/a>        <\/div>\n        <div class=\"w-full @md:w-2\/3 overflow-auto group\/content-text\">\n            \n<div class=\"block mb-md align-middle\">\n            \n        <a\n        href=\"https:\/\/www.red-gate.com\/simple-talk\/author\/fabiano-amorim\/\"\n        class=\"group\/author inline align-middle no-style min-w-fit\"\n        rel=\"author\"\n    >\n        <img decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/11\/IMG-20240328-WA0020-Copy-2-150x150.jpg\"\n            alt=\"Image of author: Fabiano Amorim\" \n            class=\"rounded-full align-middle w-6 h-6 duration-200 inline-block object-cover\"\/>\n        <span class=\"group-hover\/author:text-brand-600 peer\/ftr-image:text-brand-600 group-hover\/author:dark:text-brand-400 peer\/ftr-image:dark:text-brand-400 group-hover\/author:underline min-w-fit align-middle duration-200\">Fabiano Amorim<\/span>\n    <\/a>\n\n        <span class=\"card__categories align-middle\">\n                                                        <span class=\"text-gray-600 align-middle dark:text-gray-400\">in<\/span>\n                    <a\n                    class=\"inline align-middle no-underline hover:text-brand-600 hover:dark:text-brand-400 hover:underline\"\n                    href=\"https:\/\/www.red-gate.com\/simple-talk\/databases\/sql-server\/\">\n                            SQL Server                    <\/a>\n                                        <\/span>\n<\/div>\n<a class=\"no-underline group\/content-text-lower\" href=\"https:\/\/www.red-gate.com\/simple-talk\/databases\/sql-server\/window-functions-in-sql-server\/ \">\n    <div>\n        <h1 class=\"\n            duration-200 mt-0 mb-1 text-xl\n            \n            peer-hover:group-[]\/content-text:text-brand-600\n            group-hover\/content-text-lower:text-brand-600\n\n            peer-hover:group-[]\/content-text:dark:text-brand-400\n            group-hover\/content-text-lower:dark:text-brand-400\n            \n            peer-hover:group-[]\/content-text:underline\n            group-hover\/content-text-lower:underline\n            \n        \">\n            Window Functions in SQL Server        <\/h1>\n                    <p class=\"mb-0\">\n                When SQL Server introduced Window Functions in SQL Server 2005, it was done in a rather tentative way, with only&#8230;            <\/p>\n            <\/div>\n            <div class=\"flex items-center gap-1 mt-md\">\n            <time>27 October 2011<\/time>\n            <span class=\"w-1 h-1 bg-current\tinline-block my-auto rounded-full\"><\/span>\n            <span>12 min read<\/span>\n                    <\/div>\n    <\/a>        <\/div>\n    <\/article>\n<\/div>\n\n\n            <\/div>\n<\/section>\n","protected":false},"excerpt":{"rendered":"<p>Learn everything you need to know about window function performance in SQL Server.&hellip;<\/p>\n","protected":false},"author":343608,"featured_media":0,"template":"","tags":[159402,4150,4151],"coauthors":[159208],"class_list":["post-111191","collection","type-collection","status-publish","hentry","tag-fawindowfunctions","tag-sql","tag-sql-server"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/collection\/111191","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/collection"}],"about":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/types\/collection"}],"author":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/users\/343608"}],"wp:attachment":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/media?parent=111191"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/tags?post=111191"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/coauthors?post=111191"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}