1 21 22 package org.apache.derby.impl.sql.execute.rts; 23 24 import org.apache.derby.iapi.services.io.StoredFormatIds; 25 import org.apache.derby.iapi.util.PropertyUtil; 26 27 import org.apache.derby.iapi.services.i18n.MessageService; 28 import org.apache.derby.iapi.reference.SQLState; 29 30 import org.apache.derby.iapi.services.io.FormatableHashtable; 31 import org.apache.derby.iapi.services.io.FormatableProperties; 32 33 import java.io.ObjectOutput ; 34 import java.io.ObjectInput ; 35 import java.io.IOException ; 36 37 import java.util.Enumeration ; 38 import java.util.Properties ; 39 40 41 47 public class RealTableScanStatistics 48 extends RealNoPutResultSetStatistics 49 { 50 51 52 public boolean isConstraint; 53 public boolean coarserLock; 54 public int fetchSize; 55 public String isolationLevel; 56 public String tableName; 57 public String userSuppliedOptimizerOverrides; 58 public String indexName; 59 public String lockString; 60 public String qualifiers; 61 public String startPosition; 62 public String stopPosition; 63 public FormatableProperties scanProperties; 64 65 67 71 public RealTableScanStatistics(int numOpens, 72 int rowsSeen, 73 int rowsFiltered, 74 long constructorTime, 75 long openTime, 76 long nextTime, 77 long closeTime, 78 int resultSetNumber, 79 String tableName, 80 String userSuppliedOptimizerOverrides, 81 String indexName, 82 boolean isConstraint, 83 String qualifiers, 84 Properties scanProperties, 85 String startPosition, 86 String stopPosition, 87 String isolationLevel, 88 String lockString, 89 int fetchSize, 90 boolean coarserLock, 91 double optimizerEstimatedRowCount, 92 double optimizerEstimatedCost 93 ) 94 { 95 super( 96 numOpens, 97 rowsSeen, 98 rowsFiltered, 99 constructorTime, 100 openTime, 101 nextTime, 102 closeTime, 103 resultSetNumber, 104 optimizerEstimatedRowCount, 105 optimizerEstimatedCost 106 ); 107 this.tableName = tableName; 108 this.userSuppliedOptimizerOverrides = userSuppliedOptimizerOverrides; 109 this.indexName = indexName; 110 this.isConstraint = isConstraint; 111 this.qualifiers = qualifiers; 112 this.scanProperties = new FormatableProperties(); 113 for (Enumeration e = scanProperties.keys(); e.hasMoreElements(); ) 114 { 115 String key = (String )e.nextElement(); 116 this.scanProperties.put(key, scanProperties.get(key)); 117 } 118 this.startPosition = startPosition; 119 this.stopPosition = stopPosition; 120 this.isolationLevel = isolationLevel; 121 this.lockString = lockString; 122 this.fetchSize = fetchSize; 123 this.coarserLock = coarserLock; 124 } 125 126 128 135 public String getStatementExecutionPlanText(int depth) 136 { 137 String header = ""; 138 String isolationString = null; 139 140 initFormatInfo(depth); 141 142 if (userSuppliedOptimizerOverrides != null) 143 { 144 header = 145 indent + MessageService.getTextMessage(SQLState.RTS_USER_SUPPLIED_OPTIMIZER_OVERRIDES_FOR_TABLE, 146 tableName, userSuppliedOptimizerOverrides); 147 header = header + "\n"; 148 } 149 if (indexName != null) 150 { 151 header = header + 152 indent + MessageService.getTextMessage( 153 SQLState.RTS_IS_RS_USING, 154 tableName, 155 MessageService.getTextMessage( 156 (isConstraint) ? 157 SQLState.RTS_CONSTRAINT : 158 SQLState.RTS_INDEX), 159 indexName); 160 161 } 162 else 163 { 164 header = header + 165 indent + MessageService.getTextMessage( 166 SQLState.RTS_TS_RS_FOR, 167 tableName); 168 } 169 170 header = header + " " + MessageService.getTextMessage( 171 SQLState.RTS_LOCKING_OPTIMIZER, 172 isolationLevel, 173 lockString); 174 175 179 if (coarserLock) 180 { 181 header = header + " (" + MessageService.getTextMessage( 182 SQLState.RTS_ACTUAL_TABLE) + 183 ")"; 184 } 185 186 header = header + "\n"; 187 188 String scanInfo = 189 indent + MessageService.getTextMessage(SQLState.RTS_SCAN_INFO) + 190 ": \n" + 191 PropertyUtil.sortProperties(scanProperties, subIndent); 192 193 return 194 header + 195 indent + MessageService.getTextMessage(SQLState.RTS_NUM_OPENS) + 196 " = " + numOpens + "\n" + 197 indent + MessageService.getTextMessage(SQLState.RTS_ROWS_SEEN) + 198 " = " + rowsSeen + "\n" + 199 indent + MessageService.getTextMessage( 200 SQLState.RTS_ROWS_FILTERED) + 201 " = " + rowsFiltered + "\n" + 202 indent + MessageService.getTextMessage(SQLState.RTS_FETCH_SIZE) + 203 " = " + fetchSize + "\n" + 204 dumpTimeStats(indent, subIndent) + "\n" + 205 ((rowsSeen > 0) 206 ? 207 subIndent + MessageService.getTextMessage( 208 SQLState.RTS_NEXT_TIME) + 209 " = " + (nextTime / rowsSeen) + "\n" 210 : 211 "") + "\n" + 212 scanInfo + 213 subIndent + MessageService.getTextMessage( 214 SQLState.RTS_START_POSITION) + 215 ": \n" + startPosition + 216 subIndent + MessageService.getTextMessage( 217 SQLState.RTS_STOP_POSITION) + 218 ": \n" + stopPosition + 219 subIndent + MessageService.getTextMessage(SQLState.RTS_QUALS) + 220 ":\n" + qualifiers + "\n" + 221 dumpEstimatedCosts(subIndent); 224 } 225 226 236 public String getScanStatisticsText(String tableName, int depth) 237 { 238 if ((tableName == null) || (tableName.equals(this.tableName))) 239 return getStatementExecutionPlanText(depth); 240 else 241 return ""; 242 } 243 244 245 247 public String toString() 248 { 249 return getStatementExecutionPlanText(0); 250 } 251 252 256 public String getNodeName(){ 257 return MessageService.getTextMessage( 258 indexName == null ? 259 SQLState.RTS_TABLE_SCAN : 260 SQLState.RTS_INDEX_SCAN); 261 } 262 263 268 public String getNodeOn(){ 269 if (indexName == null) 270 return MessageService.getTextMessage(SQLState.RTS_ON, tableName); 271 else 272 return MessageService.getTextMessage(SQLState.RTS_ON_USING, 273 tableName, 274 indexName); 275 } 276 } 277 | Popular Tags |