This document introduces windowing functions in Firebird 3. It explains that windowing functions allow calculations across sets of rows and provide access to values from related rows in the same table. It describes the syntax of window functions in Firebird and how they use windows to define partitions of rows and sort orders. Examples show how aggregate functions can be used as window functions to calculate moving and cumulative aggregates over window partitions.
The second presentation of a series of presentations on Operations Geology. Very basic, just to introduce beginners to operations geology. I hope the end users will find this and the following presentations very helpful.
The document discusses the benefits of exercise for mental health. Regular physical activity can help reduce anxiety and depression and improve mood and cognitive functioning. Exercise causes chemical changes in the brain that may help boost feelings of calmness, happiness and focus.
Petroleum reservoirs are classified as either oil or gas reservoirs based on reservoir temperature relative to critical temperature. Within these broad classifications, reservoirs can be further classified. Oil reservoirs have temperature below critical temperature, while gas reservoirs have temperature above critical. Specific gas reservoir classifications include retrograde, near-critical, wet and dry based on phase behavior and GOR. Retrograde reservoirs have unique condensation behavior on pressure depletion. Classification is important for understanding reservoir fluid properties, production behavior, and development approach.
The document discusses offshore drilling in the United States. It provides details on the history and locations of offshore drilling in the US. Offshore drilling produces a significant portion of US oil and gas. However, it also faces regulatory restrictions and debates around various costs and environmental concerns. The document also discusses the US partnership with Brazil to help develop offshore drilling capacity there.
Well Deliverability Assessment of Libyan Near-Critical Gas Condensate Field -...raghad gaderboh
This document summarizes a study of Well A3, located in a near critical gas condensate field in Libya. It discusses:
1) An analysis of well test data that found low permeability and a large composite skin value.
2) The construction of a simulation model to history match test data, which required introducing transmissibility barriers and adjusting skin and relative permeability values.
3) An assessment of well deliverability through inflow performance curves, finding low potential production due to damage. Stimulation could improve this.
4) Scenarios modeling natural depletion and gas cycling, finding cycling over 10 years enhances condensate recovery.
This document provides an overview of the key components and systems on a rotary drilling rig, including:
- The power system, which typically includes 1-3 diesel engines providing 1,000-3,000 hp of power to run systems like the hoisting system and rotary table.
- The hoisting system, which uses a drawworks powered by the engines to control the drilling line via a block and tackle system for raising/lowering the drill string and other equipment.
- Calculations for determining the mechanical advantage and efficiency of the block and tackle system based on factors like pulley efficiency, number of lines, and the ideal mechanical advantage provided by the number of lines.
The document discusses cement used in oil and gas wells. It covers cement composition, classes of cement, additives for controlling density, acceleration, retardation and viscosity. It also discusses cementing operations, equipment and performing a good cementing job. Key factors include casing centralization, pipe movement, drilling fluid viscosity, hole condition and achieving proper displacement velocity.
Casing and cementing involves running and cementing steel pipe (casing) into drilled wellbore sections to prevent collapse and seal off formations. Casing comes in various diameters, lengths, and strengths. It is run and connected using tools like elevators, spiders, and tongs. A typical cementing system uses centralizers, scrapers, and plugs to pump cement down the casing and up the wellbore annulus to isolate formations and seal the well. The cement job is monitored and considered complete when the calculated amount of cement has been displaced and the top plug separates from the bottom plug.
The second presentation of a series of presentations on Operations Geology. Very basic, just to introduce beginners to operations geology. I hope the end users will find this and the following presentations very helpful.
The document discusses the benefits of exercise for mental health. Regular physical activity can help reduce anxiety and depression and improve mood and cognitive functioning. Exercise causes chemical changes in the brain that may help boost feelings of calmness, happiness and focus.
Petroleum reservoirs are classified as either oil or gas reservoirs based on reservoir temperature relative to critical temperature. Within these broad classifications, reservoirs can be further classified. Oil reservoirs have temperature below critical temperature, while gas reservoirs have temperature above critical. Specific gas reservoir classifications include retrograde, near-critical, wet and dry based on phase behavior and GOR. Retrograde reservoirs have unique condensation behavior on pressure depletion. Classification is important for understanding reservoir fluid properties, production behavior, and development approach.
The document discusses offshore drilling in the United States. It provides details on the history and locations of offshore drilling in the US. Offshore drilling produces a significant portion of US oil and gas. However, it also faces regulatory restrictions and debates around various costs and environmental concerns. The document also discusses the US partnership with Brazil to help develop offshore drilling capacity there.
Well Deliverability Assessment of Libyan Near-Critical Gas Condensate Field -...raghad gaderboh
This document summarizes a study of Well A3, located in a near critical gas condensate field in Libya. It discusses:
1) An analysis of well test data that found low permeability and a large composite skin value.
2) The construction of a simulation model to history match test data, which required introducing transmissibility barriers and adjusting skin and relative permeability values.
3) An assessment of well deliverability through inflow performance curves, finding low potential production due to damage. Stimulation could improve this.
4) Scenarios modeling natural depletion and gas cycling, finding cycling over 10 years enhances condensate recovery.
This document provides an overview of the key components and systems on a rotary drilling rig, including:
- The power system, which typically includes 1-3 diesel engines providing 1,000-3,000 hp of power to run systems like the hoisting system and rotary table.
- The hoisting system, which uses a drawworks powered by the engines to control the drilling line via a block and tackle system for raising/lowering the drill string and other equipment.
- Calculations for determining the mechanical advantage and efficiency of the block and tackle system based on factors like pulley efficiency, number of lines, and the ideal mechanical advantage provided by the number of lines.
The document discusses cement used in oil and gas wells. It covers cement composition, classes of cement, additives for controlling density, acceleration, retardation and viscosity. It also discusses cementing operations, equipment and performing a good cementing job. Key factors include casing centralization, pipe movement, drilling fluid viscosity, hole condition and achieving proper displacement velocity.
Casing and cementing involves running and cementing steel pipe (casing) into drilled wellbore sections to prevent collapse and seal off formations. Casing comes in various diameters, lengths, and strengths. It is run and connected using tools like elevators, spiders, and tongs. A typical cementing system uses centralizers, scrapers, and plugs to pump cement down the casing and up the wellbore annulus to isolate formations and seal the well. The cement job is monitored and considered complete when the calculated amount of cement has been displaced and the top plug separates from the bottom plug.
This document provides an overview of the power and hoisting systems used on rotary drilling rigs. It discusses the typical components of a rig's power system, including diesel engines that provide mechanical or electric power. It also details the components that make up the hoisting system, including the derrick, drawworks, block and tackle pulley system, and their functions in raising and lowering equipment in the well. The block and tackle provides mechanical advantage to reduce the load on the drawworks. Formulas are provided to calculate the fast line force required to lift a weight and the load distribution throughout the rig.
r k bansal - A Textbook of Fluid Mechanics and hydraulic machines. 9-laxmi.pdfNallusamy5
This document describes a new type of battery that is safer and longer-lasting than current lithium-ion batteries. It works by using sodium ions rather than lithium ions and two different liquids to prevent fires. Sodium is more abundant than lithium, making it potentially more affordable and sustainable. Initial tests show the new battery maintains over 90% capacity after 250 charge cycles.
This document provides an overview of well design and construction. It begins with an agenda and then covers topics such as different types of drill rigs used for various water depths, rig systems for hoisting, rotating, circulating, and well control, well types (exploration, appraisal, development), typical well schematics, casing strings, typical lithology for the central North Sea, casing cementation, drilling fluids, drill bits, bottom-hole assemblies, drilling problems, and well evaluation using wireline logging. The document provides essential information on the key aspects and considerations for well design and construction.
The document discusses several methods for predicting fracture gradients: Hubbert & Willis, Matthews & Kelly, and Ben Eaton. It provides examples of calculating fracture gradients for a Texas Gulf Coast well using each method and summarizes the results. Experimental determination of fracture gradients using leak-off tests is also addressed. The Ben Eaton method is considered the most accurate as it accounts for variations in pore pressure, overburden stress, and Poisson's ratio.
The document provides information on different types of oil and gas drilling rigs used on land and offshore. It describes key components and uses of land rigs, as well as differences between light, medium, and heavy duty land rigs. For offshore rigs, it discusses jackup rigs, gravity platforms, semisubmersibles, tension leg platforms, spars, drillships and their applications in different water depths. Specific rigs like the Berkut and Seastars platforms are also summarized.
Offshore petroleum production has evolved from early onshore operations using wooden derricks to modern floating production systems. Initially, platforms were fixed structures on shallow continental shelves, using steel jacket designs. As water depths increased, new designs like compliant towers and tension leg platforms were developed. Today, the most common systems are semi-submersibles, spars, and ship-shaped floating production, storage, and offloading vessels (FPSOs), which are moored but move with ocean currents and waves. Designing integrated systems that account for environmental loads on the hull, mooring lines, risers, and subsea infrastructure is challenging and expensive, but continues to push into deeper waters and harsher environments to meet global energy demand
Offshore drilling is the process of drilling through the seabed to explore and extract petroleum deposits beneath the seafloor. It involves using seismic surveys to locate potential oil deposits, drilling holes hundreds to thousands of feet below the seabed using metal casing and drill pipes, and extracting oil through the wells. Offshore drilling poses environmental risks like oil spills that can harm ocean life and pollute shorelines if not properly regulated. Unconventional drilling methods allow drilling at angles and laterally to access more oil.
The document discusses the benefits of exercise for mental health. Regular physical activity can help reduce anxiety and depression and improve mood and cognitive functioning. Exercise causes chemical changes in the brain that may help boost feelings of calmness and well-being.
The document provides an introduction and overview of offshore oil drilling operations. It discusses the reasons for offshore drilling given increasing global oil demand. It then reviews the history of offshore drilling from early platforms constructed in the late 1800s to modern large rigs. The document outlines the main steps in offshore drilling including exploration, leasing land, installing casing, cementing, connecting blowout preventers, and drilling. It also describes how wells are evaluated to determine if oil reserves are producible. Mobile drilling platforms commonly used are also identified.
The document discusses procedures for BOP testing and kick tolerance calculations. It provides details on general BOP testing steps including using water, ensuring personnel safety, and pressure testing all equipment. It also covers kick tolerance concepts like calculating the maximum gas volume that can be circulated out of the wellbore without exceeding the weakest formation pressure. An example calculation is provided to determine a well's kick tolerance volume.
This document provides information about casing pipes used in oil and gas wells. It discusses the different types of casing including conductor casing, surface casing, intermediate casing, and production casing. Each type of casing serves a specific purpose like maintaining hole integrity, isolating pressure zones, and protecting groundwater. The document also covers casing connection types, sizing standards, recommended lengths, and potential causes of leaks.
This document discusses the key systems of a rotary drilling rig, including the power system. It explains that the power system provides power to all other rig systems, including hoisting, circulation, and rotary systems. Diesel engines are typically used to power the drawworks and rotary table. The document discusses power requirements, classifications of power systems, power supply components, and calculations for determining output power and efficiency.
Casing is essential for safely drilling oil and gas wells. It must withstand forces during drilling and through the life of the well. Different casing strings are run to isolate formations with different pressures and seal off problematic zones to allow deeper drilling. Surface casing isolates fresh water and supports blowout preventers. Intermediate casing increases pressure integrity to drill deeper and protects progress. Production casing houses completion equipment and isolates the producing zone. Liners are shorter strings hung from intermediate casing to complete zones economically. Proper casing and cementing is crucial to isolate formations and prevent communication between zones.
Exploration geophysics uses seismic, gravity, magnetic, electrical, and electromagnetic methods to search for oil, gas, minerals, and water underground. Seismic data is collected using vibrator trucks on land or seismic vessels at sea, and reflected waves are received by geophones or hydrophones. The data is processed to create 2D and 3D images of underground strata. Wells are drilled using a rig and drill string to further explore promising areas identified on seismic maps. If hydrocarbons are found, economic analysis is conducted to determine if developing the reservoir will cover costs and be profitable.
Lucas Franzen presents on stored procedures in Firebird. He discusses what stored procedures are, why they are useful, how to write them, and common pitfalls. Stored procedures allow precompiled SQL functions and queries to be stored in a database for improved performance. They can be used to encapsulate business logic, centralize rules, and enhance security.
In this presentation we consider how to resolve Firebird performance problems: what Firebird database parameters we need to monitor and how we need to tune Firebird configuration and adjust client applications.
This document contains slides from a presentation on how Firebird transactions work. The presentation covers the basics of transactions, how record versions are created in Firebird's multi-version architecture, and how the transaction inventory pages and isolation levels allow Firebird to maintain transaction consistency and isolation. Key points include that each record can have multiple versions associated with different transactions, snapshots isolate transactions by copying the transaction inventory, and read committed transactions see the global transaction state while snapshots see only up to their start time.
Firebird 3: provider-based architecture, plugins and OO approach to API Mind The Firebird
This session will be devoted to the architecture of Firebird 3:
The Interface-based API of plugins, and its configuration (which can be done separately for each database)
OSRI (Open Systems Relational Interface) implementation with plugins (more details about OSRI)
Non-SQL stored procedures and triggers with plugins
Safe passwords and network encryption
Trace plugin and more
Who would be interested in this topic?
The plugins API in Firebird 3 is designed to significantly improve the capabilities of embedding external code.
There will be areas of extension which will allow the following:
external triggers and procedures (written in almost any programming language)
custom trace plugins
security plugins to implement custom users identification (biometrics, etc)
traffic encryption using algorithms others than SHA1 and RC4
Special attention will be devoted to non-standard providers, such as bridges to external (non-Firebird) databases or ODBC connection and caching abilities.
This document provides information about installing and using the Firebird RDBMS, including:
- The two main types of Firebird servers and how to start/stop the Superserver.
- Default username and password for administration, and how to add/modify user accounts.
- Using the isql tool to connect to databases and execute SQL statements.
- Basic troubleshooting for common errors.
- Security measures like logging login attempts and restricting access after failed logins.
- Using the GBAK tool to backup and restore entire Firebird databases.
This document provides an overview of the power and hoisting systems used on rotary drilling rigs. It discusses the typical components of a rig's power system, including diesel engines that provide mechanical or electric power. It also details the components that make up the hoisting system, including the derrick, drawworks, block and tackle pulley system, and their functions in raising and lowering equipment in the well. The block and tackle provides mechanical advantage to reduce the load on the drawworks. Formulas are provided to calculate the fast line force required to lift a weight and the load distribution throughout the rig.
r k bansal - A Textbook of Fluid Mechanics and hydraulic machines. 9-laxmi.pdfNallusamy5
This document describes a new type of battery that is safer and longer-lasting than current lithium-ion batteries. It works by using sodium ions rather than lithium ions and two different liquids to prevent fires. Sodium is more abundant than lithium, making it potentially more affordable and sustainable. Initial tests show the new battery maintains over 90% capacity after 250 charge cycles.
This document provides an overview of well design and construction. It begins with an agenda and then covers topics such as different types of drill rigs used for various water depths, rig systems for hoisting, rotating, circulating, and well control, well types (exploration, appraisal, development), typical well schematics, casing strings, typical lithology for the central North Sea, casing cementation, drilling fluids, drill bits, bottom-hole assemblies, drilling problems, and well evaluation using wireline logging. The document provides essential information on the key aspects and considerations for well design and construction.
The document discusses several methods for predicting fracture gradients: Hubbert & Willis, Matthews & Kelly, and Ben Eaton. It provides examples of calculating fracture gradients for a Texas Gulf Coast well using each method and summarizes the results. Experimental determination of fracture gradients using leak-off tests is also addressed. The Ben Eaton method is considered the most accurate as it accounts for variations in pore pressure, overburden stress, and Poisson's ratio.
The document provides information on different types of oil and gas drilling rigs used on land and offshore. It describes key components and uses of land rigs, as well as differences between light, medium, and heavy duty land rigs. For offshore rigs, it discusses jackup rigs, gravity platforms, semisubmersibles, tension leg platforms, spars, drillships and their applications in different water depths. Specific rigs like the Berkut and Seastars platforms are also summarized.
Offshore petroleum production has evolved from early onshore operations using wooden derricks to modern floating production systems. Initially, platforms were fixed structures on shallow continental shelves, using steel jacket designs. As water depths increased, new designs like compliant towers and tension leg platforms were developed. Today, the most common systems are semi-submersibles, spars, and ship-shaped floating production, storage, and offloading vessels (FPSOs), which are moored but move with ocean currents and waves. Designing integrated systems that account for environmental loads on the hull, mooring lines, risers, and subsea infrastructure is challenging and expensive, but continues to push into deeper waters and harsher environments to meet global energy demand
Offshore drilling is the process of drilling through the seabed to explore and extract petroleum deposits beneath the seafloor. It involves using seismic surveys to locate potential oil deposits, drilling holes hundreds to thousands of feet below the seabed using metal casing and drill pipes, and extracting oil through the wells. Offshore drilling poses environmental risks like oil spills that can harm ocean life and pollute shorelines if not properly regulated. Unconventional drilling methods allow drilling at angles and laterally to access more oil.
The document discusses the benefits of exercise for mental health. Regular physical activity can help reduce anxiety and depression and improve mood and cognitive functioning. Exercise causes chemical changes in the brain that may help boost feelings of calmness and well-being.
The document provides an introduction and overview of offshore oil drilling operations. It discusses the reasons for offshore drilling given increasing global oil demand. It then reviews the history of offshore drilling from early platforms constructed in the late 1800s to modern large rigs. The document outlines the main steps in offshore drilling including exploration, leasing land, installing casing, cementing, connecting blowout preventers, and drilling. It also describes how wells are evaluated to determine if oil reserves are producible. Mobile drilling platforms commonly used are also identified.
The document discusses procedures for BOP testing and kick tolerance calculations. It provides details on general BOP testing steps including using water, ensuring personnel safety, and pressure testing all equipment. It also covers kick tolerance concepts like calculating the maximum gas volume that can be circulated out of the wellbore without exceeding the weakest formation pressure. An example calculation is provided to determine a well's kick tolerance volume.
This document provides information about casing pipes used in oil and gas wells. It discusses the different types of casing including conductor casing, surface casing, intermediate casing, and production casing. Each type of casing serves a specific purpose like maintaining hole integrity, isolating pressure zones, and protecting groundwater. The document also covers casing connection types, sizing standards, recommended lengths, and potential causes of leaks.
This document discusses the key systems of a rotary drilling rig, including the power system. It explains that the power system provides power to all other rig systems, including hoisting, circulation, and rotary systems. Diesel engines are typically used to power the drawworks and rotary table. The document discusses power requirements, classifications of power systems, power supply components, and calculations for determining output power and efficiency.
Casing is essential for safely drilling oil and gas wells. It must withstand forces during drilling and through the life of the well. Different casing strings are run to isolate formations with different pressures and seal off problematic zones to allow deeper drilling. Surface casing isolates fresh water and supports blowout preventers. Intermediate casing increases pressure integrity to drill deeper and protects progress. Production casing houses completion equipment and isolates the producing zone. Liners are shorter strings hung from intermediate casing to complete zones economically. Proper casing and cementing is crucial to isolate formations and prevent communication between zones.
Exploration geophysics uses seismic, gravity, magnetic, electrical, and electromagnetic methods to search for oil, gas, minerals, and water underground. Seismic data is collected using vibrator trucks on land or seismic vessels at sea, and reflected waves are received by geophones or hydrophones. The data is processed to create 2D and 3D images of underground strata. Wells are drilled using a rig and drill string to further explore promising areas identified on seismic maps. If hydrocarbons are found, economic analysis is conducted to determine if developing the reservoir will cover costs and be profitable.
Lucas Franzen presents on stored procedures in Firebird. He discusses what stored procedures are, why they are useful, how to write them, and common pitfalls. Stored procedures allow precompiled SQL functions and queries to be stored in a database for improved performance. They can be used to encapsulate business logic, centralize rules, and enhance security.
In this presentation we consider how to resolve Firebird performance problems: what Firebird database parameters we need to monitor and how we need to tune Firebird configuration and adjust client applications.
This document contains slides from a presentation on how Firebird transactions work. The presentation covers the basics of transactions, how record versions are created in Firebird's multi-version architecture, and how the transaction inventory pages and isolation levels allow Firebird to maintain transaction consistency and isolation. Key points include that each record can have multiple versions associated with different transactions, snapshots isolate transactions by copying the transaction inventory, and read committed transactions see the global transaction state while snapshots see only up to their start time.
Firebird 3: provider-based architecture, plugins and OO approach to API Mind The Firebird
This session will be devoted to the architecture of Firebird 3:
The Interface-based API of plugins, and its configuration (which can be done separately for each database)
OSRI (Open Systems Relational Interface) implementation with plugins (more details about OSRI)
Non-SQL stored procedures and triggers with plugins
Safe passwords and network encryption
Trace plugin and more
Who would be interested in this topic?
The plugins API in Firebird 3 is designed to significantly improve the capabilities of embedding external code.
There will be areas of extension which will allow the following:
external triggers and procedures (written in almost any programming language)
custom trace plugins
security plugins to implement custom users identification (biometrics, etc)
traffic encryption using algorithms others than SHA1 and RC4
Special attention will be devoted to non-standard providers, such as bridges to external (non-Firebird) databases or ODBC connection and caching abilities.
This document provides information about installing and using the Firebird RDBMS, including:
- The two main types of Firebird servers and how to start/stop the Superserver.
- Default username and password for administration, and how to add/modify user accounts.
- Using the isql tool to connect to databases and execute SQL statements.
- Basic troubleshooting for common errors.
- Security measures like logging login attempts and restricting access after failed logins.
- Using the GBAK tool to backup and restore entire Firebird databases.
Firebird 3 includes many new SQL features such as the full MERGE statement syntax from SQL 2008, window functions, regular expression support in SUBSTRING, a native BOOLEAN datatype, and improvements to cursor stability for data modification queries. Procedural SQL is also enhanced with the ability to create SQL functions, subroutines, external functions/procedures/triggers, and exception handling improvements. Additional new features include DDL changes, enhanced security options, and monitoring capabilities.
The document discusses changes to the architecture and implementation of the Super Server in Firebird 3. Key points include:
- The Super Server now uses a single process with multiple threads to handle connections instead of cooperative multitasking with a single active thread.
- Fine-grained locking is used for the shared page cache, with individual latches for each page buffer, improving parallelism but increasing synchronization costs.
- Benchmarks show significant performance improvements for multi-threaded workloads in Firebird 3 compared to earlier versions thanks to better utilization of multiple CPU cores by the Super Server.
This document provides information and examples for working with system tables in Firebird, including:
- Finding tables without a primary key by querying system tables
- Examples of querying system tables to find unique indexes, field types, and more
- Techniques for updating and deleting from tables without a primary key such as using cursors and DB keys
The document contains code examples for common tasks like listing tables without primary keys, finding unique indexes, and working with data in tables that lack a primary or unique key. It also provides insights into the structure and contents of important system tables.
There are more and more companies have big Firebird databases, from 100Gb till 1Tb. Maintenance and optimization tasks for such databases are different from small, and database administrators need take into account several important things about big Firebird databases.
College for Women Department of Information Science WilheminaRossi174
College for Women
Department of Information Science
Kuwait University
College of Computing Sciences and Engineering
Department of Information Science
COMP1231
Web Programming
Assignment #1
Due Date: Friday, February 26th, 11:59 pm
Weight: 7% of Final Grade
COMP1231 - ASSIGNMENT 1 2
Table of Contents
COMP1231 Assignment 1 ............................................................................................................................ 3
Function 1: Student Information ................................................................................................................... 4
Function 2: Calculate Change ....................................................................................................................... 5
Function 3: Miles to Kilometers ................................................................................................................... 5
Function 4: Find Min and Max ..................................................................................................................... 6
Function 5: Count Occurrences..................................................................................................................... 6
Function 6: Convert Number Grade to Letter Grade .................................................................................... 7
Function 7: Reverse the Order of the Array .................................................................................................. 7
Function 8: School Days Remaining ............................................................................................................ 7
Function 9: Count Vowels ............................................................................................................................ 8
Function 10: Alphabetical Order................................................................................................................... 8
Submission Procedure and Rules ................................................................................................................ 10
Submission Procedure ............................................................................................................................. 10
COMP1231 - ASSIGNMENT 1 3
COMP1231 Assignment 1
Assignment Type: Individual Assignment
1. Description
In this assignment, you are to develop a JavaScript file that contains the implementation of 10 functions. Each
function is represented as one step, and marks will be awarded on the completion of each step (each function).
Each function is independent and solves a unique problem, as such, treat and implement each function in isolation
of the others, that’s is, you should only focus on one problem at a time.
PLEASE NOTE: Input validation is NOT required for any function parameter – You may assume that all
input p ...
College for women department of information science AMMY30
This document provides instructions for Assignment 1 in the COMP1231 Web Programming course. It outlines 10 functions that students must implement in a JavaScript file. Each function solves a unique problem, like calculating change, converting between miles and kilometers, or reversing an array. Students will create a functions.js file with the 10 functions and a main.html file that includes and calls the functions.js file. Students must submit both files to the specified folder before the due date. Plagiarism detection software will be used to check for copied code.
This document provides an overview of SQL tuning concepts and tools in Oracle Database. It discusses the differences between database tuning and SQL tuning. It also covers diagnostic tools like SQL Trace, ASH, EXPLAIN PLAN, AUTOTRACE, and SQL Developer. Active monitoring tools like AWR, SQL Monitor and reactive tools like SQL Diagnostic Tool and SQLD360 are also mentioned. Additional topics include full table scans, adaptive features, statistics, hints, pending statistics, restoring statistics history, and invisible indexes.
Pygrunn 2012 down the rabbit - profiling in pythonRemco Wendt
The document discusses various tools for profiling Python code such as cProfile, profile, hotshot, line profiler, and trace to identify inefficient code and potential bottlenecks. It also covers memory profiling tools like Heapy and Meliae. Effective profiling requires understanding different profiling techniques, tools, and how to analyze the output to optimize performance and memory usage.
Oracle SQL Tuning 101 provides an overview of SQL tuning concepts and tools in Oracle Database. It discusses database tuning versus SQL tuning, proactive versus reactive tuning approaches, tools for SQL tracing and monitoring like SQL Trace, ASH, Autotrace, and SQL Monitor. The document also covers topics like full table scans, adaptive optimization features, pending statistics, and restoring or exporting statistics.
Down the rabbit hole, profiling in DjangoRemco Wendt
The document discusses various tools for profiling Python code such as cProfile, profile, hotshot, line profiler, and trace to identify inefficient code and bottlenecks. It covers using these tools to profile CPU and I/O bound problems as well as memory profiling issues. The document also demonstrates how to optimize code through caching, removing unnecessary function calls, and memoization.
This document discusses OLAP functions in Informix 12.1. It provides an overview of OLAP and what it is used for in business intelligence. It then describes the OVER clause and how it defines the domain of OLAP function calculation using optional PARTITION BY, ORDER BY, and WINDOW FRAME clauses. Several examples of ranking, aggregation, and analytic OLAP functions like RANK, SUM, and LAG are shown. The document concludes by noting how OLAP functions can be accelerated by the Informix Warehouse Accelerator.
A talk about unit testing for iOS apps. Part rambling introduction to test driven development, part examples of certain types of tests for iOS, and a brief mention of writing your tests using Kiwi.
This document discusses data manipulation in Oracle databases. It describes how to insert new rows into tables using the INSERT statement, update existing rows using the UPDATE statement, and delete rows from tables using the DELETE statement. It also covers controlling transactions with commands like COMMIT, ROLLBACK, and SAVEPOINT to ensure data integrity when making multiple changes to a database.
The document discusses using R for analytics on Netezza's TwinFin appliance. TwinFin is a massively parallel processing database management system designed specifically for performance. It utilizes field programmable gate arrays and an "on-stream analytics" approach. The document outlines how R interfaces with TwinFin through functions like nzapply and nztapply that allow running R functions on TwinFin's distributed data in parallel. It provides examples of building decision trees and linear models on TwinFin tables using these functions.
IBM Informix dynamic server 11 10 Cheetah Sql FeaturesKeshav Murthy
The document summarizes new features in Informix Dynamic Server (IDS) version 11.10. Key features include:
1) Full support for subqueries in the FROM clause of SQL statements and enhancements to distributed queries.
2) New data types like Node and Binary, and a basic text search index for full text search capabilities.
3) Performance improvements to the SQL optimizer including an index self-join access method and directives for ANSI joins.
4) Enhancements to stored procedures, functions, isolation levels and utilities like SYSDBOPEN and SYSDBCLOSE.
SQL Performance Tuning and New Features in Oracle 19cRachelBarker26
What's new in Oracle 19c (and CMiC R12) and the reporting software Jaspersoft Studios. If you are not interested in Jasper go ahead and skip to page 26. Explains how to read an execution plan and what to look for in an optimized execution plan.
Angular 16 is the biggest release since the initial rollout of Angular, and it changes everything: Bye bye zones, change-detection, life-cycle, children-selectors, Rx and what not.
Recorded webinar based on these slides given by Yaron Biton, Misterbit Coding-Academy’s CTO, can be found at: https://www.youtube.com/watch?v=92K1fgPbku8
Coding-Academy offers advanced web-techs training and software development services: Top-rated Full-stack courses for Angular, React, Vue, Node, Modern architectures, etc. | Available top-notch on-demand-coders trough Misterbit technological solutions | Coding-Academy Bootcamp: Hundreds of employed full-stack developers every year | Anything web, end to end projects | Tech companies and startups | Consulting to management and dev teams | Workshops for managers and leaders.
The document discusses views in Oracle databases and how they have evolved beyond simple stored SQL queries. Views can now serve as an isolation layer between applications and tables, accept DML operations directly or through triggers, and include complex functionality through features like parameterized conditions, dynamic SQL, and INSTEAD OF triggers. The document outlines techniques for optimizing DML operations on views, such as using dynamic SQL to only update changed columns, and leveraging compound triggers for shared program logic. It also warns of performance issues that can arise from logical primary keys on views.
We are all told that we must use bind variables rather than literals in our code, and then are left to deal with the problems this causes. This issue probably still causes more performance tuning problems than any other. This presentation discusses how Oracle has handled the optimisation of statements using bind variables from version 8i to the new features in Oracle 11g and highlights some issues that still exist in version 11g.
•Introduce new XML features and enhancements in IBM DB2 11 for z/OS
•Introduce XML features delivered to services stream of DB2 10 for z/OS
•Demonstrate how to use XML in actual business scenarios.
The document summarizes how SQL Plan Directives in Oracle 12c can help address issues caused by cardinality misestimation in the optimizer. It provides an example where the optimizer underestimates the number of rows returned by a query on a table due to not having statistics on correlated columns. In 12c, a SQL Plan Directive is automatically generated after the first execution to capture this misestimation. On subsequent queries, the directive can be used to provide more accurate cardinality estimates through automatic reoptimization or dynamic sampling.
Art and Science Come Together When Mastering Relevance Ranking - Tom Burgmans...Lucidworks
Art and Science come together when mastering Relevance Ranking. The document discusses various ingredients for improving relevance ranking such as understanding relevance, preparing content, controlling scoring algorithms, using domain experts, and measuring expectations vs reality. It provides examples of tuning elements in scoring algorithms like term frequency, inverse document frequency, and function queries to customize relevance ranking.
This document summarizes the changes to the .NET Firebird data provider over the past year. It discusses 11 new versions that were released with various new features and bug fixes. A total of 49 tickets were resolved, while 87 remained open. The code is now hosted on GitHub for easier community contributions. Support was added for Entity Framework 6 and a new connection pooling system was implemented. Various other improvements and bug fixes were also mentioned.
This document discusses Firebird database replication solutions, focusing on Jonathan Neve's company Microtec Communications' replication product called CopyCat. CopyCat includes CopyCat Developer for multi-database replication across various database types, CopyCat LiveMirror for high frequency one-way replication for backups, and the upcoming CopyCat DataMerge for fully-featured bidirectional replication. The document provides information on features, case studies demonstrating usage, and upcoming additions planned for 2015.
The document discusses using the TPC-C benchmark to study Firebird database performance under load. It describes running tests with different Firebird configurations, hardware, and database sizes to determine optimal settings. Analysis found page size, buffer size, and hash slots impact performance, but settings optimized for HDDs did not always help SSD performance which responded differently. The tests provided valuable insights into Firebird performance tuning but also showed more analysis is needed to optimize configurations for different hardware.
The document provides an overview of Red Database 2.5, an open source database product developed by Red Soft Corporation. It describes the company and development process, as well as key features of Red Database 2.5 including security features, functional features, integration with OpenLDAP, and use in large government and medical systems. Plans for Red Database 3.0 include merging with Firebird 3.0 and adding load balancing, parallel backup/restore, and migration tools.
The document discusses performance counters in Firebird that provide insight into bottlenecks. It describes existing counters for pages, records, and transactions and improvements being made. New counters being added in Firebird 3.x will provide more granular statistics on record-level activity like locks, waits, conflicts and index usage. The presentation raises potential areas for additional counters related to temporary space, time statistics, and integration with monitoring systems.
This document provides information about numbers and data types in Firebird databases. It discusses integer, floating point, numeric, and decimal data types, including their storage sizes and value ranges. It also covers data type considerations when migrating between Firebird dialects and potential issues with calculations and changing numeric scales. The document is intended to help understand internal numeric storage and proper data type usage in Firebird.
This document discusses the history and future of threading in Firebird databases. It describes how early versions of Firebird were not multi-threaded, but modern versions use threading to improve performance on multi-processor systems. Key aspects of Firebird threading include using limited worker threads to balance load across CPU cores without excessive contention, and fine-grained locking of individual data structures for maximum parallelism.
"Orphans, Corruption, Careful Write, and Logging", by Ann W. Harrison and Jim Starkey. A frequent question on the Firebird Support list is "Gfix thinks my database is corrupt. How can I fix it?" The best answer may be to fix gfix itself so it reports benign errors differently from actual corruption. The most common errors reported by gfix can simply be ignored. From the beginning of InterBase to now, gfix is the least interesting of the utilities, so it's had little attention. However it requires a great deal of knowledge of database internals, so it's not easily replaced by a separately developed tool. So, from 1984 until now, gfix has reported major corruption and benign errors as if they were all the same.
What's a benign error? Usually, it's an artifact from the sudden death of a Firebird server that leaves obsolete record versions or even whole empty pages orphaned - neither released nor in use. Orphans represent lost space, but have no other damaging effect on the database. Orphaned record versions and pages occur because Firebird carefully orders its page writes to avoid the need for before or after logs. Database management systems that rely on logging for durability and recovery write each piece of data twice - once to a log and later to the database. Careful write requires discipline in programming. In 1984, careful write had performance advantages that more than made up for the need for careful programming.
This talk and paper explore the cause of "orphan" pages and record versions, Firebird's careful write I/O architecture, and the trade-offs between careful write and logging today.
Nbackup and Backup: Internals, Usage strategy and Pitfalls, by Dmitry Kuzmenk...Mind The Firebird
This document discusses NBackup and Backup strategies for Firebird databases. NBackup allows creating multiple incremental backups over time, taking up more disk space but enabling restoration to precise historical states. Backup is slower than NBackup but is still useful for tasks like database renewal. When database corruption occurs, restoration may fail due to logical data issues, so regular NBackup is recommended to minimize data loss risks.
This document summarizes the results of tests conducted on Firebird databases of varying sizes (small, medium, quite large, very large) to analyze how administrative tasks are impacted. The key findings are:
1) Gstat scans took 3 times longer when the database was active compared to inactive, significantly impacting user performance on RAID 10 systems. SSDs mitigated this performance hit.
2) Nbackup backups were faster without direct I/O enabled, with the time cost ranging from 1.2x to 22.5x depending on database size and activity.
3) Xcopy backups were significantly faster than Nbackup, with a time cost reduction of 1.2x to 5x depending on
The document discusses installing and configuring Firebird on Linux. It describes installing from project packages such as RPM and tar.gz files, from distribution packages, or by building from source code. It also covers configuring services for classic or superserver modes using xinetd or systemd, checking the max open file settings, and optimizing the file system choices and settings.
Superchaging big production systems on Firebird: transactions, garbage, maint...Mind The Firebird
This document discusses tools from IBSurgeon for monitoring and optimizing transaction processing, garbage collection, and maintenance in large Firebird database systems. IBTM, IBAnalyst and FBScanner are used to identify issues like unnecessary transactions, growing data versions, and inefficient queries. Addressing problems with transaction management, indices tuning, and fixing application logic can help supercharge performance. IBSurgeon is offering their tools and services to conference attendees at a 25% discount.
Different application domains including sensor networks, social networks, science, financial services, condition monitoring systems demand the storage of a vast amount of data in the petabytes area. Prominent candidates are Google, Facebook, Yahoo!, Amazon just to name a few.
This data volume can't be tackled with convential relational database technologies anymore, either from a technical or licensing point of view or both. It demands a scale-out environment, which allows reliable, scalable and distributed processing. This trend in Big Data management is more and more approached with NoSQL solutions like Apache HBase on top of Apache Hadoop.
This session discusses big data management and their scalability challenges in general with a short introduction into Apache Hadoop/HBase and a case study on the co-existence of Apache Hadoop/HBase with Firebird in a sensor data aquisition system.
This document summarizes a presentation about continuous database monitoring using the Trace API in Firebird 2.5. It discusses the motivation for database monitoring, different monitoring approaches in Firebird including triggers, monitoring tables, and the new Audit and Trace Services API. It provides an overview of the Trace Services API and how to configure and manage trace sessions. It also demonstrates how to use the fbtracemgr tool and introduces the FB TraceManager 2 software.
The document summarizes the Firebird Conference 2011. It discusses the Firebird organization structure and governance model operated by consensus. It outlines the core development team and external contributions. It also summarizes Firebird Foundation's objectives, membership, budget, and management committee. Finally, it addresses Firebird's increasing workload and need for new resources and ways for attendees to support the project.
Firebird database recovery and protection for enterprises and ISVMind The Firebird
This document discusses database reliability and recovery for Firebird databases. It begins by addressing whether Firebird databases are reliable, noting that all databases can experience corruption from hardware or software failures over time. The document then discusses what happens when a Firebird database crashes, explaining that the database consists of system metadata pages and user data pages. It provides an overview of standard recovery methods using gfix and gbak commands. Additional approaches for recovery are presented, including the FBDataGuard and FirstAID tools from IBSurgeon. Offers are made to developers for subscribing to FBDataGuard instances to protect databases.
This document summarizes the migration of a 75GB Firebird database from version 1.5 to 2.5 for a pharmaceutical distributor in Russia. Key steps included preparing metadata, testing data conversion, checking and updating SQL queries in applications, and optimizing query plans and performance. Over 55,000 SQL queries were analyzed, with around 750 requiring changes. The migration was completed in less than 4 months. Tools like FBScanner were used to log and analyze queries between versions. The end result was improved performance, backup/restore times, and better hardware utilization in Firebird 2.5.
The document discusses using Firebird SQL in web applications. It provides statistics on web portal and game usage, common tasks like parallel database access and load balancing, and recommendations on optimizing queries, using read-only transactions, and combining Firebird SQL with NoSQL for speed while maintaining relational features. Firebird SQL can be used effectively in web applications by leveraging its power and optimizing for tasks like high volume read-only queries.
Dandelion Hashtable: beyond billion requests per second on a commodity serverAntonios Katsarakis
This slide deck presents DLHT, a concurrent in-memory hashtable. Despite efforts to optimize hashtables, that go as far as sacrificing core functionality, state-of-the-art designs still incur multiple memory accesses per request and block request processing in three cases. First, most hashtables block while waiting for data to be retrieved from memory. Second, open-addressing designs, which represent the current state-of-the-art, either cannot free index slots on deletes or must block all requests to do so. Third, index resizes block every request until all objects are copied to the new index. Defying folklore wisdom, DLHT forgoes open-addressing and adopts a fully-featured and memory-aware closed-addressing design based on bounded cache-line-chaining. This design offers lock-free index operations and deletes that free slots instantly, (2) completes most requests with a single memory access, (3) utilizes software prefetching to hide memory latencies, and (4) employs a novel non-blocking and parallel resizing. In a commodity server and a memory-resident workload, DLHT surpasses 1.6B requests per second and provides 3.5x (12x) the throughput of the state-of-the-art closed-addressing (open-addressing) resizable hashtable on Gets (Deletes).
How information systems are built or acquired puts information, which is what they should be about, in a secondary place. Our language adapted accordingly, and we no longer talk about information systems but applications. Applications evolved in a way to break data into diverse fragments, tightly coupled with applications and expensive to integrate. The result is technical debt, which is re-paid by taking even bigger "loans", resulting in an ever-increasing technical debt. Software engineering and procurement practices work in sync with market forces to maintain this trend. This talk demonstrates how natural this situation is. The question is: can something be done to reverse the trend?
"What does it really mean for your system to be available, or how to define w...Fwdays
We will talk about system monitoring from a few different angles. We will start by covering the basics, then discuss SLOs, how to define them, and why understanding the business well is crucial for success in this exercise.
"Scaling RAG Applications to serve millions of users", Kevin GoedeckeFwdays
How we managed to grow and scale a RAG application from zero to thousands of users in 7 months. Lessons from technical challenges around managing high load for LLMs, RAGs and Vector databases.
Northern Engraving | Modern Metal Trim, Nameplates and Appliance PanelsNorthern Engraving
What began over 115 years ago as a supplier of precision gauges to the automotive industry has evolved into being an industry leader in the manufacture of product branding, automotive cockpit trim and decorative appliance trim. Value-added services include in-house Design, Engineering, Program Management, Test Lab and Tool Shops.
QR Secure: A Hybrid Approach Using Machine Learning and Security Validation F...AlexanderRichford
QR Secure: A Hybrid Approach Using Machine Learning and Security Validation Functions to Prevent Interaction with Malicious QR Codes.
Aim of the Study: The goal of this research was to develop a robust hybrid approach for identifying malicious and insecure URLs derived from QR codes, ensuring safe interactions.
This is achieved through:
Machine Learning Model: Predicts the likelihood of a URL being malicious.
Security Validation Functions: Ensures the derived URL has a valid certificate and proper URL format.
This innovative blend of technology aims to enhance cybersecurity measures and protect users from potential threats hidden within QR codes 🖥 🔒
This study was my first introduction to using ML which has shown me the immense potential of ML in creating more secure digital environments!
Getting the Most Out of ScyllaDB Monitoring: ShareChat's TipsScyllaDB
ScyllaDB monitoring provides a lot of useful information. But sometimes it’s not easy to find the root of the problem if something is wrong or even estimate the remaining capacity by the load on the cluster. This talk shares our team's practical tips on: 1) How to find the root of the problem by metrics if ScyllaDB is slow 2) How to interpret the load and plan capacity for the future 3) Compaction strategies and how to choose the right one 4) Important metrics which aren’t available in the default monitoring setup.
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...Jason Yip
The typical problem in product engineering is not bad strategy, so much as “no strategy”. This leads to confusion, lack of motivation, and incoherent action. The next time you look for a strategy and find an empty space, instead of waiting for it to be filled, I will show you how to fill it in yourself. If you’re wrong, it forces a correction. If you’re right, it helps create focus. I’ll share how I’ve approached this in the past, both what works and lessons for what didn’t work so well.
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor IvaniukFwdays
At this talk we will discuss DDoS protection tools and best practices, discuss network architectures and what AWS has to offer. Also, we will look into one of the largest DDoS attacks on Ukrainian infrastructure that happened in February 2022. We'll see, what techniques helped to keep the web resources available for Ukrainians and how AWS improved DDoS protection for all customers based on Ukraine experience
QA or the Highway - Component Testing: Bridging the gap between frontend appl...zjhamm304
These are the slides for the presentation, "Component Testing: Bridging the gap between frontend applications" that was presented at QA or the Highway 2024 in Columbus, OH by Zachary Hamm.
Introducing BoxLang : A new JVM language for productivity and modularity!Ortus Solutions, Corp
Just like life, our code must adapt to the ever changing world we live in. From one day coding for the web, to the next for our tablets or APIs or for running serverless applications. Multi-runtime development is the future of coding, the future is to be dynamic. Let us introduce you to BoxLang.
Dynamic. Modular. Productive.
BoxLang redefines development with its dynamic nature, empowering developers to craft expressive and functional code effortlessly. Its modular architecture prioritizes flexibility, allowing for seamless integration into existing ecosystems.
Interoperability at its Core
With 100% interoperability with Java, BoxLang seamlessly bridges the gap between traditional and modern development paradigms, unlocking new possibilities for innovation and collaboration.
Multi-Runtime
From the tiny 2m operating system binary to running on our pure Java web server, CommandBox, Jakarta EE, AWS Lambda, Microsoft Functions, Web Assembly, Android and more. BoxLang has been designed to enhance and adapt according to it's runnable runtime.
The Fusion of Modernity and Tradition
Experience the fusion of modern features inspired by CFML, Node, Ruby, Kotlin, Java, and Clojure, combined with the familiarity of Java bytecode compilation, making BoxLang a language of choice for forward-thinking developers.
Empowering Transition with Transpiler Support
Transitioning from CFML to BoxLang is seamless with our JIT transpiler, facilitating smooth migration and preserving existing code investments.
Unlocking Creativity with IDE Tools
Unleash your creativity with powerful IDE tools tailored for BoxLang, providing an intuitive development experience and streamlining your workflow. Join us as we embark on a journey to redefine JVM development. Welcome to the era of BoxLang.
Northern Engraving | Nameplate Manufacturing Process - 2024Northern Engraving
Manufacturing custom quality metal nameplates and badges involves several standard operations. Processes include sheet prep, lithography, screening, coating, punch press and inspection. All decoration is completed in the flat sheet with adhesive and tooling operations following. The possibilities for creating unique durable nameplates are endless. How will you create your brand identity? We can help!
Northern Engraving | Nameplate Manufacturing Process - 2024
Firebird 3 Windows Functions
1. Firebird 3 Windowing Functions
Firebird 3 Windowing Functions
Author: Philippe Makowski IBPhoenix
Email: pmakowski@ibphoenix
Licence: Public Documentation License
Date: 2011-11-22
Philippe Makowski - IBPhoenix - 2011-11-22
2. Firebird 3 Windowing Functions
What are Windowing Functions?
• Similar to classical aggregates but does more!
• Provides access to set of rows from the current row
• Introduced SQL:2003 and more detail in SQL:2008
• Supported by PostgreSQL, Oracle, SQL Server, Sybase and DB2
• Used in OLAP mainly but also useful in OLTP
• Analysis and reporting by rankings, cumulative aggregates
Philippe Makowski - IBPhoenix - 2011-11-22
3. Firebird 3 Windowing Functions
Windowed Table Functions
• Windowed table function
• operates on a window of a table
• returns a value for every row in that window
• the value is calculated by taking into consideration values from the set of
rows in that window
• 8 new windowed table functions
• In addition, old aggregate functions can also be used as windowed table
functions
• Allows calculation of moving and cumulative aggregate values.
Philippe Makowski - IBPhoenix - 2011-11-22
4. Firebird 3 Windowing Functions
A Window
• Represents set of rows that is used to compute additionnal attributes
• Based on three main concepts
• partition
• specified by PARTITION BY clause in OVER()
• Allows to subdivide the table, much like GROUP BY clause
• Without a PARTITION BY clause, the whole table is in a single partition
• order
• defines an order with a partition
• may contain multiple order items
• Each item includes a value-expression
• NULLS FIRST/LAST defines ordering semantics for NULL
• this clause is independant of the query's ORDER BY clause
• frame (Firebird don't implement frame yet)
Philippe Makowski - IBPhoenix - 2011-11-22
5. Firebird 3 Windowing Functions
Window function syntax in Firebird
<window function> ::=
<window function type> OVER <window specification>
<window function type> ::=
<rank function type> <left paren> <right paren>
| ROW_NUMBER <left paren> <right paren>
| <aggregate function>
| <lead or lag function>
| <first or last value function>
| <nth value function>
<rank function type> ::=
RANK
| DENSE_RANK
Philippe Makowski - IBPhoenix - 2011-11-22
6. Firebird 3 Windowing Functions
Window function syntax in Firebird
<lead or lag function> ::=
<lead or lag> <left paren> <lead or lag extent>
[ <comma> <offset> [ <comma> <default expression> ] ] <right paren>
<lead or lag> ::=
LEAD | LAG
<lead or lag extent> ::=
<value expression>
<offset> ::=
<exact numeric literal>
<default expression> ::=
<value expression>
Philippe Makowski - IBPhoenix - 2011-11-22
7. Firebird 3 Windowing Functions
Window function syntax in Firebird
<first or last value function> ::=
<first or last value> <left paren> <value expression> <right paren>
<first or last value> ::=
FIRST_VALUE | LAST_VALUE
<nth value function> ::=
NTH_VALUE <left paren> <value expression> <comma> <nth row>
<right paren>
<nth row> ::=
<simple value specification>
| <dynamic parameter specification>
(must be an integer >= 1)
Philippe Makowski - IBPhoenix - 2011-11-22
8. Firebird 3 Windowing Functions
Window specification syntax in Firebird
<window specification> ::=
<left paren> <window specification details> <right paren>
<window specification details> ::=
[ <window partition clause> ]
[ <window order clause> ]
<window partition clause> ::=
PARTITION BY <window partition column reference or expression list>
<window partition column reference or expression list> ::=
<window partition column reference or expression>
[ { <comma> <window partition column reference or expression> }... ]
<window partition column reference or expression> ::=
<column reference or expression> [ <collate clause> ]
<window order clause> ::=
ORDER BY <sort specification list>
Philippe Makowski - IBPhoenix - 2011-11-22
9. Firebird 3 Windowing Functions
About order
The window order clause is to calculate its values, and has nothing to do with the main
order.
select emp_no, salary,
sum(salary) over (order by salary) cum_salary,
sum(salary) over (order by salary desc) cum_salary_desc
from employee order by emp_no;
EMP_NO SALARY CUM_SALARY CUM_SALARY_DESC
======= ===================== ===================== =====================
2 105900.00 1990493.02 113637875.00
4 97500.00 1680929.02 113939039.00
28 22935.00 22935.00 115522468.02
121 99000000.00 115522468.02 99000000.00
145 32000.00 113210.00 115441258.02
Philippe Makowski - IBPhoenix - 2011-11-22
10. Firebird 3 Windowing Functions
About order
If the main query doesn't have a order by but a window have, the query will be ordered
accordingly to the last window order.
select emp_no, salary,
sum(salary) over (order by salary) cum_salary,
sum(salary) over (order by salary desc) cum_salary_desc
from employee;
EMP_NO SALARY CUM_SALARY CUM_SALARY_DESC
======= ===================== ===================== =====================
121 99000000.00 115522468.02 99000000.00
118 7480000.00 16522468.02 106480000.00
110 6000000.00 9042468.02 112480000.00
134 390500.00 3042468.02 112870500.00
Philippe Makowski - IBPhoenix - 2011-11-22
11. Firebird 3 Windowing Functions
About order
select emp_no, salary,
sum(salary) over (order by salary desc) cum_salary_desc,
sum(salary) over (order by salary) cum_salary
from employee;
EMP_NO SALARY CUM_SALARY_DESC CUM_SALARY
======= ===================== ===================== =====================
28 22935.00 115522468.02 22935.00
109 27000.00 115499533.02 49935.00
65 31275.00 115472533.02 81210.00
145 32000.00 115441258.02 113210.00
Philippe Makowski - IBPhoenix - 2011-11-22
12. Firebird 3 Windowing Functions
Set Functions as Window Functions
The OVER clause turns a set function into a window function
• Aggregated value is computed per current row window
select emp_no, dept_no, salary,
avg(salary) over (partition by dept_no) as dept_avg
from employee;
EMP_NO DEPT_NO SALARY DEPT_AVG
======= ======= ===================== =====================
12 000 53793.00 133321.50
105 000 212850.00 133321.50
127 100 44000.00 77631.25
85 100 111262.50 77631.25
34 110 61637.81 65221.40
61 110 68805.00 65221.40
110 115 6000000.00 6740000.00
118 115 7480000.00 6740000.00
Philippe Makowski - IBPhoenix - 2011-11-22
13. Firebird 3 Windowing Functions
Set Functions as Window Functions
Who are the highest paid relatively compared with the department average?
select emp_no, dept_no, salary,
avg(salary) over (partition by dept_no) as dept_avg,
salary - avg(salary) over (partition by dept_no) as diff
from employee
order by diff desc;
EMP_NO DEPT_NO SALARY DEPT_AVG DIFF
======= ======= ===================== ===================== =====================
118 115 7480000.00 6740000.00 740000.00
105 000 212850.00 133321.50 79528.50
107 670 111262.50 71268.75 39993.75
2 600 105900.00 66450.00 39450.00
85 100 111262.50 77631.25 33631.25
4 621 97500.00 69184.87 28315.13
46 900 116100.00 92791.31 23308.69
9 622 75060.00 53409.16 21650.84
Philippe Makowski - IBPhoenix - 2011-11-22
14. Firebird 3 Windowing Functions
Built-in Windowing Functions
• RANK () OVER ...
• DENSE_RANK () OVER ...
• LAG () OVER ...
• LEAD () OVER ...
• ROW_NUMBER () OVER ...
• FIRST_VALUE () OVER ...
• LAST_VALUES () OVER ...
• NTH_VALUE () OVER ...
Philippe Makowski - IBPhoenix - 2011-11-22
15. Firebird 3 Windowing Functions
Built-in Windowing Functions : row_number
Returns number of the current row
select emp_no, dept_no, salary,
row_number() over (order by salary desc nulls last) as row_num
from employee;
EMP_NO DEPT_NO SALARY ROW_NUM
======= ======= ===================== =====================
121 125 99000000.00 1
118 115 7480000.00 2
110 115 6000000.00 3
134 123 390500.00 4
105 000 212850.00 5
46 900 116100.00 6
85 100 111262.50 7
107 670 111262.50 8
141 121 110000.00 9
row_number() always incremented values independent of frame
Philippe Makowski - IBPhoenix - 2011-11-22
16. Firebird 3 Windowing Functions
Built-in Windowing Functions : rank
Returns rank of the current row with gap
select emp_no, dept_no, salary,
rank() over (order by salary desc nulls last) as rank
from employee;
EMP_NO DEPT_NO SALARY RANK
======= ======= ===================== =====================
121 125 99000000.00 1
118 115 7480000.00 2
110 115 6000000.00 3
134 123 390500.00 4
105 000 212850.00 5
46 900 116100.00 6
85 100 111262.50 7
107 670 111262.50 7
141 121 110000.00 9
rank() OVER(empty) returns 1 for all rows, since all rows are peers to each other
Philippe Makowski - IBPhoenix - 2011-11-22
17. Firebird 3 Windowing Functions
Built-in Windowing Functions : dense_rank
Returns rank of the current row without gap
select emp_no, dept_no, salary,
dense_rank() over (order by salary desc nulls last)
from employee;
EMP_NO DEPT_NO SALARY DENSE_RANK
======= ======= ===================== =====================
121 125 99000000.00 1
118 115 7480000.00 2
110 115 6000000.00 3
134 123 390500.00 4
105 000 212850.00 5
46 900 116100.00 6
85 100 111262.50 7
107 670 111262.50 7
141 121 110000.00 8
dense_rank() OVER(empty) returns 1 for all rows, since all rows are peers to each
other
Philippe Makowski - IBPhoenix - 2011-11-22
19. Firebird 3 Windowing Functions
Missing Built-in Windowing Functions : percent_rank
Returns relative rank of the current row: (rank - 1) / (total rows - 1)
can be emulated with rank() and count()
select emp_no, dept_no, salary,
cast((rank() over (order by salary asc))-1 as double precision)
/ ( count(*) over () -1) as percent_rank
from employee
EMP_NO DEPT_NO SALARY PERCENT_RANK
======= ======= ===================== =======================
28 120 22935.00 0.000000000000000
109 600 27000.00 0.02439024390243903
...
144 672 35000.00 0.1219512195121951
114 623 35000.00 0.1219512195121951
138 621 36000.00 0.1707317073170732
...
118 115 7480000.00 0.9756097560975610
121 125 99000000.00 1.000000000000000
Philippe Makowski - IBPhoenix - 2011-11-22
20. Firebird 3 Windowing Functions
Missing Built-in Windowing Functions : cum_dist
Returns relative rank; (# of preced. or peers) / (total row)
can be emulated with count()
select emp_no, dept_no, salary,
cast((count(*) over (order by salary asc)) as double precision)
/ ( COUNT(*) over () ) as cum_dist
from employee
EMP_NO DEPT_NO SALARY CUM_DIST
======= ======= ===================== =======================
28 120 22935.00 0.02380952380952381
109 600 27000.00 0.04761904761904762
...
144 672 35000.00 0.1666666666666667
114 623 35000.00 0.1666666666666667
138 621 36000.00 0.1904761904761905
...
118 115 7480000.00 0.9761904761904762
121 125 99000000.00 1.000000000000000
Philippe Makowski - IBPhoenix - 2011-11-22
21. Firebird 3 Windowing Functions
Built-in Windowing Functions :
first_value,nth_value,last_value
Warning
Note that first_value, last_value, and nth_value consider only the rows within
the "window frame", which by default contains the rows from the start of the
partition through the last peer of the current row.
And Firebird today don't allow you to change the frame definition.
This is likely to give unhelpful results for nth_value and particularly last_value.
Philippe Makowski - IBPhoenix - 2011-11-22
22. Firebird 3 Windowing Functions
Built-in Windowing Functions : first_value
Returns value of the first row in a window
select emp_no, dept_no, salary,
first_value(salary) over (order by salary desc nulls last) overall_max,
first_value(salary) over (partition by dept_no order by salary desc nulls last) dept_max,
first_value(salary) over (order by salary asc nulls last) overall_min,
first_value(salary) over (partition by dept_no order by salary asc nulls last) dept_min
from employee;
EMP_NO DEPT_NO SALARY OVERALL_MAX DEPT_MAX OVERALL_MIN DEPT_MIN
======= ======= ============ ============ ============ ============ ============
12 000 53793.00 99000000.00 212850.00 22935.00 53793.00
105 000 212850.00 99000000.00 212850.00 22935.00 53793.00
127 100 44000.00 99000000.00 111262.50 22935.00 44000.00
85 100 111262.50 99000000.00 111262.50 22935.00 44000.00
34 110 61637.81 99000000.00 68805.00 22935.00 61637.81
61 110 68805.00 99000000.00 68805.00 22935.00 61637.81
110 115 6000000.00 99000000.00 7480000.00 22935.00 6000000.00
118 115 7480000.00 99000000.00 7480000.00 22935.00 6000000.00
28 120 22935.00 99000000.00 39224.06 22935.00 22935.00
37 120 39224.06 99000000.00 39224.06 22935.00 22935.00
121 125 99000000.00 99000000.00 99000000.00 22935.00 99000000.00
Philippe Makowski - IBPhoenix - 2011-11-22
23. Firebird 3 Windowing Functions
Built-in Windowing Functions : nth_value
Returns value of the nth row in a window
select emp_no, dept_no, salary,
nth_value(salary,2) over (partition by dept_no order by salary desc)
from employee;
EMP_NO DEPT_NO SALARY NTH_VALUE
======= ======= ===================== =====================
105 000 212850.00 <null>
12 000 53793.00 53793.00
85 100 111262.50 <null>
127 100 44000.00 44000.00
61 110 68805.00 <null>
34 110 61637.81 61637.81
118 115 7480000.00 <null>
110 115 6000000.00 6000000.00
37 120 39224.06 <null>
36 120 33620.63 33620.63
28 120 22935.00 33620.63
Philippe Makowski - IBPhoenix - 2011-11-22
24. Firebird 3 Windowing Functions
Built-in Windowing Functions : last_value
Returns value of the last row in a window
select emp_no, dept_no, salary,
last_value(salary) over (partition by dept_no order by salary asc)
from employee;
EMP_NO DEPT_NO SALARY LAST_VALUE
======= ======= ===================== =====================
12 000 53793.00 53793.00
105 000 212850.00 212850.00
127 100 44000.00 44000.00
85 100 111262.50 111262.50
34 110 61637.81 61637.81
61 110 68805.00 68805.00
Philippe Makowski - IBPhoenix - 2011-11-22
25. Firebird 3 Windowing Functions
Built-in Windowing Functions : lag and lead
Both LAG and LEAD functions have the same usage.
LAG (value [,offset[, default]]) OVER ([query_partition_clause] order_by_clause)
LEAD (value [,offset[, default]]) OVER ([query_partition_clause] order_by_clause)
• value - Can be a column or a built-in function, except for other analytic functions.
• offset - The number of rows preceeding/following the current row, from which the
data is to be retrieved. The default value is 1.
• default - The value returned if the offset is outside the scope of the window. The
default value is NULL.
Philippe Makowski - IBPhoenix - 2011-11-22
26. Firebird 3 Windowing Functions
Built-in Windowing Functions : lag
Returns value of row above
select emp_no, dept_no, salary,
lag(salary) over (order by salary desc nulls last)
from employee;
EMP_NO DEPT_NO SALARY LAG
======= ======= ===================== =====================
121 125 99000000.00 <null>
118 115 7480000.00 99000000.00
110 115 6000000.00 7480000.00
134 123 390500.00 6000000.00
105 000 212850.00 390500.00
46 900 116100.00 212850.00
85 100 111262.50 116100.00
107 670 111262.50 111262.50
141 121 110000.00 111262.50
lag() only acts on a partition.
Philippe Makowski - IBPhoenix - 2011-11-22
27. Firebird 3 Windowing Functions
Built-in Windowing Functions : lead
Returns value of row below
select emp_no, dept_no, salary,
lead(salary) over (order by salary desc nulls last)
from employee;
EMP_NO DEPT_NO SALARY LEAD
======= ======= ===================== =====================
121 125 99000000.00 7480000.00
118 115 7480000.00 6000000.00
110 115 6000000.00 390500.00
134 123 390500.00 212850.00
105 000 212850.00 116100.00
46 900 116100.00 111262.50
85 100 111262.50 111262.50
107 670 111262.50 110000.00
141 121 110000.00 105900.00
28 120 22935.00 <null>
lead() only acts on a partition.
Philippe Makowski - IBPhoenix - 2011-11-22
28. Firebird 3 Windowing Functions
Cumulative aggregates
The current row window is now restricted to all rows equal to or preceding the current
row within the current partition
• Find the total sales per quarter, and cumulative sales in quarter order
select order_year, order_quarter, sum(total_value) as q_sales,
sum(sum(total_value)) over (partition by order_year order by order_quarter)
as cum_sales_year
from v_sales_q
group by order_year, order_quarter;
ORDER_YEAR ORDER_QUARTER Q_SALES CUM_SALES_YEAR
========== ============= ===================== =====================
1992 3 2985.00 2985.00
1992 4 72000.00 74985.00
1993 1 648.00 648.00
1993 2 20000.00 20648.00
1993 3 1009643.04 1030291.04
1993 4 699724.16 1730015.20
1994 1 440590.83 440590.83
Philippe Makowski - IBPhoenix - 2011-11-22
30. Firebird 3 Windowing Functions
Performance
Without window function
SELECT ORDER_DATE, CUST_NO,QTY_ORDERED,
(SELECT SUM(QTY_ORDERED)
FROM SALES AS Si
WHERE Si.ORDER_DATE = S.ORDER_DATE
AND Si.CUST_NO <= S.CUST_NO)
AS QTY_CUMUL_DAY
FROM SALES AS S
ORDER BY S.ORDER_DATE, S.CUST_NO
PLAN (SI INDEX (RDB$FOREIGN25))
PLAN SORT (S NATURAL)
SALES 591 indexed reads
SALES 33 non indexed reads
Philippe Makowski - IBPhoenix - 2011-11-22
31. Firebird 3 Windowing Functions
Performance
With window function
SELECT ORDER_DATE, PO_NUMBER,QTY_ORDERED,
SUM(QTY_ORDERED)
OVER (PARTITION BY ORDER_DATE
ORDER BY PO_NUMBER)
AS QTY_CUMUL_DAY
FROM SALES
ORDER BY ORDER_DATE, PO_NUMBER
PLAN SORT (SALES NATURAL)
SALES 33 non indexed reads
Philippe Makowski - IBPhoenix - 2011-11-22
32. Firebird 3 Windowing Functions
Performance
And you can extend it nearly without cost
SELECT ORDER_DATE, PO_NUMBER,QTY_ORDERED,
SUM(QTY_ORDERED)
OVER (PARTITION BY ORDER_DATE
ORDER BY PO_NUMBER)
AS QTY_CUMUL_DAY,
SUM(QTY_ORDERED)
OVER (PARTITION BY EXTRACT(YEAR FROM ORDER_DATE),EXTRACT(MONTH FROM ORDER_DATE)
ORDER BY ORDER_DATE, PO_NUMBER)
AS QTY_CUMUL_MONTH,
SUM(QTY_ORDERED)
OVER (PARTITION BY EXTRACT(YEAR FROM ORDER_DATE)
ORDER BY ORDER_DATE, PO_NUMBER)
AS QTY_CUMUL_YEAR
FROM SALES
ORDER BY ORDER_DATE, PO_NUMBER
Philippe Makowski - IBPhoenix - 2011-11-22