shiba 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +16 -6
- data/lib/shiba/setup.rb +3 -0
- data/lib/shiba/version.rb +1 -1
- data/web/results.html.erb +3 -2
- metadata +2 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: ad898fa0f36457fbd570698c276b567f6f09f1a2
         | 
| 4 | 
            +
              data.tar.gz: '028e8a99dff1f8c843bcb222151a0c100f0ebbe1'
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 716210a01a6fded73a217b03992371c4d8dcff472f1a69a6195cb53e1dfb122b8c43c512fa7f4ef30bbf776ee8eff3fcabe356bb3e5f4967cec5a4383ec1675a
         | 
| 7 | 
            +
              data.tar.gz: 4f7434ec7c78fa7134947ecfe90d9706e4cb22e800eb8036b03216522dee96c8d42e2a33409c5b40e9f4fbb478e48bf6a5e127c3fe0c05284819bd9d87f392ea
         | 
    
        data/Gemfile.lock
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | @@ -14,19 +14,21 @@ By default, it will pretty much only detect queries that miss indexes. As it's f | |
| 14 14 | 
             
            Install using bundler. Note: this gem is not designed to be run on production.
         | 
| 15 15 |  | 
| 16 16 | 
             
            ```ruby
         | 
| 17 | 
            -
             | 
| 17 | 
            +
            # Gemfile
         | 
| 18 | 
            +
            gem 'shiba', :group => :test
         | 
| 18 19 | 
             
            ```
         | 
| 19 20 |  | 
| 20 | 
            -
            If  | 
| 21 | 
            +
            If your application lazy loads gems, you will to manually require it.
         | 
| 21 22 |  | 
| 22 23 | 
             
            ```ruby
         | 
| 23 | 
            -
             | 
| 24 | 
            -
             | 
| 24 | 
            +
            # config/environments/test.rb or test/test_helper.rb
         | 
| 25 | 
            +
            require 'shiba/setup'
         | 
| 25 26 | 
             
            ```
         | 
| 26 27 |  | 
| 27 28 | 
             
            ## Usage
         | 
| 28 29 |  | 
| 29 30 | 
             
            A report will only be generated when problem queries are detected.
         | 
| 31 | 
            +
            To verify shiba is actually running, you can run your tests with SHIBA_DEBUG=true.
         | 
| 30 32 |  | 
| 31 33 | 
             
            ```ruby
         | 
| 32 34 | 
             
            # Install
         | 
| @@ -35,11 +37,17 @@ bundle | |
| 35 37 | 
             
            # Run some tests using to generate a SQL report
         | 
| 36 38 | 
             
            rake test:functional
         | 
| 37 39 | 
             
            rails test test/controllers/users_controller_test.rb
         | 
| 40 | 
            +
            SHIBA_DEBUG=true ruby test/controllers/users_controller_test.rb
         | 
| 38 41 |  | 
| 39 42 | 
             
            # 1 problematic query detected
         | 
| 40 43 | 
             
            # Report available at /tmp/shiba-explain.log-1550099512
         | 
| 41 44 | 
             
            ```
         | 
| 42 45 |  | 
| 46 | 
            +
            ### Screenshot
         | 
| 47 | 
            +
            `open /tmp/shiba-explain.log-1550099512`
         | 
| 48 | 
            +
            
         | 
| 49 | 
            +
             | 
| 50 | 
            +
             | 
| 43 51 | 
             
            ## Typical query problems
         | 
| 44 52 |  | 
| 45 53 | 
             
            Here are some typical query problems Shiba can detect. We'll assume the following schema:
         | 
| @@ -85,7 +93,7 @@ With more data, Shiba can help detect this issue when it appears in a pull reque | |
| 85 93 |  | 
| 86 94 | 
             
            ## Going beyond table scans
         | 
| 87 95 |  | 
| 88 | 
            -
             | 
| 96 | 
            +
            Without more information, Shiba acts as a simple missed index detector. To catch other problems that can bring down production (or at least cause some performance issues), Shiba requires general statistics about production data, such as the number of rows in a table and how unique columns are.
         | 
| 89 97 |  | 
| 90 98 | 
             
            This information can be obtained by running the bin/dump_stats command in production.
         | 
| 91 99 |  | 
| @@ -100,7 +108,9 @@ scp production:~/shiba_index.yml RAILS_PROJECT/config | |
| 100 108 | 
             
            ```
         | 
| 101 109 |  | 
| 102 110 | 
             
            The stats file will look similar to the following:
         | 
| 103 | 
            -
             | 
| 111 | 
            +
            ```console
         | 
| 112 | 
            +
            local$ head <rails_project>/config/shiba_index.yml
         | 
| 113 | 
            +
            ```
         | 
| 104 114 | 
             
            ```yaml
         | 
| 105 115 | 
             
            users:
         | 
| 106 116 | 
             
              count: 10000
         | 
    
        data/lib/shiba/setup.rb
    ADDED
    
    
    
        data/lib/shiba/version.rb
    CHANGED
    
    
    
        data/web/results.html.erb
    CHANGED
    
    | @@ -43,7 +43,7 @@ | |
| 43 43 |  | 
| 44 44 | 
             
                  Query.prototype = {
         | 
| 45 45 | 
             
                    hasTag: function(tag) {
         | 
| 46 | 
            -
                      this.tags.includes(tag);
         | 
| 46 | 
            +
                      return this.tags.includes(tag);
         | 
| 47 47 | 
             
                    },
         | 
| 48 48 | 
             
                    splitSQL: function() {
         | 
| 49 49 | 
             
                      this.sqlFragments = this.sql.match(/(SELECT\s)(.*?)(\s+FROM .*)/i);
         | 
| @@ -175,7 +175,8 @@ | |
| 175 175 | 
             
                    <div class="row">
         | 
| 176 176 | 
             
                      <div v-if="hasFuzzed" class="alert alert-warning" role="alert">
         | 
| 177 177 | 
             
                        This query analysis was generated using estimated table sizes.
         | 
| 178 | 
            -
                         | 
| 178 | 
            +
                        To improve these results and find other problem queries beyond missing indexes, we'll need more stats.<br/>
         | 
| 179 | 
            +
                        <a target="_blank" href="https://github.com/burrito-brothers/shiba/blob/master/README.md#going-beyond-table-scans">Find out how to get a more accurate analysis by feeding Shiba index stats</a>
         | 
| 179 180 | 
             
                      </div>
         | 
| 180 181 |  | 
| 181 182 | 
             
                      <div class="col-12">We found {{ queries.length }} queries that deserve your attention: </div>
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: shiba
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.2. | 
| 4 | 
            +
              version: 0.2.3
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Ben Osheroff
         | 
| @@ -102,6 +102,7 @@ files: | |
| 102 102 | 
             
            - lib/shiba/output/tags.yaml
         | 
| 103 103 | 
             
            - lib/shiba/query.rb
         | 
| 104 104 | 
             
            - lib/shiba/query_watcher.rb
         | 
| 105 | 
            +
            - lib/shiba/setup.rb
         | 
| 105 106 | 
             
            - lib/shiba/table_stats.rb
         | 
| 106 107 | 
             
            - lib/shiba/version.rb
         | 
| 107 108 | 
             
            - shiba.gemspec
         |