Search notes:

Oracle SQL Plan operation INDEX FULL SCAN feeding into FIRST ROW

create table tq84_tab (
   num    integer      not null,
   txt    varchar2(3)  not null,
   val    number(4,1)  not null
);


create index tq84_tab_ix on tq84_tab(num, txt);


insert into tq84_tab
select
   mod(level, 100),
   dbms_random.string('U', 3),
   dbms_random.value(1, 999)
from
   dual connect by level <= 10000;


begin
   dbms_stats.gather_table_stats(user, 'tq84_tab');
end;
/


explain plan for
select
   max(num)
from
   tq84_tab
where
   txt = 'QUG'
;

select * from table(dbms_xplan.display(format=>'basic'));
--
-- ---------------------------------------------------
-- | Id  | Operation                   | Name        |
-- ---------------------------------------------------
-- |   0 | SELECT STATEMENT            |             |
-- |   1 |  SORT AGGREGATE             |             |
-- |   2 |   FIRST ROW                 |             |
-- |   3 |    INDEX FULL SCAN (MIN/MAX)| TQ84_TAB_IX |
-- ---------------------------------------------------

drop table tq84_tab;

See also

SQL plan operations

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758206519, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/databases/Oracle/SQL/statement/execution/plan/operations/index_/full-scan/min-max/first-row(80): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78