Home » SQL & PL/SQL » SQL & PL/SQL » Problems in Oracle Hints
Problems in Oracle Hints [message #611460] Wed, 02 April 2014 13:42 Go to next message
aaditya321
Messages: 225
Registered: January 2014
Location: Delhi
Senior Member
Here /*+ FIRST_ROWS(1) */ and /*+ ALL_ROWS */ are giving same result, but result should be come here different for different hints.

SQL> select * from emp3;

EMPLOYEE_ID LAST_NAME                SALARY JOB_ID     DEPARTMENT_ID
----------- -------------------- ---------- ---------- -------------
          1 Ram                         100 X                     11
          2 Shyam                       200 Y                     12
          2 Shyam                       300 Y                     12
          2 Neelesh                     400 Y                     12

SQL> SELECT /*+ FIRST_ROWS(1) */ employee_id, last_name, salary, job_id
  2    FROM emp3
  3    WHERE department_id = 12;

EMPLOYEE_ID LAST_NAME                SALARY JOB_ID
----------- -------------------- ---------- ----------
          2 Shyam                       200 Y
          2 Shyam                       300 Y
          2 Neelesh                     400 Y


SQL> SELECT /*+ ALL_ROWS */ employee_id, last_name, salary, job_id
  2        FROM emp3
  3        WHERE department_id = 12;

EMPLOYEE_ID LAST_NAME                SALARY JOB_ID
----------- -------------------- ---------- ----------
          2 Shyam                       200 Y
          2 Shyam                       300 Y
          2 Neelesh                     400 Y


Re: Problems in Oracle Hints [message #611461 is a reply to message #611460] Wed, 02 April 2014 13:45 Go to previous messageGo to next message
John Watson
Messages: 8930
Registered: January 2010
Location: Global Village
Senior Member
No, the result set must always be identical. The difference (if any) is in the way the result set is generated, for which you need to look at the execution plans.
Re: Problems in Oracle Hints [message #611465 is a reply to message #611461] Wed, 02 April 2014 14:33 Go to previous messageGo to next message
Michel Cadot
Messages: 68643
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

... and if you find a different result set (assuming you do not limit it using rownum or the like) then it is a bug and your only solution is to raise a SR to Oracle which will ask you for the complete version number and a test case to reproduce it.
If you want some help from here, you have to post the same thing.

[Updated on: Wed, 02 April 2014 14:34]

Report message to a moderator

Re: Problems in Oracle Hints [message #611475 is a reply to message #611460] Wed, 02 April 2014 20:00 Go to previous messageGo to next message
Solomon Yakobson
Messages: 3273
Registered: January 2010
Location: Connecticut, USA
Senior Member
FIRST_ROWS(1) doesn't mean return just one row same as ALL_ROWS doesn't mean return all rows. FIRST_ROWS(1) tells optimizer to construct plan in such way that first 1 row would be fetched as fast as possible even though fetching all rows would take more time than it could. And ALL_ROWS tells optimizer to construct plan in such way that all rows would be fetched as fast as possible even though fetching first row would take more time than it could.

SY.
Re: Problems in Oracle Hints [message #611484 is a reply to message #611475] Thu, 03 April 2014 00:55 Go to previous message
aaditya321
Messages: 225
Registered: January 2014
Location: Delhi
Senior Member
Thank you for so much supporting Guys.
Previous Topic: passing values from Refcursor into Object type
Next Topic: Unable to get running total conditionally
Goto Forum:
  


Current Time: Tue Apr 23 15:31:20 CDT 2024