Someone would know how to explain why the use of 'is null' in a SQL query diminishes the Bank's performance, making excessive use of the processor?
IS NULL Performance
-
thiago.sousa
- Rank: Programador Júnior

- Posts: 28
- Joined: Fri, 09 Dec 2005 9:17 am
- Location: Itajai-SC
_______________________________________
Thiago Antonio
SCJP - Sun Certified Java Programer
SCJA - Sun Certified Java Associate
Thiago Antonio
SCJP - Sun Certified Java Programer
SCJA - Sun Certified Java Associate
- dr_gori
- Moderador

- Posts: 5027
- Joined: Mon, 03 May 2004 3:08 pm
- Location: Portland, OR USA
- Contact:
Thomas F. G
Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered
Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered
I may be mistaken, but that I know, the null does not enter the indexes. Type, Oracle only places in the Null values ??index. So when you seek the null, he has to do a full scan ...
Someone knows if my answer confers?
This is a good theme for discussion here! ...
Someone knows if my answer confers?
This is a good theme for discussion here! ...
-
thiago.sousa
- Rank: Programador Júnior

- Posts: 28
- Joined: Fri, 09 Dec 2005 9:17 am
- Location: Itajai-SC
_______________________________________
Thiago Antonio
SCJP - Sun Certified Java Programer
SCJA - Sun Certified Java Associate
Thiago Antonio
SCJP - Sun Certified Java Programer
SCJA - Sun Certified Java Associate
I really had a lot of interest in knowing this ...
and how can we solve this?
and how can we solve this?
-
gilbertoca
- Rank: DBA Sênior

- Posts: 372
- Joined: Tue, 24 Jan 2006 3:33 pm
- Location: Palmas - TO
- Contact:
Maybe this link http://www.dba-oracle.com/oracle_tips_null_idx.htm can help. Another thing, I usually create my columns with a default value.
Gilberto
Gilberto
-
thiago.sousa
- Rank: Programador Júnior

- Posts: 28
- Joined: Fri, 09 Dec 2005 9:17 am
- Location: Itajai-SC
_______________________________________
Thiago Antonio
SCJP - Sun Certified Java Programer
SCJA - Sun Certified Java Associate
Thiago Antonio
SCJP - Sun Certified Java Programer
SCJA - Sun Certified Java Associate
Yes ... I also create my columns always with default.
What I want to say is the following
Ex:
understood?
How do I optimize this?
What I want to say is the following
Ex:
select * from teste
where
(campo1 = :parametro1 or :parametro1 is null)How do I optimize this?
-
gilbertoca
- Rank: DBA Sênior

- Posts: 372
- Joined: Tue, 24 Jan 2006 3:33 pm
- Location: Palmas - TO
- Contact:
select * from teste
where
(campo1 = :parametro1 or :parametro1 is null)
nomedacouluna = :parametro
As you saw, no!understood?
- dr_gori
- Moderador

- Posts: 5027
- Joined: Mon, 03 May 2004 3:08 pm
- Location: Portland, OR USA
- Contact:
Thomas F. G
Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered
Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered
This command is very common, when it has optional parameters.Gilbertoca wrote: This command is not wrong?
Example:
All records of the EMP:
SQL> select * from emp;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- ---------- --------- ---------- --------- ---------- ---------- ----------
7369 SMITH CLERK 7902 17-DEC-80 800 20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7566 JONES MANAGER 7839 02-APR-81 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7788 SCOTT ANALYST 7566 19-APR-87 3000 20
7839 KING PRESIDENT 17-NOV-81 5000 10
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
7876 ADAMS CLERK 7788 23-MAY-87 1100 20
7900 JAMES CLERK 7698 03-DEC-81 950 30
7902 FORD ANALYST 7566 03-DEC-81 3000 20
7934 MILLER CLERK 7782 23-JAN-82 1300 10
14 rows selected.
SQL> var vjob varchar2(20)
SQL> select * from emp where job = :vjob;
no rows selectedAs VJOB is null, you have to bring everything from the table.
SQL> select * from emp where (job = :vjob or :vjob is null);
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- ---------- --------- ---------- --------- ---------- ---------- ----------
7369 SMITH CLERK 7902 17-DEC-80 800 20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7566 JONES MANAGER 7839 02-APR-81 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7788 SCOTT ANALYST 7566 19-APR-87 3000 20
7839 KING PRESIDENT 17-NOV-81 5000 10
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
7876 ADAMS CLERK 7788 23-MAY-87 1100 20
7900 JAMES CLERK 7698 03-DEC-81 950 30
7902 FORD ANALYST 7566 03-DEC-81 3000 20
7934 MILLER CLERK 7782 23-JAN-82 1300 10
14 rows selected.SQL> begin
2 :vjob :='SALESMAN';
3 end;
4 /
PL/SQL procedure successfully completed.
SQL> select * from emp where (job = :vjob or :vjob is null);
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- ---------- --------- ---------- --------- ---------- ---------- ----------
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
4 rows selected.
SQL>
I think to solve our friend's problem, we have to find out if his column has index if the bank statistics were recently collected, the other table relationships, etc.
I think a trace would help you know what Join is slow.
-
thiago.sousa
- Rank: Programador Júnior

- Posts: 28
- Joined: Fri, 09 Dec 2005 9:17 am
- Location: Itajai-SC
_______________________________________
Thiago Antonio
SCJP - Sun Certified Java Programer
SCJA - Sun Certified Java Associate
Thiago Antonio
SCJP - Sun Certified Java Programer
SCJA - Sun Certified Java Associate
In fact, the problem is always with the is nulll .... if you do a test will check the difference that happens in the bank.
I'd like to know why? And how I would solve
I'd like to know why? And how I would solve
-
gilbertoca
- Rank: DBA Sênior

- Posts: 372
- Joined: Tue, 24 Jan 2006 3:33 pm
- Location: Palmas - TO
- Contact:
You can use enough resource from the bank and cause a problem to make tunning. Well, it's the opinion of a NewbieThis command is very common, yes, when you have optional parameters.
For me in this command,
SQL> select * from emp where (job = :vjob or :vjob is null);
SQL> select * from emp where (job = null or null is null);
falso verdadeiro
select * from emp where (job = null or 1=1);
select * from emp where (1=1);
While
SQL> select * from emp where (job = :vjob or :vjob is null);
SQL> select * from emp where (job = 'SALESMAN' or SALESMAN is null);
verdadeiro falso
vjob := 'SALESMAN'.Boy This business is really complicated! It's making me confused! I'll read and practice a little more.
-
- Information
-
Who is online
Users browsing this forum: No registered users and 1 guest
