SlideShare ist ein Scribd-Unternehmen logo
1 von 30
Downloaden Sie, um offline zu lesen
Window functions in MySQL 8.0
Presented by
Sri Sakthivel M.D.
www.mydbops.com info@mydbops.com
About Mydbops
● Founded in 2015, HQ in Bangalore India with 450+ customer base across the globe.
● Mydbops is on Database Consulting with core specialization on MySQL,MongoDB,PostgreSQL
Administration and Support.
● We have expert team with 30+ certified DBA’s providing full time support and currently managing 400+
servers.
● Mydbops was created with a motto of developing a Devops model for Database administration offering
24*7 expert remote DBA support.
● We help organisations to architect and scale systems in MySQL/Mongo by implementing the advanced
technologies in industry which are completely open source.
● We are leading solution provider in the market for all sort of cloud based database deployments and
management.
About Me
● MySQL/MariaDB DBA Expert.
● AWS Solution Architect Associate
● Expertise in Gallera / PXC / InnoDB clusters
● Expertise in MySQL load balancers ProxySQL / Maxscale
● Active MySQL Blogger.
● Interested on DB Fine Tuning and SQL Load Balancers.
● Twitter : @hercules7sakthi
● Hobbies : Bike riding and like good Food.
Agenda
● What is Window function ?
● Window function vs MySQL
● Window function Syntax
● Types of Window function
● Query Example with Window function
● Conclusion
What is Window function ?
Window functions enable users to perform calculations against partitions (i.e. subgroups or sections) of a
result set .
Window functions increase the efficiency and reduce the complexity of queries that analyze partitions
(windows) of a data set by providing an alternative to more complex SQL concepts, e.g. derived queries.
Window functions do not cause rows to become grouped into a single output row, the rows retain their
separate identities and an aggregated value will be added to each row.
Window function vs MySQL
● Frequently requested feature for data analysis
● Supports since version MySQL 8.0
● Supports aggregate & most non aggregate functions
● Solving analytical queries & Improves performance
● Flexible & ease to use
Window function Syntax
● Partition definition
● Order definition
● Frame definition
Window function Syntax
Partition definition ( Syntax ) :
● Helps to create the partition window over the column .
windows_function_name(expression) OVER({PARTITION BY <definition>})
example :
root@localhost>select a.method,a.loanId,a.amt,a.Total from (select method,loanId,amt, sum(amt) over(partition by method) as Total
from yp_payments) a group by a.method limit 3;
+--------+---------+------+--------------------+
| method | loanId | amt | Total |
+--------+---------+------+--------------------+
| 118 | 6768178 | 2233 | 12176312573.809387 |
| 122 | 4953108 | 1655 | 1036464 |
| 167 | 1975693 | 8235 | 634836 |
+--------+---------+------+--------------------+
Window function Syntax
Order definition (syntax) :
● Can use the ORDER BY inside the function OVER()
windows_function_name(expression) OVER({ORDER BY ASC | DESC})
example :
root@localhost:>select a.method,a.loanId,a.amt,a.Total from (select method,loanId,amt, sum(amt) over(order by method desc) as Total
from yp_payments) a group by a.method limit 3;
+--------+---------+------+--------------------+
| method | loanId | amt | Total |
+--------+---------+------+--------------------+
| 994 | 7108021 | 2 | 67 |
| 518 | 6040015 | 4118 | 5050588984.439701 |
| 489 | 4703452 | 1784 | 10805334804.439701 |
+--------+---------+------+--------------------+
3 rows in set (26.15 sec)
Window function Syntax
Frame definition :
● Can compute running totals for each row.
● Can compute rolling averages.
Syntax :
windows_function_name(expression) OVER(PARTITION BY <expression> ROWS UNBOUNDED PRECEDING)
windows_function_name(expression) OVER(PARTITION BY <expression> ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING)
Window function Syntax
Frame definition :
Example : running incremental totals for each method ,
root@localhost:yp>select a.method,a.loanId,a.amt,a.incremental_Total from (select method,loanId,amt,sum(amt) over(partition by
method rows unbounded preceding) as incremental_Total from yp_payments where method=489) a limit 5;
+--------+---------+------+-------------------+
| method | loanId | amt | incremental_Total |
+--------+---------+------+-------------------+
| 489 | 6758312 | 2233 | 2233 |
| 489 | 6457319 | 2677 | 4910 |
| 489 | 6094261 | 8387 | 13297 |
| 489 | 6240342 | 5148 | 18445 |
| 489 | 6734211 | 3604 | 22049 |
+--------+---------+------+-------------------+
Window function Syntax
Frame definition :
Example : rolling averages for each method,
root@localhost:>select a.method,a.loanId,a.amt,a.rolling_Avg from (select method,loanId,amt, avg(amt) over(partition by method rows
between 1 preceding and 1 following) as rolling_Avg from yp_payments where method=489) a limit 5;
+--------+---------+------+-------------------+
| method | loanId | amt | rolling_Avg |
+--------+---------+------+-------------------+
| 489 | 6758312 | 2233 | 2455 |
| 489 | 6457319 | 2677 | 4432.333333333333 |
| 489 | 6094261 | 8387 | 5404 |
| 489 | 6240342 | 5148 | 5713 |
| 489 | 6734211 | 3604 | 4290 |
+--------+---------+------+-------------------+
5 rows in set (12.73 sec)
Types of Window function
● CUME_DIST()
● DENSE_RANK()
● RANK()
● FIRST_VALUE()
● LAST_VALUE()
● NTH_VALUE()
● NTILE()
● LEAD()
● LAG()
● PERCENT_RANK()
● ROW_NUMBER()
Types of Window functions
CUM_DIST() :
● Returns the cumulative distribution of a value within a group of values .
root@localhost>select method,loanId,amt,cume_dist() over( partition by method order by amt) as cummulative_dist from yp_payments where method=994 limit 10;
+--------+---------+------+---------------------+
| method | loanId | amt | cummulative_dist |
+--------+---------+------+---------------------+
| 994 | 6966384 | 1 | 0.23684210526315788 |
| 994 | 6966668 | 1 | 0.23684210526315788 |
| 994 | 7101985 | 1 | 0.23684210526315788 |
| 994 | 7102975 | 1 | 0.23684210526315788 |
| 994 | 7108441 | 1 | 0.23684210526315788 |
| 994 | 7109122 | 1 | 0.23684210526315788 |
| 994 | 7110529 | 1 | 0.23684210526315788 |
| 994 | 7111399 | 1 | 0.23684210526315788 |
| 994 | 7112577 | 1 | 0.23684210526315788 |
| 994 | 6965596 | 2 | 1 |
+--------+---------+------+---------------------+
10 rows in set (0.00 sec)
Types of Window functions
DENSE_RANK() :
● Rank of current row within its partition, without gaps
root@localhost>select method,loanId,amt, dense_rank() over(order by amt) as dens_rank from yp_payments group by method limit 5;
+--------+---------+------+------------------+
| method | loanId | amt | dens_rank |
+--------+---------+------+------------------+
| 489 | 713157 | 2 | 1 |
| 518 | 775470 | 2 | 1 |
| 994 | 6965596 | 2 | 1 |
| 167 | 11801 | 344 | 2 |
| 122 | 28101 | 1075 | 3 |
+--------+---------+------+------------------+
5 rows in set (4.83 sec)
Types of Window functions
RANK() :
● Rank of current row within its partition, with gaps
root@localhost:yp>select method,loanId,amt, rank() over(order by amt) as _mrank from yp_payments group by method limit 5;
+--------+---------+------+------------------+
| method | loanId | amt | _mrank |
+--------+---------+------+------------------+
| 489 | 713157 | 2 | 1 |
| 518 | 775470 | 2 | 1 |
| 994 | 6965596 | 2 | 1 |
| 167 | 11801 | 344 | 4 |
| 122 | 28101 | 1075 | 5 |
+--------+---------+------+------------------+
5 rows in set (8.41 sec)
Types of Window functions
FIRST_VALUE() :
1. Value of argument from first row of window frame
root@localhost:yp>select method,loanId,amt, first_value(amt) over( partition by method order by amt) as 1st_value from yp_payments
where method in (994,323);
+--------+---------+------+------------------+
| method | loanId | amt | 1st_value |
+--------+---------+------+------------------+
| 323 | 5217241 | 70 | 70 |
| 323 | 769665 | 8118 | 70 |
| 323 | 671604 | 8768 | 70 |
| 994 | 6966384 | 1 | 1 |
| 994 | 6966668 | 1 | 1 |
| 994 | 7101985 | 1 | 1 |
+--------+---------+------+------------------+
Types of Window functions
LAST_VALUE() :
Value of argument from last row of window frame
root@localhost>select method,loanId,amt, last_value(amt) over( partition by method order by amt) as lst_value from yp_payments where
method in (994,323);
+--------+---------+------+------------------+
| method | loanId | amt | lst_value |
+--------+---------+------+------------------+
| 323 | 5217241 | 8768 | 70 |
| 323 | 769665 | 8118 | 70 |
| 323 | 671604 | 70 | 70 |
| 994 | 6966384 | 1 | 1 |
| 994 | 6966668 | 1 | 1 |
| 994 | 7101985 | 1 | 1 |
+--------+---------+------+------------------+
Types of Window functions
NTH_VALUE() :
● Value of argument from N-th row of window frame
root@localhost>select method,loanId,amt, nth_value(amt,3) over( partition by method ) as n_value from yp_payments where method in
(994,323);
+--------+---------+------+------------------+
| method | loanId | amt | n_value |
+--------+---------+------+------------------+
| 323 | 170645 | 5244 | 3200 |
| 323 | 150974 | 3404 | 3200 |
| 323 | 135282 | 3200 | 3200 |
| 323 | 5217241 | 70 | 3200 |
| 994 | 6965596 | 2 | 2 |
| 994 | 6966384 | 1 | 2 |
| 994 | 6966384 | 2 | 2 |
+--------+---------+------+------------------+
Types of Window functions
NTILE() :
● Bucket number of current row within its partition.
root@localhost:yp>select method,loanId,amt, ntile(100) over( partition by method ) as tile_value from yp_payments where method in
(994,323);
+--------+---------+------+------------------+
| method | loanId | amt | tile_value |
+--------+---------+------+------------------+
| 323 | 170645 | 5244 | 1 |
| 323 | 150974 | 3404 | 2 |
. . . . . . . . .
| 323 | 5217241 | 70 | 79 |
| 994 | 6965596 | 2 | 1 |
| 994 | 6966384 | 1 | 2 |
. . . . . . . . .
| 994 | 7112577 | 2 | 38 |
+--------+---------+------+------------------+
Types of Window functions
LEAD() :
● Value of argument from row leading current row within partition
root@localhost>select method,loanId,amt, lead(amt) over( partition by method ) as lead_smt, amt - lead(amt) over(partition by method)
as lead_diff from yp_payments where method in (323);
+--------+---------+------+----------+-----------+
| method | loanId | amt | lead_smt | lead_diff |
+--------+---------+------+----------+-----------+
| 323 | 170645 | 5244 | 3404 | 1840 |
| 323 | 150974 | 3404 | 3200 | 204 |
| 323 | 135282 | 3200 | 5174 | -1974 |
| 323 | 288222 | 5174 | 5699 | -525 |
| 323 | 376684 | 5699 | 5489 | 210 |
| 323 | 432680 | 5489 | 5074 | 415 |
| 323 | 506159 | 5074 | 3500 | 1574 |
. . . . . . . . .
+--------+---------+------+----------+-----------+
79 rows in set (0.00 sec)
Types of Window functions
LAG() :
● Value of argument from row lagging current row within partition
root@localhost>select method,loanId,amt, lag(amt) over( partition by method ) as lag_amt, amt - lag(amt) over(partition by method) as
lag_diff from yp_payments where method in (323);
+--------+---------+------+---------+----------+
| method | loanId | amt | lag_amt | lag_diff |
+--------+---------+------+---------+----------+
| 323 | 170645 | 5244 | NULL | NULL |
| 323 | 150974 | 3404 | 5244 | -1840 |
| 323 | 135282 | 3200 | 3404 | -204 |
| 323 | 288222 | 5174 | 3200 | 1974 |
| 323 | 376684 | 5699 | 5174 | 525 |
| 323 | 432680 | 5489 | 5699 | -210 |
| 323 | 506159 | 5074 | 5489 | -415 |
. . . . . . .
+--------+---------+------+---------+----------+
Types of Window functions
PERSENT_RANK() :
● Percentage rank value
root@localhost>select method,loanId,amt, percent_rank() over( order by method) as rank_per from yp_payments where method in
(994,323);
+--------+---------+------+--------------------+
| method | loanId | amt | rank_per |
+--------+---------+------+--------------------+
| 323 | 170645 | 5244 | 0 |
. . . . . . . . . .. . . . . . . .
| 323 | 5217241 | 70 | 0 |
| 994 | 6965596 | 2 | 0.6810344827586207 |
. . . . . . . . . .. . . . . . . .
| 994 | 7112577 | 2 | 0.6810344827586207 |
+--------+---------+------+--------------------+
117 rows in set (0.00 sec)
Types of Window functions
ROW_NUMBER() :
● Percentage rank value
root@localhost>select method,loanId,amt, row_number() over( order by method ) as rw_num from yp_payments where method in (994,323);
+--------+---------+------+------------------+
| method | loanId | amt | rw_num |
+--------+---------+------+------------------+
| 323 | 170645 | 5244 | 1 |
| 323 | 150974 | 3404 | 2 |
| 323 | 135282 | 3200 | 3 |
| 323 | 288222 | 5174 | 4 |
| 323 | 376684 | 5699 | 5 |
..... . . . . . . . .. . . . . .
| 994 | 7112577 | 2 | 117 |
+--------+---------+------+------------------+
117 rows in set (0.01 sec)
Query example with windows function
● Need top 2 methods ( column ) from yp_payments table, which having huge amount
● The amount should be above 50000 thousands
● Need to know the highest amount from both methods
Query example with windows function
Using windows function :
root@localhost> select a.method,a.loanId,a.amt from (select method,loanId,amt,rank() over(partition by method order by amt desc) as
rank_gap from yp_payments where amt > 50000) a where a.rank_gap=1 order by a.amt desc limit 2;
+--------+---------+--------+
| method | loanId | amt |
+--------+---------+--------+
| 118 | 448 | 508698 |
| 518 | 5377057 | 92839 |
+--------+---------+--------+
2 rows in set (3.02 sec)
Execution Time : 3 seconds
+----+-------------+-------------+------------+------+---------------+-------------+---------+-------+---------+----------+-----------------------------+
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+----+-------------+-------------+------------+------+---------------+-------------+---------+-------+---------+----------+-----------------------------+
| 1 | PRIMARY | <derived2> | NULL | ref | <auto_key0> | <auto_key0> | 8 | const | 10 | 100.00 | Using filesort |
| 2 | DERIVED | yp_payments | NULL | ALL | NULL | NULL | NULL | NULL | 5549711 | 33.33 |Using where; Using filesort |
+----+-------------+-------------+------------+------+---------------+-------------+---------+-------+---------+----------+-----------------------------+
2 rows in set, 2 warnings (0.00 sec)
Query example with windows function
normal query :
root@localhost>select method,loanId,max(amt) from yp_payments where amt > 50000 group by method order by amt desc limit 2;
+--------+--------+----------+
| method | loanId | max(amt) |
+--------+--------+----------+
| 118 | 448 | 508698 |
| 518 |5377057 | 92839 |
+--------+--------+----------+
2 rows in set (12.00 sec)
Execution Time : 12 seconds
+----+-------------+-------------+------------+-------+-----------------------------------+---------------------------+---------+------+---------+----------+----------------------------------------------+
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+----+-------------+-------------+------------+-------+-----------------------------------+---------------------------+---------+------+---------+----------+----------------------------------------------+
| 1 | SIMPLE | yp_payments | NULL | index | fk_yp_payments_method_idx,idx_met | fk_yp_payments_method_idx | 4 | NULL | 5549920 | 33.33 | Using where; Using temporary; Using filesort |
+----+-------------+-------------+------------+-------+-----------------------------------+---------------------------+---------+------+---------+----------+----------------------------------------------+
1 row in set, 1 warning (0.00 sec)
Query example with windows function
● GROUP BY & ORDER BY required for normal query to sort the results
● Query without windows function is creating temporary table
● Temporary tables are very critical ( disk temporary tables) on huge data set
For an enterprise class Database support and
DB managed services reach
Mydbops
Email : info@mydbops.com
Thank you !!!

Weitere ähnliche Inhalte

Was ist angesagt?

PostgreSQL query planner's internals
PostgreSQL query planner's internalsPostgreSQL query planner's internals
PostgreSQL query planner's internalsAlexey Ermakov
 
MySQL 8.0 Optimizer Guide
MySQL 8.0 Optimizer GuideMySQL 8.0 Optimizer Guide
MySQL 8.0 Optimizer GuideMorgan Tocker
 
[오픈소스컨설팅]Day #1 MySQL 엔진소개, 튜닝, 백업 및 복구, 업그레이드방법
[오픈소스컨설팅]Day #1 MySQL 엔진소개, 튜닝, 백업 및 복구, 업그레이드방법[오픈소스컨설팅]Day #1 MySQL 엔진소개, 튜닝, 백업 및 복구, 업그레이드방법
[오픈소스컨설팅]Day #1 MySQL 엔진소개, 튜닝, 백업 및 복구, 업그레이드방법Ji-Woong Choi
 
Oracle Course
Oracle CourseOracle Course
Oracle Courserspaike
 
Oracle statistics by example
Oracle statistics by exampleOracle statistics by example
Oracle statistics by exampleMauro Pagano
 
PostgreSQL Database Slides
PostgreSQL Database SlidesPostgreSQL Database Slides
PostgreSQL Database Slidesmetsarin
 
MySQL Performance Schema in Action
MySQL Performance Schema in ActionMySQL Performance Schema in Action
MySQL Performance Schema in ActionSveta Smirnova
 
SQL Joins With Examples | Edureka
SQL Joins With Examples | EdurekaSQL Joins With Examples | Edureka
SQL Joins With Examples | EdurekaEdureka!
 
Histograms in MariaDB, MySQL and PostgreSQL
Histograms in MariaDB, MySQL and PostgreSQLHistograms in MariaDB, MySQL and PostgreSQL
Histograms in MariaDB, MySQL and PostgreSQLSergey Petrunya
 
Oracle Table Partitioning - Introduction
Oracle Table Partitioning  - IntroductionOracle Table Partitioning  - Introduction
Oracle Table Partitioning - IntroductionMyOnlineITCourses
 
Query Optimization with MySQL 8.0 and MariaDB 10.3: The Basics
Query Optimization with MySQL 8.0 and MariaDB 10.3: The BasicsQuery Optimization with MySQL 8.0 and MariaDB 10.3: The Basics
Query Optimization with MySQL 8.0 and MariaDB 10.3: The BasicsJaime Crespo
 
Window functions with SQL Server 2016
Window functions with SQL Server 2016Window functions with SQL Server 2016
Window functions with SQL Server 2016Mark Tabladillo
 
MySQL Performance Tuning: Top 10 Tips
MySQL Performance Tuning: Top 10 TipsMySQL Performance Tuning: Top 10 Tips
MySQL Performance Tuning: Top 10 TipsOSSCube
 
Advanced PLSQL Optimizing for Better Performance
Advanced PLSQL Optimizing for Better PerformanceAdvanced PLSQL Optimizing for Better Performance
Advanced PLSQL Optimizing for Better PerformanceZohar Elkayam
 

Was ist angesagt? (20)

PostgreSQL query planner's internals
PostgreSQL query planner's internalsPostgreSQL query planner's internals
PostgreSQL query planner's internals
 
Sql joins
Sql joinsSql joins
Sql joins
 
Oracle SQL Advanced
Oracle SQL AdvancedOracle SQL Advanced
Oracle SQL Advanced
 
MySQL 8.0 Optimizer Guide
MySQL 8.0 Optimizer GuideMySQL 8.0 Optimizer Guide
MySQL 8.0 Optimizer Guide
 
[오픈소스컨설팅]Day #1 MySQL 엔진소개, 튜닝, 백업 및 복구, 업그레이드방법
[오픈소스컨설팅]Day #1 MySQL 엔진소개, 튜닝, 백업 및 복구, 업그레이드방법[오픈소스컨설팅]Day #1 MySQL 엔진소개, 튜닝, 백업 및 복구, 업그레이드방법
[오픈소스컨설팅]Day #1 MySQL 엔진소개, 튜닝, 백업 및 복구, 업그레이드방법
 
Date and time functions in mysql
Date and time functions in mysqlDate and time functions in mysql
Date and time functions in mysql
 
SQL Overview
SQL OverviewSQL Overview
SQL Overview
 
Oracle Course
Oracle CourseOracle Course
Oracle Course
 
Oracle statistics by example
Oracle statistics by exampleOracle statistics by example
Oracle statistics by example
 
PostgreSQL Database Slides
PostgreSQL Database SlidesPostgreSQL Database Slides
PostgreSQL Database Slides
 
DBMS Notes: DDL DML DCL
DBMS Notes: DDL DML DCLDBMS Notes: DDL DML DCL
DBMS Notes: DDL DML DCL
 
MySQL Performance Schema in Action
MySQL Performance Schema in ActionMySQL Performance Schema in Action
MySQL Performance Schema in Action
 
SQL Joins With Examples | Edureka
SQL Joins With Examples | EdurekaSQL Joins With Examples | Edureka
SQL Joins With Examples | Edureka
 
Histograms in MariaDB, MySQL and PostgreSQL
Histograms in MariaDB, MySQL and PostgreSQLHistograms in MariaDB, MySQL and PostgreSQL
Histograms in MariaDB, MySQL and PostgreSQL
 
View & index in SQL
View & index in SQLView & index in SQL
View & index in SQL
 
Oracle Table Partitioning - Introduction
Oracle Table Partitioning  - IntroductionOracle Table Partitioning  - Introduction
Oracle Table Partitioning - Introduction
 
Query Optimization with MySQL 8.0 and MariaDB 10.3: The Basics
Query Optimization with MySQL 8.0 and MariaDB 10.3: The BasicsQuery Optimization with MySQL 8.0 and MariaDB 10.3: The Basics
Query Optimization with MySQL 8.0 and MariaDB 10.3: The Basics
 
Window functions with SQL Server 2016
Window functions with SQL Server 2016Window functions with SQL Server 2016
Window functions with SQL Server 2016
 
MySQL Performance Tuning: Top 10 Tips
MySQL Performance Tuning: Top 10 TipsMySQL Performance Tuning: Top 10 Tips
MySQL Performance Tuning: Top 10 Tips
 
Advanced PLSQL Optimizing for Better Performance
Advanced PLSQL Optimizing for Better PerformanceAdvanced PLSQL Optimizing for Better Performance
Advanced PLSQL Optimizing for Better Performance
 

Ähnlich wie Window functions in MySQL 8.0

MySQL/MariaDB query optimizer tuning tutorial from Percona Live 2013
MySQL/MariaDB query optimizer tuning tutorial from Percona Live 2013MySQL/MariaDB query optimizer tuning tutorial from Percona Live 2013
MySQL/MariaDB query optimizer tuning tutorial from Percona Live 2013Sergey Petrunya
 
Advanced Query Optimizer Tuning and Analysis
Advanced Query Optimizer Tuning and AnalysisAdvanced Query Optimizer Tuning and Analysis
Advanced Query Optimizer Tuning and AnalysisMYXPLAIN
 
Adaptive Query Optimization
Adaptive Query OptimizationAdaptive Query Optimization
Adaptive Query OptimizationAnju Garg
 
Common schema my sql uc 2012
Common schema   my sql uc 2012Common schema   my sql uc 2012
Common schema my sql uc 2012Roland Bouman
 
Common schema my sql uc 2012
Common schema   my sql uc 2012Common schema   my sql uc 2012
Common schema my sql uc 2012Roland Bouman
 
ANALYZE for executable statements - a new way to do optimizer troubleshooting...
ANALYZE for executable statements - a new way to do optimizer troubleshooting...ANALYZE for executable statements - a new way to do optimizer troubleshooting...
ANALYZE for executable statements - a new way to do optimizer troubleshooting...Sergey Petrunya
 
Performance Schema for MySQL Troubleshooting
Performance Schema for MySQL TroubleshootingPerformance Schema for MySQL Troubleshooting
Performance Schema for MySQL TroubleshootingSveta Smirnova
 
Window functions in MariaDB 10.2
Window functions in MariaDB 10.2Window functions in MariaDB 10.2
Window functions in MariaDB 10.2Sergey Petrunya
 
Need for Speed: MySQL Indexing
Need for Speed: MySQL IndexingNeed for Speed: MySQL Indexing
Need for Speed: MySQL IndexingMYXPLAIN
 
Applied Partitioning And Scaling Your Database System Presentation
Applied Partitioning And Scaling Your Database System PresentationApplied Partitioning And Scaling Your Database System Presentation
Applied Partitioning And Scaling Your Database System PresentationRichard Crowley
 
MariaDB 10.5 new features for troubleshooting (mariadb server fest 2020)
MariaDB 10.5 new features for troubleshooting (mariadb server fest 2020)MariaDB 10.5 new features for troubleshooting (mariadb server fest 2020)
MariaDB 10.5 new features for troubleshooting (mariadb server fest 2020)Valeriy Kravchuk
 
Workshop 20140522 BigQuery Implementation
Workshop 20140522   BigQuery ImplementationWorkshop 20140522   BigQuery Implementation
Workshop 20140522 BigQuery ImplementationSimon Su
 
Performance Schema for MySQL Troubleshooting
Performance Schema for MySQL TroubleshootingPerformance Schema for MySQL Troubleshooting
Performance Schema for MySQL TroubleshootingSveta Smirnova
 
Oracle dbms_xplan.display_cursor format
Oracle dbms_xplan.display_cursor formatOracle dbms_xplan.display_cursor format
Oracle dbms_xplan.display_cursor formatFranck Pachot
 
M|18 User Defined Function
M|18 User Defined FunctionM|18 User Defined Function
M|18 User Defined FunctionMariaDB plc
 
4. Data Manipulation.ppt
4. Data Manipulation.ppt4. Data Manipulation.ppt
4. Data Manipulation.pptKISHOYIANKISH
 
MySQL Kitchen : spice up your everyday SQL queries
MySQL Kitchen : spice up your everyday SQL queriesMySQL Kitchen : spice up your everyday SQL queries
MySQL Kitchen : spice up your everyday SQL queriesDamien Seguy
 

Ähnlich wie Window functions in MySQL 8.0 (20)

MySQL/MariaDB query optimizer tuning tutorial from Percona Live 2013
MySQL/MariaDB query optimizer tuning tutorial from Percona Live 2013MySQL/MariaDB query optimizer tuning tutorial from Percona Live 2013
MySQL/MariaDB query optimizer tuning tutorial from Percona Live 2013
 
Mysql tracing
Mysql tracingMysql tracing
Mysql tracing
 
Mysql tracing
Mysql tracingMysql tracing
Mysql tracing
 
Advanced Query Optimizer Tuning and Analysis
Advanced Query Optimizer Tuning and AnalysisAdvanced Query Optimizer Tuning and Analysis
Advanced Query Optimizer Tuning and Analysis
 
Adaptive Query Optimization
Adaptive Query OptimizationAdaptive Query Optimization
Adaptive Query Optimization
 
Common schema my sql uc 2012
Common schema   my sql uc 2012Common schema   my sql uc 2012
Common schema my sql uc 2012
 
Common schema my sql uc 2012
Common schema   my sql uc 2012Common schema   my sql uc 2012
Common schema my sql uc 2012
 
ANALYZE for executable statements - a new way to do optimizer troubleshooting...
ANALYZE for executable statements - a new way to do optimizer troubleshooting...ANALYZE for executable statements - a new way to do optimizer troubleshooting...
ANALYZE for executable statements - a new way to do optimizer troubleshooting...
 
Performance Schema for MySQL Troubleshooting
Performance Schema for MySQL TroubleshootingPerformance Schema for MySQL Troubleshooting
Performance Schema for MySQL Troubleshooting
 
Window functions in MariaDB 10.2
Window functions in MariaDB 10.2Window functions in MariaDB 10.2
Window functions in MariaDB 10.2
 
Need for Speed: MySQL Indexing
Need for Speed: MySQL IndexingNeed for Speed: MySQL Indexing
Need for Speed: MySQL Indexing
 
Applied Partitioning And Scaling Your Database System Presentation
Applied Partitioning And Scaling Your Database System PresentationApplied Partitioning And Scaling Your Database System Presentation
Applied Partitioning And Scaling Your Database System Presentation
 
MariaDB 10.5 new features for troubleshooting (mariadb server fest 2020)
MariaDB 10.5 new features for troubleshooting (mariadb server fest 2020)MariaDB 10.5 new features for troubleshooting (mariadb server fest 2020)
MariaDB 10.5 new features for troubleshooting (mariadb server fest 2020)
 
Workshop 20140522 BigQuery Implementation
Workshop 20140522   BigQuery ImplementationWorkshop 20140522   BigQuery Implementation
Workshop 20140522 BigQuery Implementation
 
Pro PostgreSQL
Pro PostgreSQLPro PostgreSQL
Pro PostgreSQL
 
Performance Schema for MySQL Troubleshooting
Performance Schema for MySQL TroubleshootingPerformance Schema for MySQL Troubleshooting
Performance Schema for MySQL Troubleshooting
 
Oracle dbms_xplan.display_cursor format
Oracle dbms_xplan.display_cursor formatOracle dbms_xplan.display_cursor format
Oracle dbms_xplan.display_cursor format
 
M|18 User Defined Function
M|18 User Defined FunctionM|18 User Defined Function
M|18 User Defined Function
 
4. Data Manipulation.ppt
4. Data Manipulation.ppt4. Data Manipulation.ppt
4. Data Manipulation.ppt
 
MySQL Kitchen : spice up your everyday SQL queries
MySQL Kitchen : spice up your everyday SQL queriesMySQL Kitchen : spice up your everyday SQL queries
MySQL Kitchen : spice up your everyday SQL queries
 

Mehr von Mydbops

Efficient MySQL Indexing and what's new in MySQL Explain
Efficient MySQL Indexing and what's new in MySQL ExplainEfficient MySQL Indexing and what's new in MySQL Explain
Efficient MySQL Indexing and what's new in MySQL ExplainMydbops
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
PostgreSQL Schema Changes with pg-osc - Mydbops @ PGConf India 2024
PostgreSQL Schema Changes with pg-osc - Mydbops @ PGConf India 2024PostgreSQL Schema Changes with pg-osc - Mydbops @ PGConf India 2024
PostgreSQL Schema Changes with pg-osc - Mydbops @ PGConf India 2024Mydbops
 
Choosing the Right Database: Exploring MySQL Alternatives for Modern Applicat...
Choosing the Right Database: Exploring MySQL Alternatives for Modern Applicat...Choosing the Right Database: Exploring MySQL Alternatives for Modern Applicat...
Choosing the Right Database: Exploring MySQL Alternatives for Modern Applicat...Mydbops
 
Mastering Aurora PostgreSQL Clusters for Disaster Recovery
Mastering Aurora PostgreSQL Clusters for Disaster RecoveryMastering Aurora PostgreSQL Clusters for Disaster Recovery
Mastering Aurora PostgreSQL Clusters for Disaster RecoveryMydbops
 
Navigating Transactions: ACID Complexity in Modern Databases- Mydbops Open So...
Navigating Transactions: ACID Complexity in Modern Databases- Mydbops Open So...Navigating Transactions: ACID Complexity in Modern Databases- Mydbops Open So...
Navigating Transactions: ACID Complexity in Modern Databases- Mydbops Open So...Mydbops
 
AWS RDS in MySQL 2023 Vinoth Kanna @ Mydbops OpenSource Database Meetup 15
AWS RDS in MySQL 2023 Vinoth Kanna @ Mydbops OpenSource Database Meetup 15AWS RDS in MySQL 2023 Vinoth Kanna @ Mydbops OpenSource Database Meetup 15
AWS RDS in MySQL 2023 Vinoth Kanna @ Mydbops OpenSource Database Meetup 15Mydbops
 
Data-at-scale-with-TIDB Mydbops Co-Founder Kabilesh PR at LSPE Event
Data-at-scale-with-TIDB Mydbops Co-Founder Kabilesh PR at LSPE EventData-at-scale-with-TIDB Mydbops Co-Founder Kabilesh PR at LSPE Event
Data-at-scale-with-TIDB Mydbops Co-Founder Kabilesh PR at LSPE EventMydbops
 
MySQL Transformation Case Study: 80% Cost Savings & Uninterrupted Availabilit...
MySQL Transformation Case Study: 80% Cost Savings & Uninterrupted Availabilit...MySQL Transformation Case Study: 80% Cost Savings & Uninterrupted Availabilit...
MySQL Transformation Case Study: 80% Cost Savings & Uninterrupted Availabilit...Mydbops
 
Scaling-MongoDB-with-Horizontal-and-Vertical-Sharding Mydbops Opensource Data...
Scaling-MongoDB-with-Horizontal-and-Vertical-Sharding Mydbops Opensource Data...Scaling-MongoDB-with-Horizontal-and-Vertical-Sharding Mydbops Opensource Data...
Scaling-MongoDB-with-Horizontal-and-Vertical-Sharding Mydbops Opensource Data...Mydbops
 
Mastering MongoDB Atlas: Essentials of Diagnostics and Debugging in the Cloud...
Mastering MongoDB Atlas: Essentials of Diagnostics and Debugging in the Cloud...Mastering MongoDB Atlas: Essentials of Diagnostics and Debugging in the Cloud...
Mastering MongoDB Atlas: Essentials of Diagnostics and Debugging in the Cloud...Mydbops
 
Data Organisation: Table Partitioning in PostgreSQL
Data Organisation: Table Partitioning in PostgreSQLData Organisation: Table Partitioning in PostgreSQL
Data Organisation: Table Partitioning in PostgreSQLMydbops
 
Navigating MongoDB's Queryable Encryption for Ultimate Security - Mydbops
Navigating MongoDB's Queryable Encryption for Ultimate Security - MydbopsNavigating MongoDB's Queryable Encryption for Ultimate Security - Mydbops
Navigating MongoDB's Queryable Encryption for Ultimate Security - MydbopsMydbops
 
Data High Availability With TIDB
Data High Availability With TIDBData High Availability With TIDB
Data High Availability With TIDBMydbops
 
Mastering Database Migration_ Native replication (8.0) to InnoDB Cluster (8.0...
Mastering Database Migration_ Native replication (8.0) to InnoDB Cluster (8.0...Mastering Database Migration_ Native replication (8.0) to InnoDB Cluster (8.0...
Mastering Database Migration_ Native replication (8.0) to InnoDB Cluster (8.0...Mydbops
 
Enhancing Security of MySQL Connections using SSL certificates
Enhancing Security of MySQL Connections using SSL certificatesEnhancing Security of MySQL Connections using SSL certificates
Enhancing Security of MySQL Connections using SSL certificatesMydbops
 
Exploring the Fundamentals of YugabyteDB - Mydbops
Exploring the Fundamentals of YugabyteDB - Mydbops Exploring the Fundamentals of YugabyteDB - Mydbops
Exploring the Fundamentals of YugabyteDB - Mydbops Mydbops
 
Time series in MongoDB - Mydbops
Time series in MongoDB - Mydbops Time series in MongoDB - Mydbops
Time series in MongoDB - Mydbops Mydbops
 
TiDB in a Nutshell - Power of Open-Source Distributed SQL Database - Mydbops
TiDB in a Nutshell - Power of Open-Source Distributed SQL Database - MydbopsTiDB in a Nutshell - Power of Open-Source Distributed SQL Database - Mydbops
TiDB in a Nutshell - Power of Open-Source Distributed SQL Database - MydbopsMydbops
 
Achieving High Availability in PostgreSQL
Achieving High Availability in PostgreSQLAchieving High Availability in PostgreSQL
Achieving High Availability in PostgreSQLMydbops
 

Mehr von Mydbops (20)

Efficient MySQL Indexing and what's new in MySQL Explain
Efficient MySQL Indexing and what's new in MySQL ExplainEfficient MySQL Indexing and what's new in MySQL Explain
Efficient MySQL Indexing and what's new in MySQL Explain
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
PostgreSQL Schema Changes with pg-osc - Mydbops @ PGConf India 2024
PostgreSQL Schema Changes with pg-osc - Mydbops @ PGConf India 2024PostgreSQL Schema Changes with pg-osc - Mydbops @ PGConf India 2024
PostgreSQL Schema Changes with pg-osc - Mydbops @ PGConf India 2024
 
Choosing the Right Database: Exploring MySQL Alternatives for Modern Applicat...
Choosing the Right Database: Exploring MySQL Alternatives for Modern Applicat...Choosing the Right Database: Exploring MySQL Alternatives for Modern Applicat...
Choosing the Right Database: Exploring MySQL Alternatives for Modern Applicat...
 
Mastering Aurora PostgreSQL Clusters for Disaster Recovery
Mastering Aurora PostgreSQL Clusters for Disaster RecoveryMastering Aurora PostgreSQL Clusters for Disaster Recovery
Mastering Aurora PostgreSQL Clusters for Disaster Recovery
 
Navigating Transactions: ACID Complexity in Modern Databases- Mydbops Open So...
Navigating Transactions: ACID Complexity in Modern Databases- Mydbops Open So...Navigating Transactions: ACID Complexity in Modern Databases- Mydbops Open So...
Navigating Transactions: ACID Complexity in Modern Databases- Mydbops Open So...
 
AWS RDS in MySQL 2023 Vinoth Kanna @ Mydbops OpenSource Database Meetup 15
AWS RDS in MySQL 2023 Vinoth Kanna @ Mydbops OpenSource Database Meetup 15AWS RDS in MySQL 2023 Vinoth Kanna @ Mydbops OpenSource Database Meetup 15
AWS RDS in MySQL 2023 Vinoth Kanna @ Mydbops OpenSource Database Meetup 15
 
Data-at-scale-with-TIDB Mydbops Co-Founder Kabilesh PR at LSPE Event
Data-at-scale-with-TIDB Mydbops Co-Founder Kabilesh PR at LSPE EventData-at-scale-with-TIDB Mydbops Co-Founder Kabilesh PR at LSPE Event
Data-at-scale-with-TIDB Mydbops Co-Founder Kabilesh PR at LSPE Event
 
MySQL Transformation Case Study: 80% Cost Savings & Uninterrupted Availabilit...
MySQL Transformation Case Study: 80% Cost Savings & Uninterrupted Availabilit...MySQL Transformation Case Study: 80% Cost Savings & Uninterrupted Availabilit...
MySQL Transformation Case Study: 80% Cost Savings & Uninterrupted Availabilit...
 
Scaling-MongoDB-with-Horizontal-and-Vertical-Sharding Mydbops Opensource Data...
Scaling-MongoDB-with-Horizontal-and-Vertical-Sharding Mydbops Opensource Data...Scaling-MongoDB-with-Horizontal-and-Vertical-Sharding Mydbops Opensource Data...
Scaling-MongoDB-with-Horizontal-and-Vertical-Sharding Mydbops Opensource Data...
 
Mastering MongoDB Atlas: Essentials of Diagnostics and Debugging in the Cloud...
Mastering MongoDB Atlas: Essentials of Diagnostics and Debugging in the Cloud...Mastering MongoDB Atlas: Essentials of Diagnostics and Debugging in the Cloud...
Mastering MongoDB Atlas: Essentials of Diagnostics and Debugging in the Cloud...
 
Data Organisation: Table Partitioning in PostgreSQL
Data Organisation: Table Partitioning in PostgreSQLData Organisation: Table Partitioning in PostgreSQL
Data Organisation: Table Partitioning in PostgreSQL
 
Navigating MongoDB's Queryable Encryption for Ultimate Security - Mydbops
Navigating MongoDB's Queryable Encryption for Ultimate Security - MydbopsNavigating MongoDB's Queryable Encryption for Ultimate Security - Mydbops
Navigating MongoDB's Queryable Encryption for Ultimate Security - Mydbops
 
Data High Availability With TIDB
Data High Availability With TIDBData High Availability With TIDB
Data High Availability With TIDB
 
Mastering Database Migration_ Native replication (8.0) to InnoDB Cluster (8.0...
Mastering Database Migration_ Native replication (8.0) to InnoDB Cluster (8.0...Mastering Database Migration_ Native replication (8.0) to InnoDB Cluster (8.0...
Mastering Database Migration_ Native replication (8.0) to InnoDB Cluster (8.0...
 
Enhancing Security of MySQL Connections using SSL certificates
Enhancing Security of MySQL Connections using SSL certificatesEnhancing Security of MySQL Connections using SSL certificates
Enhancing Security of MySQL Connections using SSL certificates
 
Exploring the Fundamentals of YugabyteDB - Mydbops
Exploring the Fundamentals of YugabyteDB - Mydbops Exploring the Fundamentals of YugabyteDB - Mydbops
Exploring the Fundamentals of YugabyteDB - Mydbops
 
Time series in MongoDB - Mydbops
Time series in MongoDB - Mydbops Time series in MongoDB - Mydbops
Time series in MongoDB - Mydbops
 
TiDB in a Nutshell - Power of Open-Source Distributed SQL Database - Mydbops
TiDB in a Nutshell - Power of Open-Source Distributed SQL Database - MydbopsTiDB in a Nutshell - Power of Open-Source Distributed SQL Database - Mydbops
TiDB in a Nutshell - Power of Open-Source Distributed SQL Database - Mydbops
 
Achieving High Availability in PostgreSQL
Achieving High Availability in PostgreSQLAchieving High Availability in PostgreSQL
Achieving High Availability in PostgreSQL
 

Kürzlich hochgeladen

Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 

Kürzlich hochgeladen (20)

Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 

Window functions in MySQL 8.0

  • 1. Window functions in MySQL 8.0 Presented by Sri Sakthivel M.D. www.mydbops.com info@mydbops.com
  • 2. About Mydbops ● Founded in 2015, HQ in Bangalore India with 450+ customer base across the globe. ● Mydbops is on Database Consulting with core specialization on MySQL,MongoDB,PostgreSQL Administration and Support. ● We have expert team with 30+ certified DBA’s providing full time support and currently managing 400+ servers. ● Mydbops was created with a motto of developing a Devops model for Database administration offering 24*7 expert remote DBA support. ● We help organisations to architect and scale systems in MySQL/Mongo by implementing the advanced technologies in industry which are completely open source. ● We are leading solution provider in the market for all sort of cloud based database deployments and management.
  • 3. About Me ● MySQL/MariaDB DBA Expert. ● AWS Solution Architect Associate ● Expertise in Gallera / PXC / InnoDB clusters ● Expertise in MySQL load balancers ProxySQL / Maxscale ● Active MySQL Blogger. ● Interested on DB Fine Tuning and SQL Load Balancers. ● Twitter : @hercules7sakthi ● Hobbies : Bike riding and like good Food.
  • 4. Agenda ● What is Window function ? ● Window function vs MySQL ● Window function Syntax ● Types of Window function ● Query Example with Window function ● Conclusion
  • 5. What is Window function ? Window functions enable users to perform calculations against partitions (i.e. subgroups or sections) of a result set . Window functions increase the efficiency and reduce the complexity of queries that analyze partitions (windows) of a data set by providing an alternative to more complex SQL concepts, e.g. derived queries. Window functions do not cause rows to become grouped into a single output row, the rows retain their separate identities and an aggregated value will be added to each row.
  • 6. Window function vs MySQL ● Frequently requested feature for data analysis ● Supports since version MySQL 8.0 ● Supports aggregate & most non aggregate functions ● Solving analytical queries & Improves performance ● Flexible & ease to use
  • 7. Window function Syntax ● Partition definition ● Order definition ● Frame definition
  • 8. Window function Syntax Partition definition ( Syntax ) : ● Helps to create the partition window over the column . windows_function_name(expression) OVER({PARTITION BY <definition>}) example : root@localhost>select a.method,a.loanId,a.amt,a.Total from (select method,loanId,amt, sum(amt) over(partition by method) as Total from yp_payments) a group by a.method limit 3; +--------+---------+------+--------------------+ | method | loanId | amt | Total | +--------+---------+------+--------------------+ | 118 | 6768178 | 2233 | 12176312573.809387 | | 122 | 4953108 | 1655 | 1036464 | | 167 | 1975693 | 8235 | 634836 | +--------+---------+------+--------------------+
  • 9. Window function Syntax Order definition (syntax) : ● Can use the ORDER BY inside the function OVER() windows_function_name(expression) OVER({ORDER BY ASC | DESC}) example : root@localhost:>select a.method,a.loanId,a.amt,a.Total from (select method,loanId,amt, sum(amt) over(order by method desc) as Total from yp_payments) a group by a.method limit 3; +--------+---------+------+--------------------+ | method | loanId | amt | Total | +--------+---------+------+--------------------+ | 994 | 7108021 | 2 | 67 | | 518 | 6040015 | 4118 | 5050588984.439701 | | 489 | 4703452 | 1784 | 10805334804.439701 | +--------+---------+------+--------------------+ 3 rows in set (26.15 sec)
  • 10. Window function Syntax Frame definition : ● Can compute running totals for each row. ● Can compute rolling averages. Syntax : windows_function_name(expression) OVER(PARTITION BY <expression> ROWS UNBOUNDED PRECEDING) windows_function_name(expression) OVER(PARTITION BY <expression> ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING)
  • 11. Window function Syntax Frame definition : Example : running incremental totals for each method , root@localhost:yp>select a.method,a.loanId,a.amt,a.incremental_Total from (select method,loanId,amt,sum(amt) over(partition by method rows unbounded preceding) as incremental_Total from yp_payments where method=489) a limit 5; +--------+---------+------+-------------------+ | method | loanId | amt | incremental_Total | +--------+---------+------+-------------------+ | 489 | 6758312 | 2233 | 2233 | | 489 | 6457319 | 2677 | 4910 | | 489 | 6094261 | 8387 | 13297 | | 489 | 6240342 | 5148 | 18445 | | 489 | 6734211 | 3604 | 22049 | +--------+---------+------+-------------------+
  • 12. Window function Syntax Frame definition : Example : rolling averages for each method, root@localhost:>select a.method,a.loanId,a.amt,a.rolling_Avg from (select method,loanId,amt, avg(amt) over(partition by method rows between 1 preceding and 1 following) as rolling_Avg from yp_payments where method=489) a limit 5; +--------+---------+------+-------------------+ | method | loanId | amt | rolling_Avg | +--------+---------+------+-------------------+ | 489 | 6758312 | 2233 | 2455 | | 489 | 6457319 | 2677 | 4432.333333333333 | | 489 | 6094261 | 8387 | 5404 | | 489 | 6240342 | 5148 | 5713 | | 489 | 6734211 | 3604 | 4290 | +--------+---------+------+-------------------+ 5 rows in set (12.73 sec)
  • 13. Types of Window function ● CUME_DIST() ● DENSE_RANK() ● RANK() ● FIRST_VALUE() ● LAST_VALUE() ● NTH_VALUE() ● NTILE() ● LEAD() ● LAG() ● PERCENT_RANK() ● ROW_NUMBER()
  • 14. Types of Window functions CUM_DIST() : ● Returns the cumulative distribution of a value within a group of values . root@localhost>select method,loanId,amt,cume_dist() over( partition by method order by amt) as cummulative_dist from yp_payments where method=994 limit 10; +--------+---------+------+---------------------+ | method | loanId | amt | cummulative_dist | +--------+---------+------+---------------------+ | 994 | 6966384 | 1 | 0.23684210526315788 | | 994 | 6966668 | 1 | 0.23684210526315788 | | 994 | 7101985 | 1 | 0.23684210526315788 | | 994 | 7102975 | 1 | 0.23684210526315788 | | 994 | 7108441 | 1 | 0.23684210526315788 | | 994 | 7109122 | 1 | 0.23684210526315788 | | 994 | 7110529 | 1 | 0.23684210526315788 | | 994 | 7111399 | 1 | 0.23684210526315788 | | 994 | 7112577 | 1 | 0.23684210526315788 | | 994 | 6965596 | 2 | 1 | +--------+---------+------+---------------------+ 10 rows in set (0.00 sec)
  • 15. Types of Window functions DENSE_RANK() : ● Rank of current row within its partition, without gaps root@localhost>select method,loanId,amt, dense_rank() over(order by amt) as dens_rank from yp_payments group by method limit 5; +--------+---------+------+------------------+ | method | loanId | amt | dens_rank | +--------+---------+------+------------------+ | 489 | 713157 | 2 | 1 | | 518 | 775470 | 2 | 1 | | 994 | 6965596 | 2 | 1 | | 167 | 11801 | 344 | 2 | | 122 | 28101 | 1075 | 3 | +--------+---------+------+------------------+ 5 rows in set (4.83 sec)
  • 16. Types of Window functions RANK() : ● Rank of current row within its partition, with gaps root@localhost:yp>select method,loanId,amt, rank() over(order by amt) as _mrank from yp_payments group by method limit 5; +--------+---------+------+------------------+ | method | loanId | amt | _mrank | +--------+---------+------+------------------+ | 489 | 713157 | 2 | 1 | | 518 | 775470 | 2 | 1 | | 994 | 6965596 | 2 | 1 | | 167 | 11801 | 344 | 4 | | 122 | 28101 | 1075 | 5 | +--------+---------+------+------------------+ 5 rows in set (8.41 sec)
  • 17. Types of Window functions FIRST_VALUE() : 1. Value of argument from first row of window frame root@localhost:yp>select method,loanId,amt, first_value(amt) over( partition by method order by amt) as 1st_value from yp_payments where method in (994,323); +--------+---------+------+------------------+ | method | loanId | amt | 1st_value | +--------+---------+------+------------------+ | 323 | 5217241 | 70 | 70 | | 323 | 769665 | 8118 | 70 | | 323 | 671604 | 8768 | 70 | | 994 | 6966384 | 1 | 1 | | 994 | 6966668 | 1 | 1 | | 994 | 7101985 | 1 | 1 | +--------+---------+------+------------------+
  • 18. Types of Window functions LAST_VALUE() : Value of argument from last row of window frame root@localhost>select method,loanId,amt, last_value(amt) over( partition by method order by amt) as lst_value from yp_payments where method in (994,323); +--------+---------+------+------------------+ | method | loanId | amt | lst_value | +--------+---------+------+------------------+ | 323 | 5217241 | 8768 | 70 | | 323 | 769665 | 8118 | 70 | | 323 | 671604 | 70 | 70 | | 994 | 6966384 | 1 | 1 | | 994 | 6966668 | 1 | 1 | | 994 | 7101985 | 1 | 1 | +--------+---------+------+------------------+
  • 19. Types of Window functions NTH_VALUE() : ● Value of argument from N-th row of window frame root@localhost>select method,loanId,amt, nth_value(amt,3) over( partition by method ) as n_value from yp_payments where method in (994,323); +--------+---------+------+------------------+ | method | loanId | amt | n_value | +--------+---------+------+------------------+ | 323 | 170645 | 5244 | 3200 | | 323 | 150974 | 3404 | 3200 | | 323 | 135282 | 3200 | 3200 | | 323 | 5217241 | 70 | 3200 | | 994 | 6965596 | 2 | 2 | | 994 | 6966384 | 1 | 2 | | 994 | 6966384 | 2 | 2 | +--------+---------+------+------------------+
  • 20. Types of Window functions NTILE() : ● Bucket number of current row within its partition. root@localhost:yp>select method,loanId,amt, ntile(100) over( partition by method ) as tile_value from yp_payments where method in (994,323); +--------+---------+------+------------------+ | method | loanId | amt | tile_value | +--------+---------+------+------------------+ | 323 | 170645 | 5244 | 1 | | 323 | 150974 | 3404 | 2 | . . . . . . . . . | 323 | 5217241 | 70 | 79 | | 994 | 6965596 | 2 | 1 | | 994 | 6966384 | 1 | 2 | . . . . . . . . . | 994 | 7112577 | 2 | 38 | +--------+---------+------+------------------+
  • 21. Types of Window functions LEAD() : ● Value of argument from row leading current row within partition root@localhost>select method,loanId,amt, lead(amt) over( partition by method ) as lead_smt, amt - lead(amt) over(partition by method) as lead_diff from yp_payments where method in (323); +--------+---------+------+----------+-----------+ | method | loanId | amt | lead_smt | lead_diff | +--------+---------+------+----------+-----------+ | 323 | 170645 | 5244 | 3404 | 1840 | | 323 | 150974 | 3404 | 3200 | 204 | | 323 | 135282 | 3200 | 5174 | -1974 | | 323 | 288222 | 5174 | 5699 | -525 | | 323 | 376684 | 5699 | 5489 | 210 | | 323 | 432680 | 5489 | 5074 | 415 | | 323 | 506159 | 5074 | 3500 | 1574 | . . . . . . . . . +--------+---------+------+----------+-----------+ 79 rows in set (0.00 sec)
  • 22. Types of Window functions LAG() : ● Value of argument from row lagging current row within partition root@localhost>select method,loanId,amt, lag(amt) over( partition by method ) as lag_amt, amt - lag(amt) over(partition by method) as lag_diff from yp_payments where method in (323); +--------+---------+------+---------+----------+ | method | loanId | amt | lag_amt | lag_diff | +--------+---------+------+---------+----------+ | 323 | 170645 | 5244 | NULL | NULL | | 323 | 150974 | 3404 | 5244 | -1840 | | 323 | 135282 | 3200 | 3404 | -204 | | 323 | 288222 | 5174 | 3200 | 1974 | | 323 | 376684 | 5699 | 5174 | 525 | | 323 | 432680 | 5489 | 5699 | -210 | | 323 | 506159 | 5074 | 5489 | -415 | . . . . . . . +--------+---------+------+---------+----------+
  • 23. Types of Window functions PERSENT_RANK() : ● Percentage rank value root@localhost>select method,loanId,amt, percent_rank() over( order by method) as rank_per from yp_payments where method in (994,323); +--------+---------+------+--------------------+ | method | loanId | amt | rank_per | +--------+---------+------+--------------------+ | 323 | 170645 | 5244 | 0 | . . . . . . . . . .. . . . . . . . | 323 | 5217241 | 70 | 0 | | 994 | 6965596 | 2 | 0.6810344827586207 | . . . . . . . . . .. . . . . . . . | 994 | 7112577 | 2 | 0.6810344827586207 | +--------+---------+------+--------------------+ 117 rows in set (0.00 sec)
  • 24. Types of Window functions ROW_NUMBER() : ● Percentage rank value root@localhost>select method,loanId,amt, row_number() over( order by method ) as rw_num from yp_payments where method in (994,323); +--------+---------+------+------------------+ | method | loanId | amt | rw_num | +--------+---------+------+------------------+ | 323 | 170645 | 5244 | 1 | | 323 | 150974 | 3404 | 2 | | 323 | 135282 | 3200 | 3 | | 323 | 288222 | 5174 | 4 | | 323 | 376684 | 5699 | 5 | ..... . . . . . . . .. . . . . . | 994 | 7112577 | 2 | 117 | +--------+---------+------+------------------+ 117 rows in set (0.01 sec)
  • 25. Query example with windows function ● Need top 2 methods ( column ) from yp_payments table, which having huge amount ● The amount should be above 50000 thousands ● Need to know the highest amount from both methods
  • 26. Query example with windows function Using windows function : root@localhost> select a.method,a.loanId,a.amt from (select method,loanId,amt,rank() over(partition by method order by amt desc) as rank_gap from yp_payments where amt > 50000) a where a.rank_gap=1 order by a.amt desc limit 2; +--------+---------+--------+ | method | loanId | amt | +--------+---------+--------+ | 118 | 448 | 508698 | | 518 | 5377057 | 92839 | +--------+---------+--------+ 2 rows in set (3.02 sec) Execution Time : 3 seconds +----+-------------+-------------+------------+------+---------------+-------------+---------+-------+---------+----------+-----------------------------+ | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra | +----+-------------+-------------+------------+------+---------------+-------------+---------+-------+---------+----------+-----------------------------+ | 1 | PRIMARY | <derived2> | NULL | ref | <auto_key0> | <auto_key0> | 8 | const | 10 | 100.00 | Using filesort | | 2 | DERIVED | yp_payments | NULL | ALL | NULL | NULL | NULL | NULL | 5549711 | 33.33 |Using where; Using filesort | +----+-------------+-------------+------------+------+---------------+-------------+---------+-------+---------+----------+-----------------------------+ 2 rows in set, 2 warnings (0.00 sec)
  • 27. Query example with windows function normal query : root@localhost>select method,loanId,max(amt) from yp_payments where amt > 50000 group by method order by amt desc limit 2; +--------+--------+----------+ | method | loanId | max(amt) | +--------+--------+----------+ | 118 | 448 | 508698 | | 518 |5377057 | 92839 | +--------+--------+----------+ 2 rows in set (12.00 sec) Execution Time : 12 seconds +----+-------------+-------------+------------+-------+-----------------------------------+---------------------------+---------+------+---------+----------+----------------------------------------------+ | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra | +----+-------------+-------------+------------+-------+-----------------------------------+---------------------------+---------+------+---------+----------+----------------------------------------------+ | 1 | SIMPLE | yp_payments | NULL | index | fk_yp_payments_method_idx,idx_met | fk_yp_payments_method_idx | 4 | NULL | 5549920 | 33.33 | Using where; Using temporary; Using filesort | +----+-------------+-------------+------------+-------+-----------------------------------+---------------------------+---------+------+---------+----------+----------------------------------------------+ 1 row in set, 1 warning (0.00 sec)
  • 28. Query example with windows function ● GROUP BY & ORDER BY required for normal query to sort the results ● Query without windows function is creating temporary table ● Temporary tables are very critical ( disk temporary tables) on huge data set
  • 29. For an enterprise class Database support and DB managed services reach Mydbops Email : info@mydbops.com