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
Ïà¹ØÎĵµ£º
¸ù¾ÝÉúÈÕµÄ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( ......
1.²éѯÁ¬½Óµ½Ä³Êý¾Ý¿âµÄÁ¬½ÓÊý
select count(*) as Á¬½ÓÊý from master..sysprocesses where db_name(dbid)='Êý¾Ý¿âÃû' ......
ÅÅÃûº¯ÊýÊÇSQL Server2005мӵŦÄÜ¡£ÔÚSQL Server2005ÖÐÓÐÈçÏÂËĸöÅÅÃûº¯Êý£º
¡¡¡¡1.row_number
¡¡¡¡2.rank
¡¡¡¡3.dense_rank
¡¡¡¡4.ntile¡¡¡¡
¡¡¡¡ÏÂÃæ·Ö±ð½éÉÜÒ»ÏÂÕâËĸöÅÅÃûº¯ÊýµÄ¹¦Äܼ°Ó÷¨¡£ÔÚ½éÉÜ֮ǰ¼ÙÉèÓÐÒ»¸öt_table±í£¬±í½á¹¹Óë±íÖеÄÊý¾ÝÈçͼ1Ëùʾ£º
¡¡¡¡Í¼1
¡¡¡¡ÆäÖÐfield1×ֶεÄÀàÐÍÊÇint£¬field2×Ö¶ ......
ÓÃ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 ......
SQL Server 2005 CE¿ª·¢»·¾³½éÉÜ£º
×î½üѧϰʹÓÃSQL Server 2005 Compact Edition½øÐÐÊý¾Ý´æ´¢£¬ÔÚѧϰµÄ¹ý³ÌÖз¢ÏÖ£¬Ê¹ÓÃSQL Server2005 management Studio´´½¨Êý¾Ý¿âʱ£¬ÔÚ“·þÎñÆ÷ÀàÐÍ”ÏÂÀÁбíÖÐûÓГSQL Server Compact Edition”Ñ¡Ïî¡£ÒòΪÎÄÕ ......