All Projects → kirillshevch → Query_track

kirillshevch / Query_track

Licence: mit
Find time-consuming database queries for ActiveRecord-based Rails Apps

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Query track

Active record doctor
Identify database issues before they hit production.
Stars: ✭ 865 (+235.27%)
Mutual labels:  database, rails, performance
Objectbox C
ObjectBox C and C++: super-fast database for objects and structs
Stars: ✭ 91 (-64.73%)
Mutual labels:  database, performance
Graphjin
GraphJin - Build APIs in 5 minutes with GraphQL. An instant GraphQL to SQL compiler.
Stars: ✭ 1,264 (+389.92%)
Mutual labels:  database, rails
Pg flame
A flamegraph generator for Postgres EXPLAIN ANALYZE output.
Stars: ✭ 1,391 (+439.15%)
Mutual labels:  database, performance
Pgtune
Pgtune - tuning PostgreSQL config by your hardware
Stars: ✭ 1,078 (+317.83%)
Mutual labels:  database, performance
Powa Web
PoWA user interface
Stars: ✭ 66 (-74.42%)
Mutual labels:  database, performance
Activerecord Clean Db Structure
Automatic cleanup for the Rails db/structure.sql file (ActiveRecord/PostgreSQL)
Stars: ✭ 101 (-60.85%)
Mutual labels:  database, rails
Js Search
JS Search is an efficient, client-side search library for JavaScript and JSON objects
Stars: ✭ 1,920 (+644.19%)
Mutual labels:  database, performance
Reactive record
Generate ActiveRecord models for a pre-existing Postgres db
Stars: ✭ 132 (-48.84%)
Mutual labels:  database, rails
Pg stat kcache
Gather statistics about physical disk access and CPU consumption done by backends.
Stars: ✭ 106 (-58.91%)
Mutual labels:  database, performance
Ansible Role Memcached
Ansible Role - Memcached
Stars: ✭ 54 (-79.07%)
Mutual labels:  database, performance
Seamless database pool
Add support for master/slave database clusters in ActiveRecord to improve performance.
Stars: ✭ 222 (-13.95%)
Mutual labels:  database, rails
Niklick
Rails Versioned API solution template for hipsters! (Ruby, Ruby on Rails, REST API, GraphQL, Docker, RSpec, Devise, Postgress DB)
Stars: ✭ 39 (-84.88%)
Mutual labels:  database, rails
Cetus
Cetus is a high performance middleware that provides transparent routing between your application and any backend MySQL Servers.
Stars: ✭ 1,199 (+364.73%)
Mutual labels:  database, performance
Activerecord Sqlserver Adapter
SQL Server Adapter For Rails
Stars: ✭ 910 (+252.71%)
Mutual labels:  database, rails
Lol dba
lol_dba is a small package of rake tasks that scan your application models and displays a list of columns that probably should be indexed. Also, it can generate .sql migration scripts.
Stars: ✭ 1,363 (+428.29%)
Mutual labels:  database, rails
Metabase
The simplest, fastest way to get business intelligence and analytics to everyone in your company 😋
Stars: ✭ 26,803 (+10288.76%)
Mutual labels:  database, slack
Libmdbx
One of the fastest embeddable key-value ACID database without WAL. libmdbx surpasses the legendary LMDB in terms of reliability, features and performance.
Stars: ✭ 729 (+182.56%)
Mutual labels:  database, performance
Counter culture
Turbo-charged counter caches for your Rails app.
Stars: ✭ 1,397 (+441.47%)
Mutual labels:  database, rails
Immudb
immudb - world’s fastest immutable database, built on a zero trust model
Stars: ✭ 3,743 (+1350.78%)
Mutual labels:  database, performance

QueryTrack

Gem Version Maintainability

Tool for finding time-consuming database queries for ActiveRecord-based Rails Apps. Provides Slack notifications with backtrace, raw SQL, time duration, etc.

Installation

Add this line to your application's Gemfile and then execute bundle install:

gem 'query_track'

Usage

SQL Duration Limit

Specify SQL duration query limit (in seconds):

QueryTrack::Settings.configure do |config|
  config.duration = 0.5
end

Console Log

Enable console logs from config:

QueryTrack::Settings.configure do |config|
  config.duration = 0.5
  config.logs = true
end

Log Example

Filters

To avoid noisy warnings from used gems, and places where fat queries are justified, you can filters SQL by backtrace. For example, you have installed activeadmin and want to skip everything from app/admin:

QueryTrack::Settings.configure do |config|
  config.duration = 0.5
  config.filters = ['app/admin']
end

App Directory

QueryTrack finds the trace by filtering the caller by the app directory. By default, the app directory is set to 'app', the default for Rails apps. For apps that have a non-stanard app directory, this can be set with the app_dir config field:

QueryTrack::Settings.configure do |config|
  config.duration = 0.5
  config.app_dir = 'backend'
end

Enable/Disable toggle

Enable/disable with ENV variables to turn it on/off without code push. By default QueryTrack is enabled.

QueryTrack::Settings.configure do |config|
  config.duration = 0.5
  config.enabled = ENV['QUERY_TRACK_ENABLED']
end

Slack Notifications

To receive notifications about slow queries into Slack, you need to install incoming-webhooks and put link into config file:

QueryTrack::Settings.configure do |config|
  config.duration = 0.5
  config.notifications.slack = 'https://hooks.slack.com/services/T0000000/B0000000/C0000000'
end

Incoming Hook Example

Custom Notifications (Handlers)

You can write your own handler for slow queries. Send data to any source(for e.g. to logs storage) or make notification for another source(Email, Messengers, etc.)

QueryTrack::Settings.configure do |config|
  config.duration = 0.5
  config.notifications.custom_handler = -> (sql, duration, trace) {
    # data processing...
  }
end

Production Usage Notes

When QueryTrack send slack hooks, request is executed in separate thread. So there should be no synchronous delays.

Subscription to SQL events and checking duration time actually take insignificant time in milliseconds.

If your project is horizontally scaled, you can install query_track for one of the node to avoid performance degrade for whole application.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/kirillshevch/query_track.

License

The gem is available as open source under the terms of the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].