ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/trunk/runtime/IBSQL.pas
(Generate patch)

Comparing ibx/trunk/runtime/IBSQL.pas (file contents):
Revision 48 by tony, Tue Dec 6 10:33:46 2016 UTC vs.
Revision 49 by tony, Thu Feb 2 16:20:12 2017 UTC

# Line 37 | Line 37 | unit IBSQL;
37  
38   {$codepage UTF8}
39  
40 + (* Define IBXQUERYSTATS to write to stdout a summary of query execution
41 +   statistics each time a query is executed
42 +
43 +   Define IBXQUERYTIME to write to stdout The local execution time for each
44 +   query
45 +   *)
46 +
47 + { $DEFINE IBXQUERYSTATS}
48 + { $DEFINE IBXQUERYTIME}
49 +
50   interface
51  
52   uses
# Line 686 | Line 696 | end;
696   procedure TIBSQL.ExecQuery;
697   var
698    fetch_res: ISC_STATUS;
699 +  {$IFDEF IBXQUERYSTATS}
700 +  stats: TPerfCounters;
701 +  {$ENDIF}
702 +  {$IFDEF IBXQUERYTIME}
703 +  tmsecs: comp;
704 +  {$ENDIF}
705   begin
706    CheckClosed;
707    if not Prepared then Prepare;
708    CheckValidStatement;
709 +  {$IFDEF IBXQUERYTIME}
710 +  tmsecs := TimeStampToMSecs(DateTimeToTimeStamp(Now));
711 +  {$ENDIF}
712    if SQLStatementType = SQLSelect then
713    begin
714      FResultSet := FStatement.OpenCursor;
# Line 709 | Line 728 | begin
728      if not (csDesigning in ComponentState) then
729        MonitorHook.SQLExecute(Self);
730    end;
731 +  {$IFDEF IBXQUERYTIME}
732 +  writeln('Executing ',FStatement.GetSQLText,
733 +    ' Response time= ',Format('%f msecs',[TimeStampToMSecs(DateTimeToTimeStamp(Now)) - tmsecs]));
734 +  {$ENDIF}
735 +  {$IFDEF IBXQUERYSTATS}
736 +  if FStatement.GetPerfStatistics(stats) then
737 +    writeln('Executing ',FStatement.GetSQLText,
738 +    ' Elapsed time= ', FormatFloat('#0.000',stats[psRealTime]/1000),' sec');
739 +  {$ENDIF}
740    FBase.DoAfterExecQuery(self);
741   end;
742  
# Line 875 | Line 903 | begin
903                       Transaction.TransactionIntf,
904                       SQL.Text,
905                       GenerateParamNames);
906 +  {$IFDEF IBXQUERYSTATS}
907 +  FStatement.EnableStatistics(true);
908 +  {$ENDIF}
909    FMetaData := FStatement.GetMetaData;
910    FSQLParams := FStatement.GetSQLParams;
911    FStatement.SetRetainInterfaces(true);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines