logging sql calls

Is there an easy way to log every SQL call to the database? I’d
like to log mysql queries and their respective execution times into a table so
that I can closely monitor/report the performance of my application and
identify potential bottlenecks.

Thanks,

Chad

I might have been a little unclear...

I'd like to log those sql calls TO a database table.

in example:

class SQLQueries < ActiveRecord::Migration
  def self.up
    create_table :sql_queries do |t|
    t.column :query, :string
    t.column :execution_time, :decimal
    t.column :date, :timestamp
  end
end

thanks,
Chad

anybody else? is it really that tough?

In case anyone in the future cares, I found a pretty good solution for
tracking db layer performance:

1) I implemented the Query Stats plugin:
http://code.google.com/p/query-stats/
2) set an after_filter to insert the results of those calls to the
database. see below:

after_filter :logging_dbstats

def logging_dbstats
    # log sql stats here (pull from footer)
    sql = "insert into
logging_dbstats(controller,action,controller_queries,view_queries,execution_time)
values
('#{params[:controller]}','#{params[:action]}','#{queries.count_with_label
:controller}', '#{queries.count_with_label :view}',
'#{queries.total_time}')"
    ActiveRecord::Base.connection.execute(sql)
end

cheers

ignore the comment in the code