Predicate Pushing

Predicate Pushing

Oracle supports the pushing of predicates into a given view. Suppose you have a set of layered views:

--View OneCREATE VIEW vw_layer_oneAS SELECT * FROM emp;-- View TwoCREATE VIEW vw_layer_two_dept_100AS SELECT * FROM vw_layer_oneWHERE deptno=100;

Then assume you issued this query:

SELECT * FROM vw_layer_two_dept_100WHERE empid=100;

The predicate in this statement is WHERE empid=100;. You may have one of tens or even hundreds of predicates (if you have hundreds, you don’t want to be supporting your SQL code!). In many cases, Oracle will push those predicates down into the views being called. Thus, Oracle will transform the vw_layer_one view into a SQL statement that looks like this:

CREATE VIEW vw_layer_oneAS SELECT * FROM empWHERE deptno=100AND empid=100;

Note that both the predicate from vw_layer_two (where deptno=100) and the predicate from the SQL statement being executed (where empid=100) are pushed down into the final view that is executed. This can have significant performance benefits, because now the bottom view can possibly use an index if one exists on deptno and/or empid.

Predicate pushing has a number of restrictions that are beyond the scope of this tip, but you can find them in the Oracle documentation. Also, any predicate pushing may result in a hard parse of the underlying SQL that is executed. Hence, it is important to make sure you use bind variables instead of literals in SQL code calling views. Your SQL should look something like this, for best performance:

SELECT * FROM vw_layer_two_dept_100WHERE empid=:b100;
Share the Post:
XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of

kubernetes logging

Kubernetes Logging: What You Need to Know

Kubernetes from Google is one of the most popular open-source and free container management solutions made to make managing and deploying applications easier. It has a solid architecture that makes

ransomware cyber attack

Why Is Ransomware Such a Major Threat?

One of the most significant cyber threats faced by modern organizations is a ransomware attack. Ransomware attacks have grown in both sophistication and frequency over the past few years, forcing

data dictionary

Tools You Need to Make a Data Dictionary

Data dictionaries are crucial for organizations of all sizes that deal with large amounts of data. they are centralized repositories of all the data in organizations, including metadata such as