Skip to content

A supplementary reporting tool for steventen's sql_tracker

License

Notifications You must be signed in to change notification settings

TarasJan/sql_reporter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

What this is?

This is a gem that can be used for comparing reports generated by excellent sql_tracker gem for different branches. It can be useful for detecting SQL queries regressions or optimisation opportunities.

Setup

Simply run the following in terminal while in the repo directory (temporary solution while not in rubygems.org)

gem build sql_reporter.gemspec
gem install sql_reporter

or if you are using Bundler

bundle

Usage

sql_reporter original_branch.json improved_branch.json

The above will generate a comparison.log file with content akin to:

SQL Count Decreases between samples/master.json -> samples/637.json
##########################################################

Queries killed: 0

Duration decrease[ms]: 0.0

SQL Count Increases between samples/master.json -> samples/637.json
##########################################################

Queries killed: 0

Duration decrease[ms]: 0.0

SQL Spawned between samples/master.json -> samples/637.json
##########################################################
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------+-------------------------------------+
|Query                                                                                                                                                                                                                                 |Count difference             |Duration difference [ms]             |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------+-------------------------------------+
|SELECT `apples`.* FROM `apples` WHERE `apples`.`apple_id` = xxx AND `apples`.`locale` = xxx AND `appler`.`apple_type` IN (xxx)             |0 -> 1                       |0.0 -> 1.76                          |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------+-------------------------------------+
Queries spawned: 1

Duration gain[ms]: 1.76

SQL Gone between samples/master.json -> samples/637.json
##########################################################
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------+--------------------+
|Query                                                                                                                                                                                                                                                                   |Count diff… |Duration differenc… |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------+--------------------+
|SELECT `apples`.* FROM `apples` WHERE `apples`.`apple_id` = xxx AND `apples`.`apple_type` = xxx AND `apples`.`locale` = xxx ORDER BY `email_default_messages`.`id` ASC LIMI… |7 -> 0      |13.78 -> 0.0        |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------+--------------------+
Queries killed: 7

Duration decrease[ms]: 13.78

################## SUMMARY #####################

Queries killed: 6

Duration decrease[ms]: 12.02

About

A supplementary reporting tool for steventen's sql_tracker

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages