Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

PL/SQL Best Practice On BULK COLLECT

On BULK COLLECT
By Steven Feuerstein Oracle ACE
Best practices for knowing your LIMIT and kicking %NOTFOUND
I have started using BULK COLLECT whenever I need to fetch large volumes of data. This has caused me some trouble with my DBA, however. He is complaining that although my programs might be running much faster, they are also consuming way too much memory. He refuses to approve them for a production rollout. What's a programmer to do?
The most important thing to remember when you learn about and start to take advantage of features such as BULK COLLECT is that there is no free lunch. There is almost always a trade-off to be made somewhere. The tradeoff with BULK COLLECT, like so many other performance-enhancing features, is "run faster but consume more memory."
Specifically, memory for collections is stored in the program global area (PGA), not the system global area (SGA). SGA memory is shared by all sessions connected to Oracle Database, but PGA memory is allocated for each session. Thus, if a program requires 5MB of memory to populate a collection and there are 100 simultaneous connections, that program causes the consumption of 500MB of PGA memory, in addition to the memory allocated to the SGA.
Fortunately, PL/SQL makes it easy for developers to control the amount of memory used in a BULK COLLECT operation by using the LIMIT clause.
Suppose I need to retrieve all the rows from the employees table and then perform some compensation analysis on each row. I can use BULK COLLECT as follows:
PROCEDURE process_all_rows
IS
   TYPE employees_aat
   IS TABLE OF employees%ROWTYPE
      INDEX BY PLS_INTEGER;
   l_employees employees_aat;
BEGIN
   SELECT *
   BULK COLLECT INTO l_employees
      from employees;
   FOR indx IN 1 .. l_employees.COUNT
 &nbs


Ïà¹ØÎĵµ£º

SQLÊý¾Ý¿âÁ¬½ÓÓï¾ä

Ò»°ãµÄÔ¶³Ì·ÃÎʵÄд³ÉÕâÑù£º
Data Source=IP;Initial Catalog=Êý¾Ý¿âÃû;UserID=Óû§Ãû;Password=ÃÜÂë
±¾µØ·ÃÎʵÄд³ÉÕâÑù£º
Data Source=(local);Initial Catalog=Êý¾Ý¿âÃû;UserID=Óû§Ãû;Password=ÃÜÂë
Èç¹ûÊDZ¾µØµÄ£¬Í¨¹ýwindows×é¼þÑéÖ¤µÄ£¨Ò²¾ÍÊÇûÓÐÓû§Ãû£¬ÃÜÂëµÄ£©Ð´³ÉÕâÑù£º
Data Source=(local);Initial Cata ......

¸ü¸ÄSql*plusµÄÌáʾ·û

  Õý³£µÇ½sql*plusµÄ²½ÖèÈçÏ£º
sbdatabase*orcl-/home/oracle>sqlplus /nolog
SQL*Plus: Release 10.2.0.3.0 - Production on Sun May 9 19:50:24 2010
Copyright (c) 1982, 2006, Oracle. All Rights Reserved.
SQL> conn hmsimis/test@orcl
Connected.
SQL>
¿ÉÒÔ¿´µ½Ç°ÃæµÄÌáʾ·ûÊÇSQL£¬ÏÖÔÚÏëÐ ......

sql having ºÍwhereµÄÇø±ð

  ×î½üÔÚѧϰoracleµÄʱºòÓöµ½Ò»¸öÎÊÌ⣬ÀÏÊÇŪ²»Çå³þwhere ºÍhavingµÄÇø±ð£¬ÔÚÍøÉϲéÒ»²é£¬¸Ð¾õ»¹¿ÉÒÔ£¬°ÑÒÔÏÂÎÒ²éµÄ×ÊÁÏÍƼö¸ø´ó¼Ò¡£
ÔÚselect Óï¾äÖпÉÒÔʹÓÃgroup by ×Ӿ佫Ðл®·Ö³É½ÏСµÄ×飬Ȼºó£¬Ê¹ÓþÛ×麯Êý·µ»Øÿһ¸ö×éµÄ»ã×ÜÐÅÏ¢£¬ÁíÍ⣬¿ÉÒÔʹÓÃhaving×Ó¾äÏÞÖÆ·µ»ØµÄ½á¹û¼¯¡£group&n ......

ÓÃTSQL°ÑAccessµÄ±íµ¼Èëµ½Ô¶³ÌSql Server

ÓÃTSQL°ÑAccessµÄ±íµ¼Èëµ½Ô¶³ÌSql Server£º
°Ñaccess µÄ.mdbÀït_itemList ±íµÄÊý¾Ý²åÈëµ½Ô¶³ÌSqlServerµÄt_itemL1111111±íÀï¡£
SELECT  top 10 *  INTO  t_itemL1111111 IN [ODBC] 
[ODBC;Driver=SQL Server; UID=jyb;PWD=jyb;Server=10.1.18.49;DataBase=ËùÓкϲ¢;]
    &nb ......

linq to sql ÖеÄÀàÐÍÇ¿´«½â¾ö·½°¸

 List<Class1> li = dc.Table_1.Where(item => item.id > 1).Cast<Class1>().ToList();
Table_1 Ϊ×Ô¶¯Éú³ÉÀà, class1Ϊ×Ô¶¨ÒåÀà,ÊôÐÔÃû³Æ¶¼ÊÇÒ»ÑùµÄ,ÒªÄÜʵÏÖÉÏÃæµÄÓï¾ä,±ØÐëÓм¸¸öÌõ¼þ
Table_1 ÐèÒª¼Ì³Ðclass1,¿ÉÒÔͨ¹ýpartialÀàÀ´ÊµÏÖ
Table_1  ÊôÐÔ¼Óoverride
class1ÀïÃæµÄÊôÐÔÒªÊÇvir ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ