<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>Manifest.txt</filename>
    </added>
    <added>
      <filename>PostInstall.txt</filename>
    </added>
    <added>
      <filename>README.rdoc</filename>
    </added>
    <added>
      <filename>Rakefile</filename>
    </added>
    <added>
      <filename>rails/init.rb</filename>
    </added>
    <added>
      <filename>script/console</filename>
    </added>
    <added>
      <filename>script/destroy</filename>
    </added>
    <added>
      <filename>script/generate</filename>
    </added>
    <added>
      <filename>spec/query_analyzer_spec.rb</filename>
    </added>
    <added>
      <filename>spec/spec.opts</filename>
    </added>
    <added>
      <filename>spec/spec_helper.rb</filename>
    </added>
    <added>
      <filename>tasks/rspec.rake</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1 +1,2 @@
 .DS_Store
+doc/*</diff>
      <filename>.gitignore</filename>
    </modified>
    <modified>
      <diff>@@ -1,3 +1,15 @@
+$:.unshift(File.dirname(__FILE__)) unless
+  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
+
+#
+# PostgreSQL/Oracle Adapter by:
+# http://spazidigitali.com/2006/12/01/rails-query-analyzer-plugin-now-also-on-oracle-and-postgresql/
+#
+
+module QueryAnalyzer
+  VERSION = '0.0.1'
+end
+
 class Array
   protected
     def qa_columnized_row(fields, sized)
@@ -27,28 +39,114 @@ class Array
 end
 
 
-
+#
+# Connection Adapters
+#
 module ActiveRecord
   module ConnectionAdapters
+
+    #
+    # MySQL
+    #
     class MysqlAdapter &lt; AbstractAdapter
       private
         alias_method :select_without_analyzer, :select
-        
+
+        def select(sql, name = nil)
+          query_results = select_without_analyzer(sql, name)
+
+          if @logger and @logger.level &lt;= Logger::INFO
+            @logger.debug(
+              @logger.silence do
+                format_log_entry(&quot;Analyzing #{name}\n&quot;,
+                  &quot;#{select_without_analyzer(&quot;explain #{sql}&quot;, name).qa_columnized}\n&quot;
+                )
+              end
+            ) if sql =~ /^select/i
+          end
+          query_results
+        end
+    end
+
+    #
+    # Oracle
+    #
+    class OracleAdapter &lt; AbstractAdapter
+        #Name of plan table, default value 'PLAN_TABLE'.
+        cattr_accessor :plan_table_name
+        @@plan_table_name = 'PLAN_TABLE'
+
+        #Plan details to use:
+        # BASIC ..... displays minimum information
+        # TYPICAL ... displays most relevant information
+        # SERIAL .... like TYPICAL but without parallel information
+        # ALL ....... displays all information
+        cattr_accessor :plan_details
+        @@plan_details ='TYPICAL'
+
+      private
+        alias_method :select_without_analyzer, :select
+
+        #Query to output the computed plan using the dbms_xplan package (available from Oracle 9i onwards)
+        def plan_query
+          &quot;select plan_table_output from table(dbms_xplan.display('#{@@plan_table_name}',null,'#{@@plan_details}'))&quot;
+        end
+
         def select(sql, name = nil)
           query_results = select_without_analyzer(sql, name)
-          
-          if @logger and @logger.level == Logger::DEBUG
+
+          if @logger and @logger.level &lt;= Logger::INFO
+            execute(&quot;explain plan for #{sql}&quot;, name)
             @logger.debug(
-              ActiveRecord::Base.silence do
-                explain_results = select_without_analyzer(&quot;explain #{sql}&quot;, name)
-                format_log_entry(&quot;\033[1;34m############ FIXME - UNOPTIMIZED QUERY for #{name} ############ \033[0m\n&quot;,
-                  &quot;#{explain_results.qa_columnized}\n&quot;
-                ) if explain_results[0][&quot;rows&quot;].to_i &gt; 100 &amp;&amp; sql =~ / where[\s(]/i
+              @logger.silence do
+                format_log_entry(&quot;Analyzing #{name}\n&quot;,
+                 &quot;#{select_without_analyzer(plan_query, name).qa_columnized}\n&quot;
+                )
               end
             ) if sql =~ /^select/i
-          end          
+          end
           query_results
         end
     end
+
+    #
+    # PostgreSQL
+    #
+    class PostgreSQLAdapter &lt; AbstractAdapter
+        # if true then uses the ANALYZE option which (from postgresql manual):
+        #Carry out the command and show the actual run times.
+        cattr_accessor :explain_analyze
+        @@explain_analyze = nil
+
+        #if true then uses the VERBOSE option which  (from postgresql manual):
+        #Shows the full internal representation of the plan tree,
+        #rather than just a summary. Usually this option is only
+        #useful for specialized debugging purposes.
+        #The VERBOSE output is either pretty-printed or not,
+        #depending on the setting of the explain_pretty_print configuration parameter.
+        cattr_accessor :explain_verbose
+      @@explain_verbose = nil
+
+      private
+
+      alias_method :select_without_analyzer, :select
+
+      def select(sql, name = nil)
+        query_results = select_without_analyzer(sql, name)
+
+        if @logger and @logger.level &lt;= Logger::INFO
+          @logger.debug(@logger.silence do
+            format_log_entry(&quot;Analyzing #{name}\n&quot;,
+            &quot;#{select_without_analyzer(&quot;explain #{'analyze' if @@explain_analyze} #{'verbose' if @@explain_verbose} #{sql}&quot;, name).qa_columnized}\n&quot;)
+          end) if sql =~ /^select/i
+        end
+
+        query_results
+
+      end
+
+    end
+
   end
+
 end</diff>
      <filename>lib/query_analyzer.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>README</filename>
    </removed>
    <removed>
      <filename>init.rb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>772f350cf558749b4cc635efe230ac0ae758f7c8</id>
    </parent>
  </parents>
  <author>
    <name>Marcos Augusto</name>
    <email>x@nofxx.com</email>
  </author>
  <url>http://github.com/nofxx/query-analyzer/commit/c99ca0b7281c18f1f075bab4a1bfb235cb655719</url>
  <id>c99ca0b7281c18f1f075bab4a1bfb235cb655719</id>
  <committed-date>2009-01-17T21:30:57-08:00</committed-date>
  <authored-date>2009-01-17T21:30:57-08:00</authored-date>
  <message>postgresl, orache and go gem</message>
  <tree>137f08074a918b5b0c9a8bb507241b3d3ce6e9f0</tree>
  <committer>
    <name>Marcos Augusto</name>
    <email>x@nofxx.com</email>
  </committer>
</commit>
