SQL has gone out of fashion lately—partly due to the NoSQL movement, but mostly because SQL is often still used like 20 years ago. As a matter of fact, the SQL standard continued to evolve during the past decades resulting in the current release of 2016. In this session, we will go through the most important additions since the widely known SQL-92. We will cover common table expressions and window functions in detail and have a very short look at the temporal features of SQL:2011 and row pattern matching from SQL:2016.
Links:
http://modern-sql.com/
http://winand.at/
http://sql-performance-explained.com/
SQL is a language used to manage data in relational database management systems (RDBMS). This tutorial provides an overview of SQL and its components, introduces key SQL concepts like database objects, data types, and SQL statements, and includes many examples for working with SQL databases, tables, and queries. It covers common SQL statements like SELECT, INSERT, UPDATE, DELETE, and explains concepts such as aggregates, joins, subqueries and more.
ISO SQL:2016 introduced Row Pattern Matching: a feature to apply (limited) regular expressions on table rows and perform analysis on each match. As of writing, this feature is only supported by the Oracle Database 12c.
Table Partitioning in SQL Server: A Magic Solution for Better Performance? (P...Cathrine Wilhelmsen
The document provides an introduction to table partitioning in SQL Server. It explains what a partitioned table is, the key components like partition key, partition function, and partition scheme. It discusses why table partitioning is used, including benefits like partition elimination to improve query performance, ability to backup and restore partitions individually, and perform maintenance tasks like indexing and statistics updates on partitions. It also covers techniques like partition switching which allows fast loading and archiving of data without physically moving it. The document uses examples and diagrams to illustrate these concepts and components of table partitioning.
OOPS Concepts, Java Evolution, Class Object basic, Class Object Constructor overloading, Inheritance, Array and String, Final Abstract class and interfaces, Exceptions, Streams, GUI Applications, Applet Programming, Network Programming and Java Sockets, Multi Threading
This document discusses building Android user interfaces with XML. It covers key UI elements like LinearLayout, RelativeLayout and ListView that can be used to design app layouts. It also describes tools in Android Studio like the layout editor, theme editor and translations editor that help develop UIs. The document provides details on implementing features like the action bar, floating action button and defining colors and dimensions as resources.
This document introduces object-oriented programming concepts including classes, inheritance, encapsulation, and polymorphism. It discusses how OOP allows for more organized and flexible code through the use of classes, objects, and methods. Key aspects of classes like constructors, destructors, and access modifiers are explained. Other concepts covered include static vs non-static classes, method overloading, enumerations, structures, abstract classes, interfaces, and abstract methods. The document aims to provide an overview of fundamental OOP principles.
This document provides an introduction and overview of C# programming and SQL. It discusses key aspects of C#, its uses in Windows, web, and web service applications. It also covers SQL fundamentals like retrieving, inserting, updating, and deleting records. The document includes examples of SQL statements like INSERT, UPDATE, DELETE, and SELECT and highlights best practices like enclosing string values in single quotes and ending statements with semicolons.
This document provides an overview of ASP.NET Core 1.0 and discusses its evolution from previous ASP.NET technologies. It covers the ASP.NET architecture, Model-View-Controller pattern, ASP.NET MVC and Web API project templates, tag helpers, consuming Web APIs, and using JavaScript frameworks with ASP.NET Core.
The document provides an introduction to SQL and relational databases. It describes how relational databases organize data into tables with rows and columns, and how primary keys and foreign keys link related data across multiple tables. It introduces SQL as a non-procedural language used to communicate with the database management system to query, insert, update and delete data from relational databases in a simple English-like syntax.
The document discusses exception handling in PL/SQL. It defines exceptions as abnormal conditions that can occur during program execution. There are two types of exceptions: system-defined exceptions which are predefined by Oracle and user-defined exceptions which are declared by the user. The document provides examples of how to handle different system-defined exceptions like NO_DATA_FOUND, INVALID_CURSOR, CURSOR_ALREADY_OPENED, INVALID_NUMBER, and ZERO_DIVIDE. It also demonstrates how to declare and raise user-defined exceptions. The RAISE_APPLICATION_ERROR technique to specify custom error numbers and messages without an exception block is also covered.
AWT (Abstract Window Toolkit) is a collection of classes and methods that allows creation and management of windows. It provides support for applets and contains support for window-based graphical user interfaces. Different window classes defined by AWT add functionality, with Component and Container being the base classes. Layout managers determine how components are arranged in frames using algorithms. Common layout managers include FlowLayout, BorderLayout, and GridLayout. Graphics methods allow for drawing shapes and text to windows.
- The document discusses advanced techniques for optimizing MySQL queries, including topics like temporary tables, file sorting, order optimizations, and calculated fields.
- It provides examples of using indexes and index optimizations, explaining concepts like index types, index usage, key lengths, and covering indexes.
- One example shows how to optimize a query involving a calculated year() expression by rewriting the query to use a range on the date field instead.
This document discusses various techniques for optimizing MySQL queries, including queries for exclusion joins, random selection, and greatest per group. For a query seeking movies without directors, solutions using NOT EXISTS, NOT IN, and outer joins are examined. The outer join solution performed best by taking advantage of a "not exists" optimization. For random selection of a movie, an initial naive solution using ORDER BY RAND() is shown to be inefficient, prompting discussion of alternative approaches.
The document provides an overview of database concepts and features in Oracle, including fundamentals like data grouping and relationships, as well as operations on tables like insert, update, delete. It also covers queries with filters, joins, and aggregations, as well as other objects like views, sequences, indexes, triggers, and stored procedures. The document is intended as training material for the Oracle database.
This document provides a cheat sheet for MySQL with summaries of basic operations, table operations, storage engines, transaction operations, administration operations, and more. It includes commands for connecting to MySQL, starting and stopping the MySQL daemon, checking server status, creating and modifying databases and tables, importing and exporting data, and server administration tasks like backups, restores, and log maintenance. A link is provided to the original Japanese sheet as well as the MySQL official documentation.
This presentation provides an overview of oracle's associate and professional Java certifications - gives you ideas on how to prepare and crack the exam with ease.
After 3 years, the third LTS version, Java 17, was released in September 2021. We all are very excited and keen to learn more about new changes it brings to us. However, many projects and products are still using Java 11, or even Java 8. In this session, we will not only focus on those amazing features, but also have a quick introduction on why we should migrate to Java 17 and how.
https://cyberjos.blog/java/seminar/jcconf-2021-java17-the-next-lts/
SQL is a standard language for accessing and manipulating databases. The document provides an introduction to SQL basics including SQL statements to select, insert, update and delete data from database tables. It explains key SQL components like the WHERE clause for filtering records and the ORDER BY clause for sorting query results. Examples are given for each SQL statement and concept discussed.
This document provides an introduction and overview of ASP.NET and Web Forms. It discusses the background of ASP and how ASP.NET was developed to address challenges with ASP. The key features of ASP.NET, including Web Forms, Web Services, and the .NET Framework are described. The document then covers the ASP.NET programming model based on controls and events, and how postbacks maintain page state without requiring additional code. It also introduces the ASP.NET object model and server-side controls.
Here are the key points about the course agenda:
- The course is divided into lessons that will be covered over multiple days.
- On the first day, the lessons covered are the Introduction lesson (which provides an overview of the course) and two core PL/SQL lessons - an introduction to PL/SQL and declaring variables.
- These initial lessons lay the groundwork by introducing PL/SQL and how to declare and work with variables.
Lessons for subsequent days will build on this foundation by covering additional core PL/SQL concepts like writing executable statements, interacting with the database, writing control structures, and more advanced topics like exceptions and stored procedures/functions.
The pacing and grouping of lessons is designed to progressively introduce
Tutorial Videos: https://www.youtube.com/playlist?list=PLD8nQCAhR3tQ7KXnvIk_v_SLK-Fb2y_k_
Day 1 : Introduction to React, Babel and Webpack
Prerequisites of starting the workshop ( Basic understanding of Node & Express )
What is Virtual DOM?
What is React and why should we use it?
Install and set up React:
a-Using create-react-app
b-From scratch using Babel and Webpack. We will use Webpack Dev Server.
Day 2 : React Basic Concepts
Types of Components: Class-based and Functional based Components
Use of JSX
Parent, Child, and Nested Components
Difference between State and Props
Create and Handle Routes
Component Lifecycle Methods
Create a form and handling form inputs
Use of arrow functions and Spread Operator
Day 3: Advanced Concepts in React
Use of Refs
What are Higher Order Components( HOC )?
How to use HOC
Understanding Context in React
Postgres expert, Bruce Momjian, as he discusses common table expressions (CTEs) and the ability to allow queries to be more imperative, allowing looping and processing hierarchical structures that are normally associated only with imperative languages.
Особенности ETL — инструмента pentaho data integrator. Опыт КРОККРОК
Семинар Центра компетенции компании КРОК «Построение единой информационной среды как средство поддержания стабильности бизнеса в условиях кризиса».
Подробнее о мероприятии http://www.croc.ru/action/detail/1602/
Презентация Юрия Кудрявцева, эксперта направления BI департамента информационных систем компании КРОК
This document provides an overview of PowerShell, including what it is, how it solves security issues with existing scripting languages, basic commands, how to get help in PowerShell, variables, operators, regular expressions, arrays, hash tables, XML handling, snap-ins, the PowerShell IDE, and resources for learning more about PowerShell.
This document discusses modern SQL features beyond the SQL-92 standard, including OLAP features like grouping sets, cube, and rollup for multi-dimensional analysis; common table expressions (WITH queries) for organizing complex queries and enabling recursion; lateral joins for iterating over query results; window functions for ranking and aggregating over partitions; and the use of JSON data types in PostgreSQL for combining SQL and NoSQL capabilities. It provides examples and discusses support for these features across major database systems.
This document provides an overview of ASP.NET Core 1.0 and discusses its evolution from previous ASP.NET technologies. It covers the ASP.NET architecture, Model-View-Controller pattern, ASP.NET MVC and Web API project templates, tag helpers, consuming Web APIs, and using JavaScript frameworks with ASP.NET Core.
The document provides an introduction to SQL and relational databases. It describes how relational databases organize data into tables with rows and columns, and how primary keys and foreign keys link related data across multiple tables. It introduces SQL as a non-procedural language used to communicate with the database management system to query, insert, update and delete data from relational databases in a simple English-like syntax.
The document discusses exception handling in PL/SQL. It defines exceptions as abnormal conditions that can occur during program execution. There are two types of exceptions: system-defined exceptions which are predefined by Oracle and user-defined exceptions which are declared by the user. The document provides examples of how to handle different system-defined exceptions like NO_DATA_FOUND, INVALID_CURSOR, CURSOR_ALREADY_OPENED, INVALID_NUMBER, and ZERO_DIVIDE. It also demonstrates how to declare and raise user-defined exceptions. The RAISE_APPLICATION_ERROR technique to specify custom error numbers and messages without an exception block is also covered.
AWT (Abstract Window Toolkit) is a collection of classes and methods that allows creation and management of windows. It provides support for applets and contains support for window-based graphical user interfaces. Different window classes defined by AWT add functionality, with Component and Container being the base classes. Layout managers determine how components are arranged in frames using algorithms. Common layout managers include FlowLayout, BorderLayout, and GridLayout. Graphics methods allow for drawing shapes and text to windows.
- The document discusses advanced techniques for optimizing MySQL queries, including topics like temporary tables, file sorting, order optimizations, and calculated fields.
- It provides examples of using indexes and index optimizations, explaining concepts like index types, index usage, key lengths, and covering indexes.
- One example shows how to optimize a query involving a calculated year() expression by rewriting the query to use a range on the date field instead.
This document discusses various techniques for optimizing MySQL queries, including queries for exclusion joins, random selection, and greatest per group. For a query seeking movies without directors, solutions using NOT EXISTS, NOT IN, and outer joins are examined. The outer join solution performed best by taking advantage of a "not exists" optimization. For random selection of a movie, an initial naive solution using ORDER BY RAND() is shown to be inefficient, prompting discussion of alternative approaches.
The document provides an overview of database concepts and features in Oracle, including fundamentals like data grouping and relationships, as well as operations on tables like insert, update, delete. It also covers queries with filters, joins, and aggregations, as well as other objects like views, sequences, indexes, triggers, and stored procedures. The document is intended as training material for the Oracle database.
This document provides a cheat sheet for MySQL with summaries of basic operations, table operations, storage engines, transaction operations, administration operations, and more. It includes commands for connecting to MySQL, starting and stopping the MySQL daemon, checking server status, creating and modifying databases and tables, importing and exporting data, and server administration tasks like backups, restores, and log maintenance. A link is provided to the original Japanese sheet as well as the MySQL official documentation.
This presentation provides an overview of oracle's associate and professional Java certifications - gives you ideas on how to prepare and crack the exam with ease.
After 3 years, the third LTS version, Java 17, was released in September 2021. We all are very excited and keen to learn more about new changes it brings to us. However, many projects and products are still using Java 11, or even Java 8. In this session, we will not only focus on those amazing features, but also have a quick introduction on why we should migrate to Java 17 and how.
https://cyberjos.blog/java/seminar/jcconf-2021-java17-the-next-lts/
SQL is a standard language for accessing and manipulating databases. The document provides an introduction to SQL basics including SQL statements to select, insert, update and delete data from database tables. It explains key SQL components like the WHERE clause for filtering records and the ORDER BY clause for sorting query results. Examples are given for each SQL statement and concept discussed.
This document provides an introduction and overview of ASP.NET and Web Forms. It discusses the background of ASP and how ASP.NET was developed to address challenges with ASP. The key features of ASP.NET, including Web Forms, Web Services, and the .NET Framework are described. The document then covers the ASP.NET programming model based on controls and events, and how postbacks maintain page state without requiring additional code. It also introduces the ASP.NET object model and server-side controls.
Here are the key points about the course agenda:
- The course is divided into lessons that will be covered over multiple days.
- On the first day, the lessons covered are the Introduction lesson (which provides an overview of the course) and two core PL/SQL lessons - an introduction to PL/SQL and declaring variables.
- These initial lessons lay the groundwork by introducing PL/SQL and how to declare and work with variables.
Lessons for subsequent days will build on this foundation by covering additional core PL/SQL concepts like writing executable statements, interacting with the database, writing control structures, and more advanced topics like exceptions and stored procedures/functions.
The pacing and grouping of lessons is designed to progressively introduce
Tutorial Videos: https://www.youtube.com/playlist?list=PLD8nQCAhR3tQ7KXnvIk_v_SLK-Fb2y_k_
Day 1 : Introduction to React, Babel and Webpack
Prerequisites of starting the workshop ( Basic understanding of Node & Express )
What is Virtual DOM?
What is React and why should we use it?
Install and set up React:
a-Using create-react-app
b-From scratch using Babel and Webpack. We will use Webpack Dev Server.
Day 2 : React Basic Concepts
Types of Components: Class-based and Functional based Components
Use of JSX
Parent, Child, and Nested Components
Difference between State and Props
Create and Handle Routes
Component Lifecycle Methods
Create a form and handling form inputs
Use of arrow functions and Spread Operator
Day 3: Advanced Concepts in React
Use of Refs
What are Higher Order Components( HOC )?
How to use HOC
Understanding Context in React
Postgres expert, Bruce Momjian, as he discusses common table expressions (CTEs) and the ability to allow queries to be more imperative, allowing looping and processing hierarchical structures that are normally associated only with imperative languages.
Особенности ETL — инструмента pentaho data integrator. Опыт КРОККРОК
Семинар Центра компетенции компании КРОК «Построение единой информационной среды как средство поддержания стабильности бизнеса в условиях кризиса».
Подробнее о мероприятии http://www.croc.ru/action/detail/1602/
Презентация Юрия Кудрявцева, эксперта направления BI департамента информационных систем компании КРОК
This document provides an overview of PowerShell, including what it is, how it solves security issues with existing scripting languages, basic commands, how to get help in PowerShell, variables, operators, regular expressions, arrays, hash tables, XML handling, snap-ins, the PowerShell IDE, and resources for learning more about PowerShell.
This document discusses modern SQL features beyond the SQL-92 standard, including OLAP features like grouping sets, cube, and rollup for multi-dimensional analysis; common table expressions (WITH queries) for organizing complex queries and enabling recursion; lateral joins for iterating over query results; window functions for ranking and aggregating over partitions; and the use of JSON data types in PostgreSQL for combining SQL and NoSQL capabilities. It provides examples and discusses support for these features across major database systems.
PPT of Common Table Expression (CTE), Window Functions, JOINS, SubQueryAbhishek590097
Common table expressions (CTEs) allow users to define temporary result sets within a single SQL statement that can be referenced within that statement, making complex queries easier to read and maintain by breaking them down into simpler components, while subqueries return data from a nested SQL query to filter the results of the outer query. Joins combine data from two or more tables by linking common columns between them and come in various types like inner, left, right, full, and cross joins.
The document provides an overview of SQL concepts for retrieving and manipulating data using SQL statements like SELECT, JOIN, GROUP BY, and subqueries. It discusses the key clauses and operations for projection, selection, aggregation, sorting, joining tables, grouping data, and using subqueries. Some important points covered include using SELECT to retrieve specific attributes or calculate column values, filtering rows with WHERE, sorting with ORDER BY, aggregation functions, inner/outer/cross joins, and applying grouping and aggregation at different levels with ROLLUP and CUBE.
This document provides an overview of Oracle database and relational database management systems (RDBMS). It defines key terms like data, database, DBMS, RDBMS and describes table structure with rows and columns. Popular RDBMS like Oracle, SQL Server, DB2, Teradata and open-source options like PostgreSQL and MySQL are listed. Core SQL commands, joins, constraints, transactions and other relational database concepts are described at a high level.
Common Table Expressions (CTE) & Window Functions in MySQL 8.0oysteing
This document discusses common table expressions (CTE) and window functions in MySQL 8.0. It provides examples of using CTEs to improve readability, allow referencing tables multiple times, and refer to other CTEs. It also discusses recursive CTEs, window functions, and examples calculating aggregates like sums over partitions of rows.
The document provides an agenda and overview for a T-SQL training session covering topics such as null values, order by, distinct, aggregates, grouping, having vs where, compute by, union, constraints, joins, subqueries, and nested queries. Key points covered include:
- Null values represent unknown, missing, or inapplicable data
- Order by specifies sorting order, ascending is default but desc can specify descending
- Distinct eliminates duplicate rows in result sets
- Aggregates like count, sum, and average perform calculations on groups of values
- Group by orders data into groups and is useful with aggregates
- Having defines which groups are returned while where defines data set for grouping
- Subqueries can
Presentation of Common Table Expressions (CTE), recursive or not , a new feature in MySQL 8.0; slides written by Guilhem Bichot, developer of the feature, and presented by him at the Percona Live Conference in Dublin on 2017-09-26.
The document describes new features and enhancements in MySQL 8.0, including common table expressions, window functions, improved UTF-8 support, geospatial functions, new locking options for SELECT statements, JSON functions, index extensions, cost model improvements, query hints, and better support for IPv6 and UUID data types. The presentation agenda outlines each topic at a high level.
The document discusses the components of the SQL Server database engine and services. The database engine includes key processes like the algebrizer, query optimizer, query engine, storage engine, buffer manager, and lock manager. SQL Server services allow controlling and communicating with SQL Server, including the SQL Server Agent, Database Mail, and Distributed Transaction Coordinator. The document also covers SQL statements, query flow, joins, and including data with subqueries and common table expressions.
This document provides an overview of SQL analytic queries and tips and tricks, mostly related to PostgreSQL. It begins with an introduction on the topics to be covered, including SQL basics, advanced topics, and a conclusion. It then shares some lesser known facts about SQL, including that it is standardized, turing complete, and the only successful 4th generation programming language. The document reviews the revision history of SQL standards from 1986 to the present. It provides examples of common table expressions, temporary tables, unnesting and aggregation, subqueries, and lateral joins in SQL.
This document discusses advances in SQL queries, including more complex retrieval queries using NULL values and three-valued logic, nested/subqueries using operators like IN and EXISTS, and group functions like COUNT and AVG. It also covers JOINs like inner, outer, full and equi joins used to combine data from multiple tables based on join conditions between columns.
This document discusses common table expressions (CTEs) in MySQL 8.0. It begins with an introduction to CTEs, explaining that they allow for subqueries to be defined before the main query similar to derived tables but with better performance and readability. It then provides examples of non-recursive and recursive CTEs. For non-recursive CTEs, it demonstrates finding the best and worst month of sales. For recursive CTEs, it shows examples of generating a sequence of numbers from 1 to 10 and generating missing dates in a date sequence. The document emphasizes that CTEs only need to be materialized once, improving performance over derived tables.
This document discusses common table expressions (CTEs) in MySQL 8.0. It begins with an introduction to CTEs, explaining how they provide an alternative to derived tables. The document then covers non-recursive and recursive CTEs. For non-recursive CTEs, it provides examples of finding the best and worst month of sales. For recursive CTEs, it demonstrates examples such as generating a sequence of numbers and traversing a employee hierarchy. The key benefits of CTEs over derived tables are also summarized, such as improved readability, ability to reference a CTE multiple times, and potential performance improvements from avoiding multiple materializations.
This is a presentation from Oracle Week 2016 (Israel). This is a newer version from last year with new 12cR2 features and demo.
In the agenda:
Aggregative and advanced grouping options
Analytic functions, ranking and pagination
Hierarchical and recursive queries
Regular Expressions
Oracle 12c new rows pattern matching
XML and JSON handling with SQL
Oracle 12c (12.1 + 12.2) new features
SQL Developer Command Line tool
The document discusses subqueries, backups, users, and privileges in SQL. It defines subqueries as SELECT statements nested inside other SELECT statements. Subqueries can include joins, WHERE clauses, and more. The document explains the terminology used in subqueries including inner and outer queries. It provides examples of different types of subqueries like those in the SELECT list, using operators like IN, ANY, ALL, and EXISTS. The document also discusses backups and why they are important to protect against data loss from hardware failures, natural disasters, and human errors. HAVING clauses are introduced as a way to use aggregate functions in queries.
SQL is a language used to interface with relational database systems. It was developed by IBM in the 1970s and is now an industry standard. SQL has three main sublanguages: DDL for defining database schemas, DML for manipulating data, and DCL for controlling access.
Some key points about SQL include:
- DDL commands like CREATE, ALTER, and DROP are used to define and modify database structures.
- DML commands like SELECT, INSERT, UPDATE, and DELETE are used to query and manipulate the data.
- DCL commands like COMMIT, ROLLBACK, GRANT and REVOKE control transactions and user privileges.
- SQL can be used
Database Management System - SQL Advanced TrainingMoutasm Tamimi
Database Management System - SQL Advanced Training
Using SQL language
By Microsoft SQL Server program
version 2008-2010-2012-2014
Prepared by: Moutasm Tamimi
Many questions on database newsgroups and forums can be answered with uses of outer joins. Outer joins are part of the standard SQL language and supported by all RDBMS brands. Many programmers are expected to use SQL in their work, but few know how to use outer joins effectively.
Learn to use this powerful feature of SQL, increase your employability, and amaze your friends!
Karwin will explain outer joins, show examples, and demonstrate a Sudoku puzzle solver implemented in a single SQL query.
Standard SQL features where PostgreSQL beats its competitorsMarkus Winand
The SQL standard has more than 4300 pages and hundreds of optional features. The number of features offered by different products varies vastly. PostgreSQL implements a relativley large number of them.
In this session I present some standard SQL features that work in PostgreSQL, but not in other popular open-source databases. But when it comes to standard conformance, PostgreSQL doesn’t even need to fear the comparison to its commercial competitors: PostgreSQL also supports a few useful standard SQL features that don’t work in any of the three most popular commercial SQL databases.
Four* Major Database Releases of 2017 in ReviewMarkus Winand
Four major database releases from 2017-2018 are summarized: MariaDB 10.2 released in May 2017 and was the first to include window functions and common table expressions; SQL Server 2017 released in October 2017 with some new functions but missing others from the SQL standard; PostgreSQL 10 also released in October 2017 with parallel query and statistics improvements; and MySQL 8.0 has no official release yet but has added window functions and common table expressions in pre-release versions. The document also provides details on new features, conformance testing results, and information about the author.
Backend to Frontend: When database optimization affects the full stackMarkus Winand
This document discusses different techniques for pagination in databases. It begins by describing the issues with using offsets for pagination, as it can lead to unstable performance. It then introduces key-set pagination as an alternative, where the next set of rows is queried based on a unique identifier from the previous set rather than an offset. This allows for faster and more consistent performance even when browsing through many pages of data. The document also notes some limitations of key-set pagination and tools needed for it to work effectively.
SQL Performance - Vienna System Architects Meetup 20131202Markus Winand
The document discusses database indexing and summarizes the results of a short quiz about indexing techniques. The quiz contains 5 questions that test knowledge of indexing technologies like index column order, indexing date fields, and indexing fields with wildcards. Taking the time to properly learn and apply indexing is important for optimizing database performance, but indexing is often neglected. The presenter is an expert on database performance tuning who provides training and writes on the topic.
Indexes: The neglected performance all rounderMarkus Winand
The document discusses improper index use as a common cause of poor database performance. It argues that indexing is often treated as an administrative task rather than a development task, but developers do not fully understand how to properly use indexes. As a result, indexes are not designed to match the overall needs of an application's queries. The document advocates that indexing should be viewed as a design task and that developers need to more fully learn how to utilize indexes to improve performance.
The SQL OFFSET keyword is evil. It basically behaves like SLEEP in other programming langauges: the bigger the number, the slower the execution.
Fetching results in a page-by-page fashion in SQL doesn't require OFFSET at all but an even simpler SQL clause. Besides being faster, you don't have to cope with drifting results if new data is inserted between two page fetches.
Delivering More with Less: AI Driven Resource Management with OnePlan OnePlan Solutions
Delivering more with less is an age-old problem. Smaller budgets, leaner teams, and greater uncertainty make the path to success unclear. Combat these issues with confidence by leveraging the best practices that help PMOs balance workloads, predict bottlenecks, and ensure resources are deployed effectively, using OnePlan’s AI forecasting capabilities, especially when organizations must deliver more with fewer people.
AI-ASSISTED METAMORPHIC TESTING FOR DOMAIN-SPECIFIC MODELLING AND SIMULATIONmiso_uam
AI-ASSISTED METAMORPHIC TESTING FOR DOMAIN-SPECIFIC MODELLING AND SIMULATION (plenary talk at ANNSIM'2025)
Testing is essential to improve the correctness of software systems. Metamorphic testing (MT) is an approach especially suited when the system under test lacks oracles, or they are expensive to compute. However, building an MT environment for a particular domain (e.g., cloud simulation, automated driving simulation, production system simulation, etc) requires substantial effort.
To alleviate this problem, we propose a model-driven engineering approach to automate the construction of MT environments, which is especially useful to test domain-specific modelling and simulation systems. Starting from a meta-model capturing the domain concepts, and a description of the domain execution environment, our approach produces an MT environment featuring comprehensive support for the MT process. This includes the definition of domain-specific metamorphic relations, their evaluation, detailed reporting of the testing results, and the automated search-based generation of follow-up test cases.
In this talk, I presented the approach, along with ongoing work and perspectives for integrating intelligence assistance based on large language models in the MT process. The work is a joint collaboration with Pablo Gómez-Abajo, Pablo C. Cañizares and Esther Guerra from the miso research group and Alberto Núñez from UCM.
VALiNTRY360’s Salesforce Experience Cloud Consulting services empower organizations to build personalized, engaging digital experiences for customers, partners, and employees. Our certified Salesforce experts help you design, implement, and optimize Experience Cloud portals tailored to your business goals. From self-service communities to partner collaboration hubs, we ensure seamless integration, enhanced user engagement, and scalable solutions. Whether you're improving customer support or streamlining partner communication, VALiNTRY360 delivers strategic consulting to maximize the value of Salesforce Experience Cloud. Trust us to transform your digital experiences into powerful tools that drive loyalty, efficiency, and growth. Partner with VALiNTRY360 to elevate every user interaction.
For more info visit us https://valintry360.com/salesforce-experience-cloud
Custom Software Development: Types, Applications and Benefits.pdfDigital Aptech
Discover the different types of custom software, their real-world applications across industries, and the key benefits they offer. Learn how tailored solutions improve efficiency, scalability, and business performance in this comprehensive overview.
Climate-Smart Agriculture Development Solution.pptxjulia smits
A technology-driven solution designed to promote sustainable, resilient, and productive farming practices. It integrates data, smart tools, and climate insights to help farmers adapt to climate change, optimize resource use, and boost yields sustainably.
Secure and Simplify IT Management with ManageEngine Endpoint Central.pdfNorthwind Technologies
ManageEngine Endpoint Central (formerly known as Desktop Central) is an all-in-one endpoint management solution designed for managing a diverse and distributed IT environment. It supports Windows, macOS, Linux, iOS, Android, and Chrome OS devices, offering a centralized approach to managing endpoints — whether they’re on-premise, remote, or hybrid.
Unlock the full potential of cloud computing with BoxLang! Discover how BoxLang’s modern, JVM-based language streamlines development, enhances productivity and simplifies scaling in a serverless environment.
List Unfolding - 'unfold' as the Computational Dual of 'fold', and how 'unfol...Philip Schwarz
In this deck we look at the following:
* how unfolding lists is the computational dual of folding lists
* different variants of the function for unfolding lists
* how they relate to the iterate function
Shortcomings of EHS Software – And How to Overcome ThemTECH EHS Solution
Shortcomings of EHS Software—and What Overcomes Them
What you'll learn in just 8 slides:
- 🔍 Why most EHS software implementations struggle initially
- 🚧 3 common pitfalls: adoption, workflow disruption, and delayed ROI
- 🛠️ Practical solutions that deliver long-term value
- 🔐 Key features: centralization, security, affordability
- 📈 Why the pros outweigh the cons
Perfect for HSE heads, plant managers, and compliance leads!
#EHS #TECHEHS #WorkplaceSafety #EHSCompliance #EHSManagement #ehssoftware #safetysoftware
How a Staff Augmentation Company IN USA Powers Flutter App Breakthroughs.pdfmary rojas
With local teams and talent aligned with U.S. business hours, a staff augmentation company in the USA enables real-time communication, faster decision-making, and better project coordination. This ensures smoother workflows compared to offshore-only models, especially for companies requiring tight collaboration.
In today’s world, artificial intelligence (AI) is transforming the way we learn. This talk will explore how we can use AI tools to enhance our learning experiences.
But as we embrace these new technologies, we must also ask ourselves: Are we becoming less capable of thinking for ourselves? Do these tools make us smarter, or do they risk dulling our critical thinking skills? This talk will encourage us to think critically about the role of AI in our education. Together, we will discover how to use AI to support our learning journey while still developing our ability to think critically.
UberEats clone app Development TechBuilderTechBuilder
Our food delivery app development solutions are designed to cater to varied business models, whether you are a startup aiming to scale, an enterprise-class business, or a niche player. With scalability, easy-to-use interfaces, and powerful AI capabilities, our solutions scale with your vision.
For more Please Visit Here : https://techbuilder.ai/food-delivery-app-development/
How to Recover Hacked Gmail Account || Help Email TalesRoger Reed
Due to weak security measures, there is a high chance that your email account will get hacked. If you are also unable to access your Gmail account, then various solutions might help you get back to your account. So, keep reading to learn everything in great detail.
VFP-Report-Copy-Data-Environment details.
I am MCTS - (Microsoft Certified Tech. Specialist).
I had started my journey with COBOL, dbaseIII+, Clipper, Foxpro - DOS/WIndows/Visual, VB6.
My 130+ Articles on .NET : https://www.c-sharpcorner.com/members/manoj-kalla3
My YouTube Channel: https://www.youtube.com/@manojkalla4174/playlists
Total 200+ Videos on Visual Foxpro.
My Medium Article : https://medium.com/@manojkalla
Ahmedabad Information Technology IT college Syllabus for BCA, MCA and online teaching for Asp.Net MVC, Asp.Net Core, Java, C Language, C++ Language, Entity Framework, Linq To SQL, Android.
The Maharaja Sayajirao University (M.S. University), Dr. Babasaheb Ambedkar Open University (BAOU), Indus University (IU), Ahmedabad courses and G.L.S. Institute Of Computer Application (GLSICA), Gujarat University online courses BCA, MCA and BTech, MTech online.
Mehsana Information Technology IT college Syllabus for BCA, MCA.
Mehsana online teaching for Asp.Net MVC, Asp.Net Core, Java, C Language, C++ Language, Entity Framework, Linq To SQL, Android.
Yashwantrao Chavan Maharashtra Open University (YCMOU) course online training institute.
YCMOU Java Notes, YCMOU Android Training, YCMOU Java Training, YCMOU Linux Course, YCMOU syllabus online Training insitute, YCMOU C++ Notes, YCMOU C++ online training, YCMOU C++ online tutor.
YCMOU BCA tutor , YCMOU BCA training,
Bharati Vidyapeeth University (BVP) courses online training ,
Bharati Vidyapeeth University (BVP) courses online tutor,
Bharati Vidyapeeth University (BVP) courses BCA online training ,
Bharati Vidyapeeth University (BVP) courses BTECH online tutor,
Angular online tutor in malad mumbai,
Angular online tutor in kandivali mumbai,
Angular online tutor in bhayandar mumbai,
Angular online tutor in vapi gujrat,
Angular online tutor in surat gujrat,
Angular online tutor in baroda gujrat,
Angular online tutor in vadodara gujrat,
Angular online tutor in indore MP,
Angular online tutor in bhopal MP,
Angular online tutor in nashik maharashtra,
Angular online tutor in pune maharashtra,
Angular online training institute in Bandra Mumbai,
Angular online training institute in mehsana Gujrat,
Angular online tutor in malad mumbai,
Angular online tutor in kandivali mumbai,
Angular online tutor in bhayandar mumbai,
Angular online tutor in vapi gujrat,
Angular online tutor in surat gujrat,
Angular online tutor in baroda gujrat,
Angular online tutor in vadodara gujrat,
Angular online tutor in indore MP,
Angular online tutor in bhopal MP,
Angular online tutor in nashik maharashtra,
Angular online tutor in pune maharashtra,
Angular online training institute in Bandra Mumbai,
Angular online training institute in mehsana Gujrat,
Marketing And Sales Software Services.pptxjulia smits
Marketing and Sales Software Services refer to digital solutions designed to streamline, automate, and enhance a company’s marketing campaigns and sales processes. These services include tools for customer relationship management (CRM), email marketing, lead generation, sales analytics, campaign tracking, and more—helping businesses attract, engage, and convert prospects more efficiently.
4. Select-list sub-queries must be scalar[0]:
LATERAL Before SQL:1999
SELECT …
, (SELECT column_1
FROM t1
WHERE t1.x = t2.y
) AS c
FROM t2
…
(an atomic quantity that can hold only one value at a time[1])
[0] Neglecting row values and other workarounds here; [1] https://en.wikipedia.org/wiki/Scalar
5. Select-list sub-queries must be scalar[0]:
LATERAL Before SQL:1999
SELECT …
, (SELECT column_1
FROM t1
WHERE t1.x = t2.y
) AS c
FROM t2
…
(an atomic quantity that can hold only one value at a time[1])
[0] Neglecting row values and other workarounds here; [1] https://en.wikipedia.org/wiki/Scalar
✗, column_2
More than
one column?
Syntax error
}
More than
one row?
Runtime error!
6. Lateral derived tables lift both limitations and can be correlated:
LATERAL Since SQL:1999
SELECT …
, ldt.*
FROM t2
LEFT JOIN LATERAL (SELECT column_1, column_2
FROM t1
WHERE t1.x = t2.y
) AS ldt
ON (true)
…
7. Lateral derived tables lift both limitations and can be correlated:
LATERAL Since SQL:1999
SELECT …
, ldt.*
FROM t2
LEFT JOIN LATERAL (SELECT column_1, column_2
FROM t1
WHERE t1.x = t2.y
) AS ldt
ON (true)
…
“Derived table” means
it’s in the
FROM/JOIN clause
Still
“correlated”
Regular join
semantics
8. FROM t
JOIN LATERAL (SELECT …
FROM …
WHERE t.c=…
ORDER BY …
LIMIT 10
) derived_table
‣ Top-N per group
inside a lateral derived table
FETCH FIRST (or LIMIT, TOP)
applies per row from left tables.
‣ Also useful to find most recent
news from several subscribed
topics (“multi-source top-N”).
Use-CasesLATERAL
Add proper index
for Top-N query
http://use-the-index-luke.com/sql/partial-results/top-n-queries
9. FROM t
JOIN LATERAL (SELECT …
FROM …
WHERE t.c=…
ORDER BY …
LIMIT 10
) derived_table
‣ Top-N per group
inside a lateral derived table
FETCH FIRST (or LIMIT, TOP)
applies per row from left tables.
‣ Also useful to find most recent
news from several subscribed
topics (“multi-source top-N”).
‣ Table function arguments
(TABLE often implies LATERAL)
Use-CasesLATERAL
FROM t
JOIN TABLE (your_func(t.c))
10. LATERAL is the "for each" loop of SQL
LATERAL plays well with outer and cross joins
LATERAL is great for Top-N subqueries
LATERAL can join table functions (unnest!)
LATERAL In a Nutshell
13. Only one GROUP BY operation at a time:
GROUPING SETS Before SQL:1999
SELECT year
, month
, sum(revenue)
FROM tbl
GROUP BY year, month
Monthly revenue Yearly revenue
SELECT year
, sum(revenue)
FROM tbl
GROUP BY year
17. GROUPING SETS are multiple GROUP BYs in one go
() (empty brackets) build a group over all rows
GROUPING (function) disambiguates the meaning of NULL
(was the grouped data NULL or is this column not currently grouped?)
Permutations can be created using ROLLUP and CUBE
(ROLLUP(a,b,c) = GROUPING SETS ((a,b,c), (a,b),(a),())
GROUPING SETS In a Nutshell
20. WITH (non-recursive) The Problem
Nested queries are hard to read:
SELECT …
FROM (SELECT …
FROM t1
JOIN (SELECT … FROM …
) a ON (…)
) b
JOIN (SELECT … FROM …
) c ON (…)
21. Understand
this first
WITH (non-recursive) The Problem
Nested queries are hard to read:
SELECT …
FROM (SELECT …
FROM t1
JOIN (SELECT … FROM …
) a ON (…)
) b
JOIN (SELECT … FROM …
) c ON (…)
22. Then this...
WITH (non-recursive) The Problem
Nested queries are hard to read:
SELECT …
FROM (SELECT …
FROM t1
JOIN (SELECT … FROM …
) a ON (…)
) b
JOIN (SELECT … FROM …
) c ON (…)
23. Then this...
WITH (non-recursive) The Problem
Nested queries are hard to read:
SELECT …
FROM (SELECT …
FROM t1
JOIN (SELECT … FROM …
) a ON (…)
) b
JOIN (SELECT … FROM …
) c ON (…)
24. Finally the first line makes sense
WITH (non-recursive) The Problem
Nested queries are hard to read:
SELECT …
FROM (SELECT …
FROM t1
JOIN (SELECT … FROM …
) a ON (…)
) b
JOIN (SELECT … FROM …
) c ON (…)
25. CTEs are statement-scoped views:
WITH
a (c1, c2, c3)
AS (SELECT c1, c2, c3 FROM …),
b (c4, …)
AS (SELECT c4, …
FROM t1
JOIN a
ON (…)
),
WITH (non-recursive) Since SQL:1999
26. CTEs are statement-scoped views:
WITH
a (c1, c2, c3)
AS (SELECT c1, c2, c3 FROM …),
b (c4, …)
AS (SELECT c4, …
FROM t1
JOIN a
ON (…)
),
Keyword
WITH (non-recursive) Since SQL:1999
27. CTEs are statement-scoped views:
WITH
a (c1, c2, c3)
AS (SELECT c1, c2, c3 FROM …),
b (c4, …)
AS (SELECT c4, …
FROM t1
JOIN a
ON (…)
),
Name of CTE and (here
optional) column names
WITH (non-recursive) Since SQL:1999
28. CTEs are statement-scoped views:
WITH
a (c1, c2, c3)
AS (SELECT c1, c2, c3 FROM …),
b (c4, …)
AS (SELECT c4, …
FROM t1
JOIN a
ON (…)
),
Definition
WITH (non-recursive) Since SQL:1999
29. CTEs are statement-scoped views:
WITH
a (c1, c2, c3)
AS (SELECT c1, c2, c3 FROM …),
b (c4, …)
AS (SELECT c4, …
FROM t1
JOIN a
ON (…)
),
Introduces
another CTE
Don't repeat
WITH
WITH (non-recursive) Since SQL:1999
30. CTEs are statement-scoped views:
WITH
a (c1, c2, c3)
AS (SELECT c1, c2, c3 FROM …),
b (c4, …)
AS (SELECT c4, …
FROM t1
JOIN a
ON (…)
),
May refer to
previous CTEs
WITH (non-recursive) Since SQL:1999
34. CTEs are statement-scoped views:
WITH
a (c1, c2, c3)
AS (SELECT c1, c2, c3 FROM …),
b (c4, …)
AS (SELECT c4, …
FROM t1
JOIN a
ON (…)
),
c (…)
AS (SELECT … FROM …)
SELECT …
FROM b JOIN c ON (…)
Read
top down
WITH (non-recursive) Since SQL:1999
35. ‣ Literate SQL
Organize SQL code to
improve maintainability
‣ Assign column names
to tables produced by values
or unnest.
‣ Overload tables (for testing)
with queries hide tables
of the same name.
Use-CasesWITH (non-recursive)
http://modern-sql.com/use-case/literate-sql
http://modern-sql.com/use-case/naming-unnamed-columns
http://modern-sql.com/use-case/unit-tests-on-transient-data
36. WITH are the "private methods" of SQL
WITH is a prefix to SELECT
WITH queries are only visible in the SELECT
they precede
WITH in detail:
http://modern-sql.com/feature/with
WITH (non-recursive) In a Nutshell
41. Views and derived tables support "predicate pushdown":
SELECT *
FROM (SELECT *
FROM news
) n
WHERE topic=1;
PostgreSQL “issues”WITH (non-recursive)
42. Views and derived tables support "predicate pushdown":
SELECT *
FROM (SELECT *
FROM news
) n
WHERE topic=1;
Bitmap Heap Scan
on news (rows=6370)
->Bitmap Index Scan
on idx (rows=6370)
Cond: topic=1
PostgreSQL “issues”WITH (non-recursive)
43. PostgreSQL 9.1+ allows DML within WITH:
WITH deleted_rows AS (
DELETE FROM source_tbl
RETURNING *
)
INSERT INTO destination_tbl
SELECT * FROM deleted_rows;
PostgreSQL ExtensionWITH (non-recursive)
51. Recursive common table expressions may refer to
themselves in the second leg of a UNION [ALL]:
WITH RECURSIVE cte (n)
AS (SELECT 1
UNION ALL
SELECT n+1
FROM cte
WHERE n < 3)
SELECT * FROM cte
Since SQL:1999WITH RECURSIVE
52. Recursive common table expressions may refer to
themselves in the second leg of a UNION [ALL]:
WITH RECURSIVE cte (n)
AS (SELECT 1
UNION ALL
SELECT n+1
FROM cte
WHERE n < 3)
SELECT * FROM cte
Keyword
Since SQL:1999WITH RECURSIVE
53. Recursive common table expressions may refer to
themselves in the second leg of a UNION [ALL]:
WITH RECURSIVE cte (n)
AS (SELECT 1
UNION ALL
SELECT n+1
FROM cte
WHERE n < 3)
SELECT * FROM cte
Column list
mandatory here
Since SQL:1999WITH RECURSIVE
54. Recursive common table expressions may refer to
themselves in the second leg of a UNION [ALL]:
WITH RECURSIVE cte (n)
AS (SELECT 1
UNION ALL
SELECT n+1
FROM cte
WHERE n < 3)
SELECT * FROM cte
Executed first
Since SQL:1999WITH RECURSIVE
55. Recursive common table expressions may refer to
themselves in the second leg of a UNION [ALL]:
WITH RECURSIVE cte (n)
AS (SELECT 1
UNION ALL
SELECT n+1
FROM cte
WHERE n < 3)
SELECT * FROM cte
Result
sent there
Since SQL:1999WITH RECURSIVE
56. Recursive common table expressions may refer to
themselves in the second leg of a UNION [ALL]:
WITH RECURSIVE cte (n)
AS (SELECT 1
UNION ALL
SELECT n+1
FROM cte
WHERE n < 3)
SELECT * FROM cte
Result
visible
twice
Since SQL:1999WITH RECURSIVE
57. Recursive common table expressions may refer to
themselves in the second leg of a UNION [ALL]:
WITH RECURSIVE cte (n)
AS (SELECT 1
UNION ALL
SELECT n+1
FROM cte
WHERE n < 3)
SELECT * FROM cte
n
---
1
2
3
(3 rows)
Once it becomes
part of
the final
result
Since SQL:1999WITH RECURSIVE
58. Recursive common table expressions may refer to
themselves in the second leg of a UNION [ALL]:
WITH RECURSIVE cte (n)
AS (SELECT 1
UNION ALL
SELECT n+1
FROM cte
WHERE n < 3)
SELECT * FROM cte
n
---
1
2
3
(3 rows)
Since SQL:1999WITH RECURSIVE
59. Recursive common table expressions may refer to
themselves in the second leg of a UNION [ALL]:
WITH RECURSIVE cte (n)
AS (SELECT 1
UNION ALL
SELECT n+1
FROM cte
WHERE n < 3)
SELECT * FROM cte
n
---
1
2
3
(3 rows)
Second
leg of
UNION
is
executed
Since SQL:1999WITH RECURSIVE
60. Recursive common table expressions may refer to
themselves in the second leg of a UNION [ALL]:
WITH RECURSIVE cte (n)
AS (SELECT 1
UNION ALL
SELECT n+1
FROM cte
WHERE n < 3)
SELECT * FROM cte
n
---
1
2
3
(3 rows)
Result
sent there
again
Since SQL:1999WITH RECURSIVE
61. Recursive common table expressions may refer to
themselves in the second leg of a UNION [ALL]:
WITH RECURSIVE cte (n)
AS (SELECT 1
UNION ALL
SELECT n+1
FROM cte
WHERE n < 3)
SELECT * FROM cte
n
---
1
2
3
(3 rows)
Since SQL:1999WITH RECURSIVE
62. Recursive common table expressions may refer to
themselves in the second leg of a UNION [ALL]:
WITH RECURSIVE cte (n)
AS (SELECT 1
UNION ALL
SELECT n+1
FROM cte
WHERE n < 3)
SELECT * FROM cte
n
---
1
2
3
(3 rows)
It's a
loop!
Since SQL:1999WITH RECURSIVE
63. Recursive common table expressions may refer to
themselves in the second leg of a UNION [ALL]:
WITH RECURSIVE cte (n)
AS (SELECT 1
UNION ALL
SELECT n+1
FROM cte
WHERE n < 3)
SELECT * FROM cte
n
---
1
2
3
(3 rows)
It's a
loop!
Since SQL:1999WITH RECURSIVE
64. Recursive common table expressions may refer to
themselves in the second leg of a UNION [ALL]:
WITH RECURSIVE cte (n)
AS (SELECT 1
UNION ALL
SELECT n+1
FROM cte
WHERE n < 3)
SELECT * FROM cte
n
---
1
2
3
(3 rows)
It's a
loop!
Since SQL:1999WITH RECURSIVE
65. Recursive common table expressions may refer to
themselves in the second leg of a UNION [ALL]:
WITH RECURSIVE cte (n)
AS (SELECT 1
UNION ALL
SELECT n+1
FROM cte
WHERE n < 3)
SELECT * FROM cte
n
---
1
2
3
(3 rows)
n=3
doesn't
match
Since SQL:1999WITH RECURSIVE
66. Recursive common table expressions may refer to
themselves in the second leg of a UNION [ALL]:
WITH RECURSIVE cte (n)
AS (SELECT 1
UNION ALL
SELECT n+1
FROM cte
WHERE n < 3)
SELECT * FROM cte
n
---
1
2
3
(3 rows)
n=3
doesn't
match
Loop
terminates
Since SQL:1999WITH RECURSIVE
67. Use Cases
‣ Row generators
To fill gaps (e.g., in time series),
generate test data.
‣ Processing graphs
Shortest route from person A to B
in LinkedIn/Facebook/Twitter/…
‣ Finding distinct values
with n*log(N)† time complexity.
[…many more…]
As shown on previous slide
http://aprogrammerwrites.eu/?p=1391
“[…] for certain classes of graphs, solutions utilizing
relational database technology […] can offer
performance superior to that of the dedicated graph
databases.” event.cwi.nl/grades2013/07-welc.pdf
http://wiki.postgresql.org/wiki/Loose_indexscan
† n … # distinct values, N … # of table rows. Suitable index required
WITH RECURSIVE
68. WITH RECURSIVE is the “while” of SQL
WITH RECURSIVE "supports" infinite loops
Except PostgreSQL, databases generally don't require
the RECURSIVE keyword.
DB2, SQL Server & Oracle don’t even know the
keyword RECURSIVE, but allow recursive CTEs anyway.
In a NutshellWITH RECURSIVE
76. OVER (PARTITION BY) The Problem
Two distinct concepts could not be used independently:
‣ Merge rows with the same key properties
‣ GROUP BY to specify key properties
‣ DISTINCT to use full row as key
‣ Aggregate data from related rows
‣ Requires GROUP BY to segregate the rows
‣ COUNT, SUM, AVG, MIN, MAX to aggregate grouped rows
78. SELECT c1
, SUM(c2) tot
FROM t
GROUP BY c1
OVER (PARTITION BY) The Problem
Yes⇠Mergerows⇢No
No ⇠ Aggregate ⇢ Yes
SELECT c1
, c2
FROM t
SELECT DISTINCT
c1
, c2
FROM t
SELECT c1
, c2
FROM t
JOIN ( ) ta
ON (t.c1=ta.c1)
SELECT c1
, SUM(c2) tot
FROM t
GROUP BY c1
, tot
79. SELECT c1
, SUM(c2) tot
FROM t
GROUP BY c1
OVER (PARTITION BY) The Problem
Yes⇠Mergerows⇢No
No ⇠ Aggregate ⇢ Yes
SELECT c1
, c2
FROM t
SELECT DISTINCT
c1
, c2
FROM t
SELECT c1
, c2
FROM t
JOIN ( ) ta
ON (t.c1=ta.c1)
SELECT c1
, SUM(c2) tot
FROM t
GROUP BY c1
, tot
89. acnt id value balance
1 1 +10 +10
22 2 +20 +30
22 3 -10 +20
333 4 +50 +70
333 5 -30 +40
333 6 -20 +20
OVER (ORDER BY) The Problem
SELECT id,
value,
FROM transactions t
90. acnt id value balance
1 1 +10 +10
22 2 +20 +30
22 3 -10 +20
333 4 +50 +70
333 5 -30 +40
333 6 -20 +20
OVER (ORDER BY) The Problem
SELECT id,
value,
(SELECT SUM(value)
FROM transactions t2
WHERE t2.id <= t.id)
FROM transactions t
91. acnt id value balance
1 1 +10 +10
22 2 +20 +30
22 3 -10 +20
333 4 +50 +70
333 5 -30 +40
333 6 -20 +20
OVER (ORDER BY) The Problem
SELECT id,
value,
(SELECT SUM(value)
FROM transactions t2
WHERE t2.id <= t.id)
FROM transactions t
Range segregation (<=)
not possible with
GROUP BY or
PARTITION BY
92. OVER (ORDER BY) Since SQL:2003
SELECT id,
value,
FROM transactions t
SUM(value)
OVER (
)
acnt id value balance
1 1 +10 +10
22 2 +20 +30
22 3 -10 +20
333 4 +50 +70
333 5 -30 +40
333 6 -20 +20
ORDER BY id
93. OVER (ORDER BY) Since SQL:2003
SELECT id,
value,
FROM transactions t
SUM(value)
OVER (
)
acnt id value balance
1 1 +10 +10
22 2 +20 +30
22 3 -10 +20
333 4 +50 +70
333 5 -30 +40
333 6 -20 +20
ORDER BY id
ROWS BETWEEN
UNBOUNDED PRECEDING
94. OVER (ORDER BY) Since SQL:2003
SELECT id,
value,
FROM transactions t
SUM(value)
OVER (
)
acnt id value balance
1 1 +10 +10
22 2 +20 +30
22 3 -10 +20
333 4 +50 +70
333 5 -30 +40
333 6 -20 +20
ORDER BY id
ROWS BETWEEN
UNBOUNDED PRECEDING
AND CURRENT ROW
95. OVER (ORDER BY) Since SQL:2003
SELECT id,
value,
FROM transactions t
SUM(value)
OVER (
)
acnt id value balance
1 1 +10 +10
22 2 +20 +30
22 3 -10 +20
333 4 +50 +70
333 5 -30 +40
333 6 -20 +20
ORDER BY id
ROWS BETWEEN
UNBOUNDED PRECEDING
AND CURRENT ROW
96. OVER (ORDER BY) Since SQL:2003
SELECT id,
value,
FROM transactions t
SUM(value)
OVER (
)
acnt id value balance
1 1 +10 +10
22 2 +20 +30
22 3 -10 +20
333 4 +50 +70
333 5 -30 +40
333 6 -20 +20
ORDER BY id
ROWS BETWEEN
UNBOUNDED PRECEDING
AND CURRENT ROW
97. OVER (ORDER BY) Since SQL:2003
SELECT id,
value,
FROM transactions t
SUM(value)
OVER (
)
acnt id value balance
1 1 +10 +10
22 2 +20 +30
22 3 -10 +20
333 4 +50 +70
333 5 -30 +40
333 6 -20 +20
ORDER BY id
ROWS BETWEEN
UNBOUNDED PRECEDING
AND CURRENT ROW
98. OVER (ORDER BY) Since SQL:2003
SELECT id,
value,
FROM transactions t
SUM(value)
OVER (
)
acnt id value balance
1 1 +10 +10
22 2 +20 +30
22 3 -10 +20
333 4 +50 +70
333 5 -30 +40
333 6 -20 +20
ORDER BY id
ROWS BETWEEN
UNBOUNDED PRECEDING
AND CURRENT ROW
99. OVER (ORDER BY) Since SQL:2003
SELECT id,
value,
FROM transactions t
SUM(value)
OVER (
)
acnt id value balance
1 1 +10 +10
22 2 +20 +30
22 3 -10 +20
333 4 +50 +70
333 5 -30 +40
333 6 -20 +20
ORDER BY id
ROWS BETWEEN
UNBOUNDED PRECEDING
AND CURRENT ROW
100. OVER (ORDER BY) Since SQL:2003
SELECT id,
value,
FROM transactions t
SUM(value)
OVER (
)
acnt id value balance
1 1 +10 +10
22 2 +20 +20
22 3 -10 +10
333 4 +50 +50
333 5 -30 +20
333 6 -20 . 0
ORDER BY id
ROWS BETWEEN
UNBOUNDED PRECEDING
AND CURRENT ROW
PARTITION BY acnt
101. OVER (ORDER BY) Since SQL:2003
With OVER (ORDER BY n) a new type of functions make sense:
n ROW_NUMBER RANK DENSE_RANK PERCENT_RANK CUME_DIST
1 1 1 1 0 0.25
2 2 2 2 0.33… 0.75
3 3 2 2 0.33… 0.75
4 4 4 3 1 1
102. ‣ Aggregates without GROUP BY
‣ Running totals,
moving averages
‣ Ranking
‣ Top-N per Group
‣ Avoiding self-joins
[… many more …]
Use Cases
SELECT *
FROM (SELECT ROW_NUMBER()
OVER(PARTITION BY … ORDER BY …) rn
, t.*
FROM t) numbered_t
WHERE rn <= 3
AVG(…) OVER(ORDER BY …
ROWS BETWEEN 3 PRECEDING
AND 3 FOLLOWING) moving_avg
OVER(SQL:2003)
103. OVER may follow any aggregate function
OVER defines which rows are visible at each row
OVER() makes all rows visible at every row
OVER(PARTITION BY …) segregates like GROUP BY
OVER(ORDER BY … BETWEEN) segregates using <, >
In a NutshellOVER(SQL:2003)
136. OVER (LEAD, LAG, …) Since SQL:2011
1999
2001
2003
2005
2007
2009
2011
2013
2015
5.1[0]
MariaDB
MySQL
8.4[1]
PostgreSQL
SQLite
9.5[2]
11.1 DB2 LUW
8i[2]
11gR2 Oracle
2012[2]
SQL Server
[0]
Not yet available in MariaDB 10.2.2 (alpha). MDEV-8091
[1]
No IGNORE NULLS and FROM LAST as of PostgreSQL 9.6
[2]
No NTH_VALUE
140. ID Data start_ts end_ts
1 X 10:00:00
UPDATE ... SET DATA = 'Y' ...
ID Data start_ts end_ts
1 X 10:00:00 11:00:00
1 Y 11:00:00
DELETE ... WHERE ID = 1
INSERT ... (ID, DATA) VALUES (1, 'X')
Temporal Tables Since SQL:2011
141. ID Data start_ts end_ts
1 X 10:00:00
UPDATE ... SET DATA = 'Y' ...
ID Data start_ts end_ts
1 X 10:00:00 11:00:00
1 Y 11:00:00
DELETE ... WHERE ID = 1
ID Data start_ts end_ts
1 X 10:00:00 11:00:00
1 Y 11:00:00 12:00:00
Temporal Tables Since SQL:2011
142. Although multiple versions exist, only the “current”
one is visible per default.
After 12:00:00, SELECT * FROM t doesn’t return
anything anymore.
ID Data start_ts end_ts
1 X 10:00:00 11:00:00
1 Y 11:00:00 12:00:00
Temporal Tables Since SQL:2011
143. ID Data start_ts end_ts
1 X 10:00:00 11:00:00
1 Y 11:00:00 12:00:00
With FOR … AS OF you can query anything you like:
SELECT *
FROM t FOR SYSTEM_TIME AS OF
TIMESTAMP '2015-04-02 10:30:00'
ID Data start_ts end_ts
1 X 10:00:00 11:00:00
Temporal Tables Since SQL:2011
144. It isn’t possible to define constraints to avoid overlapping periods.
Workarounds are possible, but no fun: CREATE TRIGGER
id begin end
1 8:00 9:00
1 9:00 11:00
1 10:00 12:00
Temporal Tables The Problem
145. SQL:2011 provides means to cope with temporal tables:
PRIMARY KEY (id, period WITHOUT OVERLAPS)
Temporal Tables Since SQL:2011
Temporal support in SQL:2011 goes way further.
Please read this paper to get the idea:
Temporal features in SQL:2011
http://cs.ulb.ac.be/public/_media/teaching/infoh415/tempfeaturessql2011.pdf
146. Temporal Tables Since SQL:2011
1999
2001
2003
2005
2007
2009
2011
2013
2015
5.1 MariaDB
MySQL
PostgreSQL
SQLite
10.1 DB2 LUW
10gR1[0]
12cR1[1]
Oracle
2016[2]
SQL Server
[0]
Limited system versioning via Flashback
[1]
Limited application versioning added (e.g. no WITHOUT OVERLAPS)
[2]
Only system versioning
167. Since SQL:2016
grp val
1 B
1 A
1 C
2 X
SELECT grp
, LIST_AGG(val, ', ')
WITHIN GROUP (ORDER BY val)
FROM t
GROUP BY grp
LIST_AGG
168. Since SQL:2016
grp val
1 B
1 A
1 C
2 X
grp val
1 A, B, C
2 X
SELECT grp
, LIST_AGG(val, ', ')
WITHIN GROUP (ORDER BY val)
FROM t
GROUP BY grp
LIST_AGG
169. Since SQL:2016
grp val
1 B
1 A
1 C
2 X
grp val
1 A, B, C
2 X
SELECT grp
, LIST_AGG(val, ', ')
WITHIN GROUP (ORDER BY val)
FROM t
GROUP BY grp
LIST_AGG(val, ', ' ON OVERFLOW TRUNCATE '...' WITH COUNT) ➔ 'A, B, ...(1)'
LIST_AGG(val, ', ' ON OVERFLOW ERROR)
Default
LIST_AGG
LIST_AGG(val, ', ' ON OVERFLOW TRUNCATE '...' WITHOUT COUNT) ➔ 'A, B, ...'
Default