oracleÓÅ»¯Æ÷
What circumstances we use ALL_ROWS and what circumstances we use FIRST_ROWS optimizer mode? This article is written in oracle9i.
First_rows attempts to optimize the query to get the very first row back to the client as fast as possible. This is good for an interactive client server environment where the client runs a query and shows the user the first 10 rows or so and waits for them to page down to get more.
All_rows attempts to optimize the query to get the very last row as fast as possible. This makes sense in a stored procedure for example where the client does not regain control until the stored procedure completes. You don't care if you have to wait to get the first row if the last row gets back to you twice as fast. In a client server/interactive application you may well care about that.
In TOAD or SQL Navigator, When we select the data, it display immediately. But it does not mean that, it is faster. If we scroll down, it might be fetching the data in the background mode. First_rows is best place for OLTP environment. Also in some reporting environment, if user wants to see initial data first and later see the rest of the data, then first_rows is good option. When we run the query in the stored procedure, first_rows would not be a good choice, all_rows is good option here, because, there is no use to fetch the first few records immediatley inside the stored procedure.
Let us demonstrate the FIRST_ROWS/ALL_ROWS optimizer hint.
Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.8.0 - Production
SQL> create table testtable as select * from user_objects;
Table created.
SQL> create index idx on testtable(object_type);
Index created.
SQL> EXECUTE DBMS_STATS.GATHER_TABLE_STATS(OWNNAME => 'SCREPORT',TABNAME => 'TESTTABLE',ESTIMATE_PER
CENT => 10, METHOD_OPT => 'FOR ALL COLUMNS SIZE 1', CASCADE => TRUE);
PL/SQL procedure successfully co
Ïà¹ØÎĵµ£º
Ëùν³öÓÚjob¶øÊ¤ÓÚjob£¬ËµµÄ¾ÍÊÇOracle 10gºóµÄÐÂÌØÐÔSchedulerÀ²¡£ÔÚ10g»·¾³ÖУ¬ORACLE½¨ÒéʹÓÃSchedulerÌæ»»ÆÕͨµÄjob£¬À´¹ÜÀíÈÎÎñµÄÖ´ÐС£Æäʵ£¬½«SchedulerÃèÊö³É¹ÜÀíjobµÄ¹¤¾ßÒѾ̫¹ýÆ¬ÃæÁË£¬10G°æ±¾ÖÐÐÂÔöµÄScheduler¾ø²»½ö½öÊÇ´´½¨ÈÎÎñÕâô¼òµ¥¡£¡£¡£¡£
Ìáʾ£ºORACLEÖйÜÀíSchedulerÊÇͨ¹ýDBMS_SCHEDULER°ü£¬ ......
Õâ¸öÖ÷ÌâÓë²¢·¢¿ØÖƵĹØÏµ·Ç³£½ôÃÜ£¬ÒòΪÕâÕýÊÇOracle²¢·¢¿ØÖÆ»úÖÆµÄ»ù´¡£¬Oracle²ÉÓÃÁËÒ»ÖÖ¶à°æ±¾¡¢¶ÁÒ»Ö£¨read-consistent£©µÄ²¢·¢Ä£ÐÍ¡£ÔÙ´Î˵Ã÷£¬ÎÒÃǽ«ÔÚµÚ7Õ¸üÏêϸµØ½éÉÜÓйصļ¼Êõ¡£²»¹ý£¬ÊµÖÊÉϽ²£¬OracleÀûÓÃÕâÖÖ»úÖÆÌṩÁËÒÔÏÂÌØÐÔ£º
q ¶ÁÒ»Ö²éѯ£º¶ÔÓÚÒ»¸öʱ¼äµã£¨point in time£©£¬²éѯ»á²úÉúÒ»ÖµĽ ......
--1²é¿´±í¿Õ¼äÒѾʹÓõİٷֱÈ
select a.tablespace_name,a.bytes/1024/1024
"Sum MB",(a.bytes-b.bytes)/1024/1024 "used MB",b.bytes/1024/1024
"free MB",round(((a.bytes-b.bytes)/a.bytes)*100,2) "percent_used"
from
(select tablespace_nam ......
»ù´¡±í(Driving Table)ÊÇÖ¸±»×îÏÈ·ÃÎʵıí(ͨ³£ÒÔÈ«±íɨÃèµÄ·½Ê½±»·ÃÎÊ). ¸ù¾ÝÓÅ»¯Æ÷µÄ²»Í¬, SQLÓï¾äÖлù´¡±íµÄÑ¡ÔñÊDz»Ò»ÑùµÄ.
Èç¹ûÄãʹÓõÄÊÇCBO (COST BASED OPTIMIZER),ÓÅ»¯Æ÷»á¼ì²éSQLÓï¾äÖеÄÿ¸ö±íµÄÎïÀí´óС,Ë÷ÒýµÄ״̬,È»ºóÑ¡Óû¨·Ñ×îµÍµÄÖ´Ðз¾¶.
Èç¹ûÄãÓÃRBO (RULE BASED OPTIMIZER) , ²¢ÇÒËùÓеÄÁ¬½ÓÌõ¼þ¶ ......
ºÎΪÉÁ»Ø»Ö¸´Çø
Oracle 10g ÓÐÒ»Ïîй¦ÄܳÆÎª:×Ô¶¯µÄ»ùÓÚ´ÅÅ̵ı¸·ÝÓë»Ö¸´( Automatic Disk-Based Backup and Recovery )¡£ÊµÏָù¦ÄܵĻù´¡Îª±¾ÎÄÒª½²ÊöµÄÉÁ»Ø»Ö¸´Çø( Flash Recovery Area )¡£ÉÁ»Ø»Ö¸´ÇøÊÇ Oracle 10g ÖеÄÐÂÊÂÎï¡£¼òµ¥µÄ˵£¬ÉÁ»Ø»Ö¸´ÇøÊÇÒ»¿éÓÃÒÔ´æ´¢»Ö¸´Ïà¹ØµÄÎļþµÄ´æ´¢¿Õ¼ä¡£ÔÊÐíÓû§¼¯Öд洢ËùÓлָ ......