sqlµ÷ÓÅÖ® ѰÕÒÎÒÃÇ×î¸ÐÐËȤµÄÓï¾ä
Tuning an Application / Reducing Load
If your whole application is performing suboptimally, or if you are attempting to
reduce the overall CPU or I/O load on the database server, then identifying
resource-intensive SQL involves the following steps:
1. Determine which period in the day you would like to examine; typically this is the
application's peak processing time.
2. Gather operating system and Oracle statistics at the beginning and end of that
period. The minimum of Oracle statistics gathered should be file I/O
(V$FILESTAT), system statistics (V$SYSSTAT), and SQL statistics (V$SQLAREA,
V$SQL or V$SQLSTATS, V$SQLTEXT, V$SQL_PLAN, and V$SQL_PLAN_
STATISTICS).
3. Using the data collected in step two, identify the SQL statements using the most
resources. A good way to identify candidate SQL statements is to query
V$SQLSTATS. V$SQLSTATS contains resource usage information for all SQL
statements in the shared pool. The data in V$SQLSTATS should be ordered by
resource usage. The most common resources are:
¡ö Buffer gets (V$SQLSTATS.BUFFER_GETS, for high CPU using statements)
¡ö Disk reads (V$SQLSTATS.DISK_READS, for high I/O statements)
¡ö Sorts (V$SQLSTATS.SORTS, for many sorts)
One method to identify which SQL statements are creating the highest load is to
compare the resources used by a SQL statement to the total amount of that resource
used in the period. For BUFFER_GETS, divide each SQL statement's BUFFER_GETS by
the total number of buffer gets during the period. The total number of buffer gets in
the system is available in the V$SYSSTAT table, for the statistic session logical reads.
Similarly, it is possible to apportion the percentage of disk reads a statement performs
out of the total disk reads performed by the system by dividing V$SQL_STATS.DISK_
READS by the value for the V$SYSSTAT statistic physical reads. The SQL sections of
the Automatic Workload Repository report include this data, so you do not need to
perform the percentag
Ïà¹ØÎĵµ£º
ʹÓÃSQLÓï¾ä´´½¨Êý¾Ý¿â
±¾ÎÄת×Ô£ºhttp://www.cppblog.com/twzheng/archive/2008/07/07/55508.html
ÓÃCREATE DATABASE´´½¨Êý¾Ý¿âµÄÓï·¨¸ñʽ£º
CREATE DATABASE database_name /*Ö¸¶¨Êý¾Ý¿âÃû*/
[ON× ......
1 ---ÉϸöÔÂÔ³õµÚÒ»Ìì
2 select CONVERT(varchar(12) , DATEADD(mm,DATEDIFF(mm,0,dateadd(mm,-1,getdate())),0), 112 )
3
4 ---ÉϸöÔÂÔÂÄ©×îºóÒ»Ìì
5 select CONVERT(varchar(12),dateadd(ms,-3,DATEADD(mm,DATEDIFF(m,0,getdate()),0)), 112 )
6
7 ......
¸ù¾ÝÉúÈÕµÄxxÔÂxxÈÕ²éÕÒÔÚ$checkDate¼ÆË㣬$beforeÈÕºóÉúÈյĿͻ§£º
$checkDateΪYYYY-MM-DD
WHERE substring(ADDDATE( '$checkDate', $before ),6,10)=substring(DATE_FORMAT(birthday,'%Y-%m-%d'),6,10)
$dates ÌìÄÚÉúÈյĿͻ§Î´¿¼Âǵ½Æ½Äê¡¢ÈòÄ꣺£º
$sql.=" (dayofyear( birthday )-dayofyear( ......
´ø´æÔÚÁ¿´ÊNOT EXISTSµÄSQLÓï¾äÎÊÌâ
ѧÉú±ístudent (snoѧºÅ snameÐÕÃû sdeptËùÔÚϵ)
¿Î³Ì±ícourse (cno¿Î³ÌºÅ cname¿Î³ÌÃû cpnoÑ¡Ð޿κŠccreditѧ·Ö)
ѧÉúÑ¡¿Î±ísc (sn0ѧºÅ cno¿Î³ÌºÅ grade³É¼¨)
¶ÔÒÔÉÏ±í½øÐвéѰѡÐÞÁËÈ«²¿¿Î³ÌµÄѧÉúÐÕÃû
ÓÉÓÚ²»£¬Ã»ÓÐÈ«³ÆÁ¿´Ê£¬¿É½«ÌâÄ¿µÄÒâ˼ת»»ÎªµÈ¼ÛµÄ´æÔÚÁ¿´ÊÐÎʽ£º²éÑ ......
ÓÃ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 ......