
Many customers migrating to Amazon Redshift have complex data warehouse processing pipelines built with stored procedures on their legacy data warehouse platform. Complex transformations and important aggregations are defined with stored procedures and reused in many parts of their processing. For example, you can create stored procedures to perform functions without giving a user access to the underlying tables. You can also use stored procedures for delegated access control. By combining multiple SQL steps into a stored procedure, you can reduce round trips between your applications and the database. Stored procedures are commonly used to encapsulate logic for data transformation, data validation, and business-specific operations. You can use the PL/pgSQL procedural language, including looping and conditional expressions, to control logical flow. A stored procedure doesn’t have to return a value. Unlike a user-defined function (UDF), a stored procedure can incorporate data definition language (DDL) and data manipulation language (DML) in addition to SELECT queries. The procedure is stored in the database and is available to users who have sufficient privileges to run it. What is a stored procedure?Ī stored procedure is a user-created object to perform a set of SQL queries and logical operations.
#REDSHIFT RANK FUNCTION HOW TO#
We also explain how to use stored procedures with AWS Schema Conversion Tool. In this post, we discuss how and where to use stored procedures to improve operational efficiency and security. With that primary goal in mind, AWS chose to implement PL/pqSQL stored procedure to maximize compatibility with existing procedures and simplify migrations. Customers have made strong requests that they want stored procedures in Amazon Redshift, to make it easier to migrate their existing workloads from legacy, on-premises data warehouses.

Amazon always works backwards from the customer’s needs.
