Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering PostgreSQL 12

You're reading from   Mastering PostgreSQL 12 Advanced techniques to build and administer scalable and reliable PostgreSQL database applications

Arrow left icon
Product type Paperback
Published in Nov 2019
Publisher Packt
ISBN-13 9781838988821
Length 470 pages
Edition 3rd Edition
Languages
Concepts
Arrow right icon
Author (1):
Arrow left icon
Hans-Jürgen Schönig Hans-Jürgen Schönig
Author Profile Icon Hans-Jürgen Schönig
Hans-Jürgen Schönig
Arrow right icon
View More author details
Toc

Table of Contents (18) Chapters Close

Preface 1. Section 1: Basic Overview
2. PostgreSQL 12 Overview FREE CHAPTER 3. Understanding Transactions and Locking 4. Section 2: Advanced Concepts
5. Making Use of Indexes 6. Handling Advanced SQL 7. Log Files and System Statistics 8. Optimizing Queries for Good Performance 9. Writing Stored Procedures 10. Managing PostgreSQL Security 11. Handling Backup and Recovery 12. Making Sense of Backups and Replication 13. Deciding on Useful Extensions 14. Troubleshooting PostgreSQL 15. Migrating to PostgreSQL 16. Assessment 17. Other Books You May Enjoy

Utilizing windowing functions and analytics

Now that we have discussed ordered sets, it is time to take a look at windowing functions. Aggregates follow a fairly simple principle; take many rows and turn them into fewer, aggregated rows. A windowing function is different. It compares the current row with all rows in the group. The number of rows returned does not change. Here is an example:

test=# SELECT avg(production) FROM t_oil; 
    avg 
----------- 
 2607.5139  
(1 row) 

test=# SELECT country, year, production,
consumption, avg(production) OVER ()
FROM t_oil
LIMIT 4;
country | year | production | consumption | avg ---------+-------+------------+-------------+---------- USA | 1965 | 9014 | 11522 | 2607.5139 USA | 1966 | 9579 | 12100 | 2607.5139 USA | 1967 | 10219 | 12567 | 2607.5139 USA | 1968...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at R$50/month. Cancel anytime