my_reg 发表于 2007-1-29 19:24:13

请各位帮我分析一下dbcc tranceon(3604,302,310) 的结果

<p>select count(*) from T_Basic a,T_EStatus b where a.EID =b.EID</p><p>下面是我执行这条语句的跟踪结果,T_Basic和T_EStatus&nbsp;都 有150万条数据,两张表的EID都是索引,大概执行15秒。</p><p>******************************* <br/>Beginning selection of qualifying indexes for table 'T_Basic', <br/>correlation name 'a', varno = 0, objectid 1856006612. <br/>&nbsp;&nbsp; The table (Datarows) has 461020 rows, 106683 pages, <br/>&nbsp;&nbsp; The table's Data Page Cluster Ratio 0.999990 </p><p>Table scan cost is 461020 rows, 107416 pages, <br/>&nbsp;&nbsp; using data prefetch (size 16K I/O), <br/>&nbsp;&nbsp; in data cache 'bizcache' (cacheid 1) with MRU replacement</p><p><br/>Index selection finished for table 'T_Basic' (objectid 1856006612). </p><p><br/>The best qualifying&nbsp; index is 'T_18560066121' (indid 5) <br/>&nbsp;&nbsp; costing 6570 pages, <br/>&nbsp;&nbsp; with an estimate of 461020 rows to be returned per scan of the table, <br/>&nbsp;&nbsp; using index prefetch (size 16K I/O) on leaf pages, <br/>&nbsp;&nbsp; in index cache 'bizcache' (cacheid 1) with LRU replacement</p><p>Index covers query. <br/>Search argumE selectivity is 1.000000. </p><p>******************************* </p><p>******************************* <br/>Beginning selection of qualifying indexes for table 'T_EStatus', <br/>correlation name 'b', varno = 1, objectid 2080007410. <br/>&nbsp;&nbsp; The table (Datarows) has 1419841 rows, 57705 pages, <br/>&nbsp;&nbsp; The table's Data Page Cluster Ratio 0.999723 <br/>&nbsp;&nbsp; The table has 20 partitions. <br/>&nbsp;&nbsp; The largest partition has 57666 pages. <br/>&nbsp;&nbsp; The partition skew is 19.514721. </p><p><br/>Table scan cost is 1419841 rows, 59081 pages, <br/>&nbsp;&nbsp; using data prefetch (size 16K I/O), <br/>&nbsp;&nbsp; in data cache 'bizcache' (cacheid 1) with MRU replacement</p><p>Index selection finished for table 'T_EStatus' (objectid 2080007410). </p><p>The best qualifying&nbsp; index is 'id_Eid' (indid 3) <br/>&nbsp;&nbsp; costing 21347 pages, <br/>&nbsp;&nbsp; with an estimate of 1419841 rows to be returned per scan of the table, <br/>&nbsp;&nbsp; using index prefetch (size 16K I/O) on leaf pages, <br/>&nbsp;&nbsp; in index cache 'bizcache' (cacheid 1) with LRU replacement <br/>Index covers query. <br/>Search argumE selectivity is 1.000000. </p><p>******************************* </p><p>******************************* <br/>Beginning selection of qualifying indexes for table 'T_Basic', <br/>correlation name 'a', varno = 0, objectid 1856006612. <br/>&nbsp;&nbsp; The table (Datarows) has 461020 rows, 106683 pages, <br/>&nbsp;&nbsp; The table's Data Page Cluster Ratio 0.999990 </p><p><br/>Table scan cost is 461020 rows, 107416 pages, <br/>&nbsp;&nbsp; using data prefetch (size 16K I/O), <br/>&nbsp;&nbsp; in data cache 'bizcache' (cacheid 1) with MRU replacement </p><p>Selecting best index for the JOIN CLAUSE: <br/>&nbsp;T_Basic.EID = b.EID </p><p>Estimated selectivity for EID, <br/>&nbsp;&nbsp; selectivity = 0.000002. <br/>Unique nonclustered index found, returns 1 row, 4 pages </p><p>Estimating selectivity of index 'T_18560066121', indid 5 <br/>&nbsp;&nbsp; scan selectivity 0.000002, filter selectivity 0.000002&nbsp; <br/>&nbsp;&nbsp; 1 rows, 4 pages, index height 3, <br/>&nbsp;&nbsp; Data Row Cluster Ratio 0.997759, <br/>&nbsp;&nbsp; Index Page Cluster Ratio 0.932301, <br/>&nbsp;&nbsp; Data Page Cluster Ratio 0.991322 </p><p>The best qualifying Nested Loop join index is 'T_18560066121' (indid 5) <br/>&nbsp;&nbsp; costing 4 pages, <br/>&nbsp;&nbsp; with an estimate of 1 rows to be returned per scan of the table, <br/>&nbsp;&nbsp; using no index prefetch (size 2K I/O) on leaf pages, <br/>&nbsp;&nbsp; in index cache 'bizcache' (cacheid 1) with LRU replacement <br/>Index covers query. <br/>Join selectivity is 0.000002. </p><p>If this access path is selected for a merge join, this table will be sorted. </p><p>******************************* </p><p>******************************* <br/>Beginning selection of qualifying indexes for table 'T_EStatus', <br/>correlation name 'b', varno = 1, objectid 2080007410. <br/>&nbsp;&nbsp; The table (Datarows) has 1419841 rows, 57705 pages, <br/>&nbsp;&nbsp; The table's Data Page Cluster Ratio 0.999723 <br/>&nbsp;&nbsp; The table has 20 partitions. <br/>&nbsp;&nbsp; The largest partition has 57666 pages. <br/>&nbsp;&nbsp; The partition skew is 19.514721. </p><p><br/>Table scan cost is 1419841 rows, 59081 pages, <br/>&nbsp;&nbsp; using data prefetch (size 16K I/O), <br/>&nbsp;&nbsp; in data cache 'bizcache' (cacheid 1) with MRU replacement </p><p>Selecting best index for the JOIN CLAUSE: <br/>&nbsp;T_EStatus.EID = a.EID </p><p>Estimated selectivity for EID, <br/>&nbsp;&nbsp; selectivity = 0.000001. </p><p>Estimating selectivity of index 'id_Eid', indid 3 <br/>&nbsp;&nbsp; scan selectivity 0.000001, filter selectivity 0.000001&nbsp; <br/>&nbsp;&nbsp; 1 rows, 4 pages, index height 3, <br/>&nbsp;&nbsp; Data Row Cluster Ratio 0.489111, <br/>&nbsp;&nbsp; Index Page Cluster Ratio 0.976601, <br/>&nbsp;&nbsp; Data Page Cluster Ratio 0.350660 </p><p>The best qualifying Nested Loop join index is 'id_Eid' (indid 3) <br/>&nbsp;&nbsp; costing 4 pages, <br/>&nbsp;&nbsp; with an estimate of 1 rows to be returned per scan of the table, <br/>&nbsp;&nbsp; using no index prefetch (size 2K I/O) on leaf pages, <br/>&nbsp;&nbsp; in index cache 'bizcache' (cacheid 1) with LRU replacement <br/>Index covers query. <br/>Join selectivity is 0.000001. </p><p>If this access path is selected for a merge join, this table will be sorted. </p><p>******************************* </p><p><br/>QUERY IS CONNECTED <br/>Number of tables in join: 2 <br/>Number of tables considered at a time: 2 <br/>Table count setting: 0 (default value used) </p><p>&nbsp;0 - 1 - </p><p>NEW PLAN (total cost = 3780590): </p><p>varno=0 (T_Basic) indexid=5 (T_18560066121) <br/>path=0x2981B4EC pathtype=sclause <br/>method=NESTED ITERATION&nbsp; <br/>scanthreads=1 <br/>outerrows=1 rows=461020 joinsel=1.000000 scanpgs=6570 <br/>index_prefetch=YES index_iosize=16 index_bufreplace=LRU <br/>scanlio=6570 scanpio=1300 <br/>corder=1 </p><p>varno=1 (T_EStatus) indexid=3 (id_Eid) <br/>path=0x2679B000 pathtype=join <br/>method=NESTED ITERATION&nbsp; <br/>scanthreads=1 <br/>outerrows=461020 rows=462472 joinsel=0.000001 jnpgs_per_scan=4 <br/>index_prefetch=YES index_iosize=16 index_bufreplace=LRU <br/>scanlio=1844080 scanpio=3105 <br/>corder=3 </p><p>jnvar=0 refcost=0 refpages=0 reftotpages=16920 ordercol=3&nbsp; ordercol=1 </p><p>&nbsp;1 - 0 - </p><p>TOTAL # PERMUTATIONS: 2 </p><p>TOTAL # PLANS CONSIDERED: 12 </p><p>CACHE USED BY THIS PLAN: </p><p>&nbsp;CacheID = 1:&nbsp;(2K) 0&nbsp;(4K) 0&nbsp;(8K) 0&nbsp;(16K) 27917 </p><p>FINAL PLAN (total cost = 3780590): </p><p><br/>varno=0 (T_Basic) indexid=5 (T_18560066121) <br/>path=0x2981B4EC pathtype=sclause <br/>method=NESTED ITERATION&nbsp; <br/>scanthreads=1 <br/>outerrows=1 rows=461020 joinsel=1.000000 scanpgs=6570 <br/>index_prefetch=YES index_iosize=16 index_bufreplace=LRU <br/>scanlio=6570 scanpio=1300 <br/>corder=1 </p><p>varno=1 (T_EStatus) indexid=3 (id_Eid) <br/>path=0x2679B000 pathtype=join <br/>method=NESTED ITERATION&nbsp; <br/>scanthreads=1 <br/>outerrows=461020 rows=462472 joinsel=0.000001 jnpgs_per_scan=4 <br/>index_prefetch=YES index_iosize=16 index_bufreplace=LRU <br/>scanlio=1844080 scanpio=3105 <br/>corder=3 </p><p>jnvar=0 refcost=0 refpages=0 reftotpages=16920 ordercol=3&nbsp; ordercol=1 </p>

flybean 发表于 2007-2-2 13:58:46

如何优化,是要根据你的主要业务来定,而不定某一句随便的SQL

flybean 发表于 2007-1-30 11:41:16

嘛目的?

my_reg 发表于 2007-1-30 14:17:08

感觉查询有点慢,想找一下原因,看能否优化一下。

flybean 发表于 2007-1-31 12:59:01

也没有都150W嘛,一个 4x W,一个 14x W,一对多,<br/>

my_reg 发表于 2007-1-31 13:11:52

这是我用的另一个测试库做的,理论上这两张表数据行数应该是一样的,现在真实库中大概都有140多万条。这条语句还是最简单的,查询起来都很慢,复杂的查询就更慢了。
页: [1]
查看完整版本: 请各位帮我分析一下dbcc tranceon(3604,302,310) 的结果

免责声明:
本站所发布的一切破解补丁、注册机和注册信息及软件的解密分析文章仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。如有侵权请邮件与我们联系处理。

Mail To:Admin@SybaseBbs.com