{"id":7773,"date":"2016-03-30T11:45:23","date_gmt":"2016-03-30T11:45:23","guid":{"rendered":"https:\/\/dev.railscarma.com\/get-more-out-of-queries-in-rails-using-bullet-in-just-3-steps\/"},"modified":"2021-06-06T12:30:08","modified_gmt":"2021-06-06T12:30:08","slug":"get-more-out-of-queries-in-rails-using-bullet-in-just-3-steps","status":"publish","type":"post","link":"https:\/\/www.railscarma.com\/sv\/blogg\/tekniska-artiklar\/get-more-out-of-queries-in-rails-using-bullet-in-just-3-steps\/","title":{"rendered":"Get More Out of Queries in Rails Using Bullet in Just 3 Steps"},"content":{"rendered":"<div data-elementor-type=\"wp-post\" data-elementor-id=\"7773\" class=\"elementor elementor-7773\" data-elementor-post-type=\"post\">\n\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-6c9f2594 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"6c9f2594\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-6c021b6c\" data-id=\"6c021b6c\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-5716e1a8 elementor-widget elementor-widget-text-editor\" data-id=\"5716e1a8\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\tHave you ever opened a closet only to have all the inside contents fall all over you? In the programming setting, this is called as \u201cspaghetti code\u201d. These are the kind of codes that are so jumbled that as soon as you make a little change, everything starts falling apart. As much as it is important to write good codes, it is equally important to keep them clean. But when you are developing a large scale application, it becomes difficult to keep your codes clean and organized. In this article you will read to get more out of queries in rails using bullet in just 3 steps\n\nFor a large scale projects with added complexity, manual code refactoring becomes a huge risk and time consuming. Therefore, it is recommended to use third party tools like Bullet Gem for the maintenance, security and optimization of codes.\n\nBullet plugin, developed by Richard Huang for Ruby on Rails, was first used in 2009. And since then, it has proved to be a powerful gem that helps monitor Ruby on Rails applications for performance improvements. Bullet Gem helps in reducing the number of queries that an application makes. It also helps in finding <strong>N+1<\/strong> queries in the application during development mode by showing the notifications in browser.\n\n<img decoding=\"async\" class=\"aligncenter wp-image-7776 size-full\" src=\"https:\/\/www.railscarma.com\/wp-content\/uploads\/2016\/03\/image_bullet_gem.jpg\" alt=\"image_bullet_gem\" width=\"589\" height=\"271\" \/>\n\n<strong>N+1<\/strong> query problem is a situation when the developer makes extra calls to database when s\/he wants to get a specific associated data over and over again.\n\nFor example,\n<blockquote>2.2.1 :005 &gt; Message.all.each {|message| message.conversation.sender_id}<\/blockquote>\nThis example gets all messages, then iterates each of those records and tries to get messages conversation from database. Solution for this problem is Bullet plugin, which helps to monitor the queries of the application. It notifies any N+1 scenarios and the unused eager loads. Other common solution for this is to use eager loading methods are preload, includes, eager_load.\n\nExamples for the following methods:-\n<blockquote>2.2.1 :007 &gt; Message.includes(:conversation).references(:conversations).each { |message| message.conversation.sender_id }\n\n2.2.1 :008 &gt; Message.eager_load(:conversation).each { |message| message.conversation.sender_id }\n\n2.2.1 :009 &gt; Message.preload(:conversation).all.each { |message| message.conversation.sender_id }\n\nEager loading is the solution to the N+1 query problem which makes sure we don\u2019t end up running unnecessary queries while looping through an object.<\/blockquote>\n<h4><strong>Usage &amp;\u00a0Configuration\u00a0Of Bullet Gem :\u00a0<\/strong><\/h4>\nBelow example shows two models; Message and Conversation, wherein a Message consists of many Conversations. Bit of code should be:-\n<blockquote>In app\/controllers\/messages_controller.rb\n\nclass MessagesController &lt; ApplicationController\ndef index\n@messages = Message.all\nend\nend\nIn app\/views\/messages\/index.html.erb\n\n&lt;h1&gt;Messages&lt;\/h1&gt;\n\n&lt;% @messages.each do |message| %&gt;\n\n&lt;%message.conversations.each do |conversation|%&gt;\n\n&lt;ul class=&quot;&rdquo;message_link&rdquo;&quot;&gt;\n\n&lt;li&gt;&lt;%=link_to conversation.sender_id, conversation_path(conversation)%&gt;&lt;\/li&gt;\n\n&lt;\/ul&gt;\n\n&lt;%end%&gt;\n\n&lt;% end %&gt;<\/blockquote>\n<strong>Basically Bullet gem helps to resolving n+1 problem in rails application.<\/strong>\n<h4>Get More Out of Queries in Rails Using Bullet in Just 3 Steps<\/h4>\nStep 1:-\n\nAdd Bullet gem to gemfile and run bundle install,\n<blockquote># For code optimisation\n\ngem &#8216;bullet&#8217;, group: [:development, :test]<\/blockquote>\nThe gem should only be used in the development environment, as you wouldn\u2019t want the users of the application getting alerts about the N+1 query problems.\n\nStep 2:-\n\nBullet should be enabled in the application. Just adding the bullet gem won\u2019t notify the bad queries. Configuration is done in the config\/environments\/development.rb.\n<blockquote>config.after_initialize do\n\nBullet.enable = true\nBullet.alert = true\nBullet.bullet_logger = true\nBullet.console = true\nBullet.rails_logger = true\nBullet.unused_eager_loading_enable = false\nend\nBullet.enable: enable Bullet gem, otherwise do nothing\n\nBullet.alert: pop up a JavaScript alert in the browser\n\nBullet.bullet_logger: log to the Bullet log file (Rails.root\/log\/bullet.log)\n\nBullet.rails_logger: add warnings directly to the Rails log<\/blockquote>\nStep 3:\n\nRestart the server. After step 2, we would see a JavaScript alert popup in the browser with the detected N+1 query. The alert would contain the file that holds the issue and the suggestions to what could be done to override the problem.\nIn Controller,\n<blockquote>class MessagesController &lt; ApplicationController\n\ndef index\n\n@messages = Message.includes(:conversations)\n\nend\n\nend<\/blockquote>\n<strong>Refrences:-<\/strong>\n\nGITHUB LINK: &#8211; <a href=\"https:\/\/github.com\/flyerhzm\/bullet\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/github.com\/flyerhzm\/bullet<\/a>\n\nOur developers are well versed in doing all kinds of <a href=\"https:\/\/www.railscarma.com\/sv\/hyra-ruby-on-rails-utvecklare\/\" target=\"_blank\" rel=\"noopener noreferrer\">ruby on rails utvecklingsarbete<\/a> och hantera alla typer av projekt. <a href=\"\/sv\/kontakta-oss\/\" target=\"_blank\" rel=\"noopener noreferrer\">Kontakta oss<\/a> att veta mer om v\u00e5r utvecklingskompetens och de projekt som vi kan hantera.\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-70987f92 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"70987f92\" data-element_type=\"section\" data-settings=\"{&quot;background_background&quot;:&quot;classic&quot;}\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-71c6c633\" data-id=\"71c6c633\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-61d1550a elementor-widget elementor-widget-heading\" data-id=\"61d1550a\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Prenumerera f\u00f6r de senaste uppdateringarna<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-3e7f0ce0 elementor-widget elementor-widget-shortcode\" data-id=\"3e7f0ce0\" data-element_type=\"widget\" data-widget_type=\"shortcode.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-shortcode\">\t\t\t\t\t<script type=\"text\/javascript\">\n\t\t\t\t\t\tvar gCaptchaSibWidget;\n                        var onloadSibCallbackInvisible = function () {\n\n                            var element = document.getElementsByClassName('sib-default-btn');\n                            var countInvisible = 0;\n                            var indexArray = [];\n                            jQuery('.sib-default-btn').each(function (index, el) {\n                                if ((jQuery(el).attr('id') == \"invisible\")) {\n                                    indexArray[countInvisible] = index;\n                                    countInvisible++\n                                }\n                            });\n\n                            jQuery('.invi-recaptcha').each(function (index, el) {\n                                grecaptcha.render(element[indexArray[index]], {\n                                    'sitekey': jQuery(el).attr('data-sitekey'),\n                                    'callback': sibVerifyCallback,\n                                });\n                            });\n                        };\n\t\t\t\t\t<\/script>\n\t\t\t\t\t                <script src=\"https:\/\/www.google.com\/recaptcha\/api.js?onload=onloadSibCallbackInvisible&render=explicit\" async defer><\/script>\n\t\t\t\t\n\t\t\t<form id=\"sib_signup_form_1\" method=\"post\" class=\"sib_signup_form\" action=\"\">\n\t\t\t\t<div class=\"sib_loader\" style=\"display:none;\"><img\n\t\t\t\t\t\t\tsrc=\"https:\/\/www.railscarma.com\/wp-includes\/images\/spinner.gif\" alt=\"lastare\"><\/div>\n\t\t\t\t<input type=\"hidden\" name=\"sib_form_action\" value=\"subscribe_form_submit\">\n\t\t\t\t<input type=\"hidden\" name=\"sib_form_id\" value=\"1\">\n                <input type=\"hidden\" name=\"sib_form_alert_notice\" value=\"Please fill out this field\">\n                <input type=\"hidden\" name=\"sib_form_invalid_email_notice\" value=\"Your email address is invalid\">\n                <input type=\"hidden\" name=\"sib_security\" value=\"d7f7626ab9\">\n\t\t\t\t<div class=\"sib_signup_box_inside_1\">\n\t\t\t\t\t<div style=\"\/*display:none*\/\" class=\"sib_msg_disp\">\n\t\t\t\t\t<\/div>\n                                            <div id=\"sib_captcha_invisible\" class=\"invi-recaptcha\" data-sitekey=\"6LdikOAaAAAAAJ6SWrrKVQrtw7TQpQAEnv0HS0G3\"><\/div>\n                    \t\t\t\t\t<p class=\"sib-email-area\">\r\n    <label class=\"sib-email-area\"><\/label>\r\n    <input type=\"email\" class=\"sib-email-area\" name=\"email\" required=\"required\" placeholder=\"E-postadress\">\r\n<\/p>\r\n<p class=\"sib-NAME-area\">\r\n    <label class=\"sib-NAME-area\"><\/label>\r\n    <input type=\"text\" class=\"sib-NAME-area\" name=\"NAME\" placeholder=\"namn\">\r\n<\/p>\r\n<p>\r\n    <input type=\"submit\" id=\"invisible\" class=\"sib-default-btn\" value=\"Prenumerera\">\r\n<\/p>\t\t\t\t<\/div>\n\t\t\t<input type=\"hidden\" name=\"trp-form-language\" value=\"sv\"\/><\/form>\n\t\t\t<style>\n\t\t\t\tform#sib_signup_form_1 p.sib-alert-message {\n    padding: 6px 12px;\n    margin-bottom: 20px;\n    border: 1px solid transparent;\n    border-radius: 4px;\n    -webkit-box-sizing: border-box;\n    -moz-box-sizing: border-box;\n    box-sizing: border-box;\n}\nform#sib_signup_form_1 p.sib-alert-message-error {\n    background-color: #f2dede;\n    border-color: #ebccd1;\n    color: #a94442;\n}\nform#sib_signup_form_1 p.sib-alert-message-success {\n    background-color: #dff0d8;\n    border-color: #d6e9c6;\n    color: #3c763d;\n}\nform#sib_signup_form_1 p.sib-alert-message-warning {\n    background-color: #fcf8e3;\n    border-color: #faebcc;\n    color: #8a6d3b;\n}\n\t\t\t<\/style>\n\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>\n\t\t  <div class=\"related-post slider\">\r\n        <div class=\"headline\">relaterade inl\u00e4gg<\/div>\r\n    <div class=\"post-list owl-carousel\">\r\n\r\n            <div class=\"item\">\r\n            <div class=\"thumb post_thumb\">\r\n    <a  title=\"Kaminari Gem\" href=\"https:\/\/www.railscarma.com\/sv\/blogg\/tekniska-artiklar\/kaminari-parla\/?related_post_from=37277\">\r\n\r\n      <img decoding=\"async\" width=\"800\" height=\"300\" src=\"https:\/\/www.railscarma.com\/wp-content\/uploads\/2023\/04\/kaminari-gem.jpg\" class=\"attachment-full size-full wp-post-image\" alt=\"kaminari p\u00e4rla\" srcset=\"https:\/\/www.railscarma.com\/wp-content\/uploads\/2023\/04\/kaminari-gem.jpg 800w, https:\/\/www.railscarma.com\/wp-content\/uploads\/2023\/04\/kaminari-gem-300x113.jpg 300w, https:\/\/www.railscarma.com\/wp-content\/uploads\/2023\/04\/kaminari-gem-768x288.jpg 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/>\r\n\r\n    <\/a>\r\n  <\/div>\r\n\r\n  <a class=\"title post_title\"  title=\"Kaminari Gem\" href=\"https:\/\/www.railscarma.com\/sv\/blogg\/tekniska-artiklar\/kaminari-parla\/?related_post_from=37277\">\r\n        Kaminari Gem  <\/a>\r\n\r\n        <\/div>\r\n              <div class=\"item\">\r\n            <div class=\"thumb post_thumb\">\r\n    <a  title=\"Varf\u00f6r anst\u00e4lla Ruby on Rails-utvecklare 2026?\" href=\"https:\/\/www.railscarma.com\/sv\/blogg\/ror\/varfor-anlita-utvecklare-av-ruby-on-rails\/?related_post_from=30627\">\r\n\r\n      <img decoding=\"async\" width=\"800\" height=\"300\" src=\"https:\/\/www.railscarma.com\/wp-content\/uploads\/2019\/01\/why-to-hire-ruby-on-rails-developers-in-2022.jpg\" class=\"attachment-full size-full wp-post-image\" alt=\"varf\u00f6r anlita utvecklare av ruby on rails 2022\" srcset=\"https:\/\/www.railscarma.com\/wp-content\/uploads\/2019\/01\/why-to-hire-ruby-on-rails-developers-in-2022.jpg 800w, https:\/\/www.railscarma.com\/wp-content\/uploads\/2019\/01\/why-to-hire-ruby-on-rails-developers-in-2022-300x113.jpg 300w, https:\/\/www.railscarma.com\/wp-content\/uploads\/2019\/01\/why-to-hire-ruby-on-rails-developers-in-2022-768x288.jpg 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/>\r\n\r\n    <\/a>\r\n  <\/div>\r\n\r\n  <a class=\"title post_title\"  title=\"Varf\u00f6r anst\u00e4lla Ruby on Rails-utvecklare 2026?\" href=\"https:\/\/www.railscarma.com\/sv\/blogg\/ror\/varfor-anlita-utvecklare-av-ruby-on-rails\/?related_post_from=30627\">\r\n        Varf\u00f6r anst\u00e4lla Ruby on Rails-utvecklare 2026?  <\/a>\r\n\r\n        <\/div>\r\n              <div class=\"item\">\r\n            <div class=\"thumb post_thumb\">\r\n    <a  title=\"Betydelsen av mjukvaruarkitektur vid utveckling av f\u00f6retagsmjukvara\" href=\"https:\/\/www.railscarma.com\/sv\/blogg\/ror\/vikten-av-mjukvaruarkitektur-i-foretagsutveckling-av-programvara\/?related_post_from=36250\">\r\n\r\n      <img decoding=\"async\" width=\"800\" height=\"300\" src=\"https:\/\/www.railscarma.com\/wp-content\/uploads\/2022\/06\/Importance-of-Software-Architecture-in-enterprise-software-development.jpg\" class=\"attachment-full size-full wp-post-image\" alt=\"Betydelsen av mjukvaruarkitektur vid utveckling av f\u00f6retagsmjukvara\" srcset=\"https:\/\/www.railscarma.com\/wp-content\/uploads\/2022\/06\/Importance-of-Software-Architecture-in-enterprise-software-development.jpg 800w, https:\/\/www.railscarma.com\/wp-content\/uploads\/2022\/06\/Importance-of-Software-Architecture-in-enterprise-software-development-300x113.jpg 300w, https:\/\/www.railscarma.com\/wp-content\/uploads\/2022\/06\/Importance-of-Software-Architecture-in-enterprise-software-development-768x288.jpg 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/>\r\n\r\n    <\/a>\r\n  <\/div>\r\n\r\n  <a class=\"title post_title\"  title=\"Betydelsen av mjukvaruarkitektur vid utveckling av f\u00f6retagsmjukvara\" href=\"https:\/\/www.railscarma.com\/sv\/blogg\/ror\/vikten-av-mjukvaruarkitektur-i-foretagsutveckling-av-programvara\/?related_post_from=36250\">\r\n        Betydelsen av mjukvaruarkitektur vid utveckling av f\u00f6retagsmjukvara  <\/a>\r\n\r\n        <\/div>\r\n              <div class=\"item\">\r\n            <div class=\"thumb post_thumb\">\r\n    <a  title=\"Ruby IDE: De b\u00e4sta IDE:erna f\u00f6r Ruby on Rails Development\" href=\"https:\/\/www.railscarma.com\/sv\/blogg\/ror\/ruby-ide-de-basta-ideerna-for-ruby-on-rails-utveckling\/?related_post_from=36125\">\r\n\r\n      <img decoding=\"async\" width=\"800\" height=\"300\" src=\"https:\/\/www.railscarma.com\/wp-content\/uploads\/2022\/01\/BEST-IDES-FOR-RUBY-ON-RAILS-DEVELOPMENT.jpg\" class=\"attachment-full size-full wp-post-image\" alt=\"B\u00c4STA ID\u00c9ER F\u00d6R UTVECKLING AV RUBY ON RAIL\" srcset=\"https:\/\/www.railscarma.com\/wp-content\/uploads\/2022\/01\/BEST-IDES-FOR-RUBY-ON-RAILS-DEVELOPMENT.jpg 800w, https:\/\/www.railscarma.com\/wp-content\/uploads\/2022\/01\/BEST-IDES-FOR-RUBY-ON-RAILS-DEVELOPMENT-300x113.jpg 300w, https:\/\/www.railscarma.com\/wp-content\/uploads\/2022\/01\/BEST-IDES-FOR-RUBY-ON-RAILS-DEVELOPMENT-768x288.jpg 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/>\r\n\r\n    <\/a>\r\n  <\/div>\r\n\r\n  <a class=\"title post_title\"  title=\"Ruby IDE: De b\u00e4sta IDE:erna f\u00f6r Ruby on Rails Development\" href=\"https:\/\/www.railscarma.com\/sv\/blogg\/ror\/ruby-ide-de-basta-ideerna-for-ruby-on-rails-utveckling\/?related_post_from=36125\">\r\n        Ruby IDE: De b\u00e4sta IDE:erna f\u00f6r Ruby on Rails Development  <\/a>\r\n\r\n        <\/div>\r\n      \r\n  <\/div>\r\n\r\n  <script>\r\n      <\/script>\r\n  <style>\r\n    .related-post {}\r\n\r\n    .related-post .post-list {\r\n      text-align: left;\r\n          }\r\n\r\n    .related-post .post-list .item {\r\n      margin: 10px;\r\n      padding: 10px;\r\n          }\r\n\r\n    .related-post .headline {\r\n      font-size: 14px !important;\r\n      color: #999999 !important;\r\n          }\r\n\r\n    .related-post .post-list .item .post_thumb {\r\n      max-height: 220px;\r\n      margin: 10px 0px;\r\n      padding: 0px;\r\n      display: block;\r\n          }\r\n\r\n    .related-post .post-list .item .post_title {\r\n      font-size: 14px;\r\n      color: #000000;\r\n      margin: 10px 0px;\r\n      padding: 0px;\r\n      display: block;\r\n      text-decoration: none;\r\n          }\r\n\r\n    .related-post .post-list .item .post_excerpt {\r\n      font-size: 12px;\r\n      color: #3f3f3f;\r\n      margin: 10px 0px;\r\n      padding: 0px;\r\n      display: block;\r\n      text-decoration: none;\r\n          }\r\n\r\n    .related-post .owl-dots .owl-dot {\r\n          }\r\n\r\n      <\/style>\r\n      <script>\r\n      jQuery(document).ready(function($) {\r\n        $(\".related-post .post-list\").owlCarousel({\r\n          items: 2,\r\n          responsiveClass: true,\r\n          responsive: {\r\n            0: {\r\n              items: 1,\r\n            },\r\n            768: {\r\n              items: 2,\r\n            },\r\n            1200: {\r\n              items: 2,\r\n            }\r\n          },\r\n                      rewind: true,\r\n                                loop: true,\r\n                                center: false,\r\n                                autoplay: true,\r\n            autoplayHoverPause: true,\r\n                                nav: true,\r\n            navSpeed: 1000,\r\n            navText: ['<i class=\"fas fa-chevron-left\"><\/i>', '<i class=\"fas fa-chevron-right\"><\/i>'],\r\n                                dots: false,\r\n            dotsSpeed: 1200,\r\n                                                    rtl: false,\r\n          \r\n        });\r\n      });\r\n    <\/script>\r\n  <\/div>","protected":false},"excerpt":{"rendered":"<p>Have you ever opened a closet only to have all the inside contents fall all over you? In the programming setting, this is called as \u201cspaghetti code\u201d. These are the kind of codes that are so jumbled that as soon as you make a little change, everything starts falling apart. As much as it is &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"https:\/\/www.railscarma.com\/sv\/blogg\/ruby-regex-match-guide-with-examples\/\"> <span class=\"screen-reader-text\">Ruby Regex Match Guide (2026) med exempel<\/span> L\u00e4s mer \u00bb<\/a><\/p>","protected":false},"author":1,"featured_media":31937,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[384],"tags":[665,572],"class_list":["post-7773","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technical-articles","tag-bullet-gem","tag-gem"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Get More Out of Queries in Rails Using Bullet in Just 3 Steps<\/title>\n<meta name=\"description\" content=\"It is recommended to use third party tools like Bullet Gem for the maintenance, security and optimization of codes.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.railscarma.com\/sv\/blogg\/tekniska-artiklar\/get-more-out-of-queries-in-rails-using-bullet-in-just-3-steps\/\" \/>\n<meta property=\"og:locale\" content=\"sv_SE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Get More Out of Queries in Rails Using Bullet in Just 3 Steps\" \/>\n<meta property=\"og:description\" content=\"It is recommended to use third party tools like Bullet Gem for the maintenance, security and optimization of codes.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.railscarma.com\/sv\/blogg\/tekniska-artiklar\/get-more-out-of-queries-in-rails-using-bullet-in-just-3-steps\/\" \/>\n<meta property=\"og:site_name\" content=\"RailsCarma - Ruby on Rails Development Company specializing in Offshore Development\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/RailsCarma\/\" \/>\n<meta property=\"article:published_time\" content=\"2016-03-30T11:45:23+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-06-06T12:30:08+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.railscarma.com\/wp-content\/uploads\/2016\/03\/rc.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"800\" \/>\n\t<meta property=\"og:image:height\" content=\"300\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@railscarma\" \/>\n<meta name=\"twitter:site\" content=\"@railscarma\" \/>\n<meta name=\"twitter:label1\" content=\"Skriven av\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Ber\u00e4knad l\u00e4stid\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minuter\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.railscarma.com\/de\/blog\/technical-articles\/holen-sie-mit-bullet-in-nur-3-schritten-mehr-aus-abfragen-in-rails-heraus\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.railscarma.com\/de\/blog\/technical-articles\/holen-sie-mit-bullet-in-nur-3-schritten-mehr-aus-abfragen-in-rails-heraus\/\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\/\/www.railscarma.com\/#\/schema\/person\/5f2228a2dec7549056e709de6eb85d21\"},\"headline\":\"Get More Out of Queries in Rails Using Bullet in Just 3 Steps\",\"datePublished\":\"2016-03-30T11:45:23+00:00\",\"dateModified\":\"2021-06-06T12:30:08+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.railscarma.com\/de\/blog\/technical-articles\/holen-sie-mit-bullet-in-nur-3-schritten-mehr-aus-abfragen-in-rails-heraus\/\"},\"wordCount\":770,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.railscarma.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.railscarma.com\/de\/blog\/technical-articles\/holen-sie-mit-bullet-in-nur-3-schritten-mehr-aus-abfragen-in-rails-heraus\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.railscarma.com\/wp-content\/uploads\/2016\/03\/rc.jpg\",\"keywords\":[\"bullet gem\",\"gem\"],\"articleSection\":[\"Technical Articles\"],\"inLanguage\":\"sv-SE\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.railscarma.com\/de\/blog\/technical-articles\/holen-sie-mit-bullet-in-nur-3-schritten-mehr-aus-abfragen-in-rails-heraus\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.railscarma.com\/de\/blog\/technical-articles\/holen-sie-mit-bullet-in-nur-3-schritten-mehr-aus-abfragen-in-rails-heraus\/\",\"url\":\"https:\/\/www.railscarma.com\/de\/blog\/technical-articles\/holen-sie-mit-bullet-in-nur-3-schritten-mehr-aus-abfragen-in-rails-heraus\/\",\"name\":\"Get More Out of Queries in Rails Using Bullet in Just 3 Steps\",\"isPartOf\":{\"@id\":\"https:\/\/www.railscarma.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.railscarma.com\/de\/blog\/technical-articles\/holen-sie-mit-bullet-in-nur-3-schritten-mehr-aus-abfragen-in-rails-heraus\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.railscarma.com\/de\/blog\/technical-articles\/holen-sie-mit-bullet-in-nur-3-schritten-mehr-aus-abfragen-in-rails-heraus\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.railscarma.com\/wp-content\/uploads\/2016\/03\/rc.jpg\",\"datePublished\":\"2016-03-30T11:45:23+00:00\",\"dateModified\":\"2021-06-06T12:30:08+00:00\",\"description\":\"It is recommended to use third party tools like Bullet Gem for the maintenance, security and optimization of codes.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.railscarma.com\/de\/blog\/technical-articles\/holen-sie-mit-bullet-in-nur-3-schritten-mehr-aus-abfragen-in-rails-heraus\/#breadcrumb\"},\"inLanguage\":\"sv-SE\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.railscarma.com\/de\/blog\/technical-articles\/holen-sie-mit-bullet-in-nur-3-schritten-mehr-aus-abfragen-in-rails-heraus\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"sv-SE\",\"@id\":\"https:\/\/www.railscarma.com\/de\/blog\/technical-articles\/holen-sie-mit-bullet-in-nur-3-schritten-mehr-aus-abfragen-in-rails-heraus\/#primaryimage\",\"url\":\"https:\/\/www.railscarma.com\/wp-content\/uploads\/2016\/03\/rc.jpg\",\"contentUrl\":\"https:\/\/www.railscarma.com\/wp-content\/uploads\/2016\/03\/rc.jpg\",\"width\":800,\"height\":300},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.railscarma.com\/de\/blog\/technical-articles\/holen-sie-mit-bullet-in-nur-3-schritten-mehr-aus-abfragen-in-rails-heraus\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.railscarma.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Get More Out of Queries in Rails Using Bullet in Just 3 Steps\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.railscarma.com\/#website\",\"url\":\"https:\/\/www.railscarma.com\/\",\"name\":\"RailsCarma - Ruby on Rails Development Company specializing in Offshore Development\",\"description\":\"RailsCarma is a Ruby on Rails Development Company in Bangalore. We specialize in Offshore Ruby on Rails Development based out in USA and India. Hire experienced Ruby on Rails developers for the ultimate Web Experience.\",\"publisher\":{\"@id\":\"https:\/\/www.railscarma.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.railscarma.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"sv-SE\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.railscarma.com\/#organization\",\"name\":\"RailsCarma\",\"url\":\"https:\/\/www.railscarma.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"sv-SE\",\"@id\":\"https:\/\/www.railscarma.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.railscarma.com\/wp-content\/uploads\/2020\/08\/railscarma_logo.png\",\"contentUrl\":\"https:\/\/www.railscarma.com\/wp-content\/uploads\/2020\/08\/railscarma_logo.png\",\"width\":200,\"height\":46,\"caption\":\"RailsCarma\"},\"image\":{\"@id\":\"https:\/\/www.railscarma.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/RailsCarma\/\",\"https:\/\/x.com\/railscarma\",\"https:\/\/www.linkedin.com\/company\/railscarma\/\",\"https:\/\/myspace.com\/railscarma\",\"https:\/\/in.pinterest.com\/railscarma\/\",\"https:\/\/www.youtube.com\/channel\/UCx3Wil-aAnDARuatTEyMdpg\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.railscarma.com\/#\/schema\/person\/5f2228a2dec7549056e709de6eb85d21\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"sv-SE\",\"@id\":\"https:\/\/www.railscarma.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/308867ca6c81f3aba146080c601000087180326f752c4116849ea9f514c6a4fa?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/308867ca6c81f3aba146080c601000087180326f752c4116849ea9f514c6a4fa?s=96&d=mm&r=g\",\"caption\":\"admin\"},\"sameAs\":[\"https:\/\/www.railscarma.com\/hire-ruby-on-rails-developer\/\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Get More Out of Queries in Rails Using Bullet in Just 3 Steps","description":"It is recommended to use third party tools like Bullet Gem for the maintenance, security and optimization of codes.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.railscarma.com\/sv\/blogg\/tekniska-artiklar\/get-more-out-of-queries-in-rails-using-bullet-in-just-3-steps\/","og_locale":"sv_SE","og_type":"article","og_title":"Get More Out of Queries in Rails Using Bullet in Just 3 Steps","og_description":"It is recommended to use third party tools like Bullet Gem for the maintenance, security and optimization of codes.","og_url":"https:\/\/www.railscarma.com\/sv\/blogg\/tekniska-artiklar\/get-more-out-of-queries-in-rails-using-bullet-in-just-3-steps\/","og_site_name":"RailsCarma - Ruby on Rails Development Company specializing in Offshore Development","article_publisher":"https:\/\/www.facebook.com\/RailsCarma\/","article_published_time":"2016-03-30T11:45:23+00:00","article_modified_time":"2021-06-06T12:30:08+00:00","og_image":[{"width":800,"height":300,"url":"https:\/\/www.railscarma.com\/wp-content\/uploads\/2016\/03\/rc.jpg","type":"image\/jpeg"}],"author":"admin","twitter_card":"summary_large_image","twitter_creator":"@railscarma","twitter_site":"@railscarma","twitter_misc":{"Skriven av":"admin","Ber\u00e4knad l\u00e4stid":"4 minuter"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.railscarma.com\/de\/blog\/technical-articles\/holen-sie-mit-bullet-in-nur-3-schritten-mehr-aus-abfragen-in-rails-heraus\/#article","isPartOf":{"@id":"https:\/\/www.railscarma.com\/de\/blog\/technical-articles\/holen-sie-mit-bullet-in-nur-3-schritten-mehr-aus-abfragen-in-rails-heraus\/"},"author":{"name":"admin","@id":"https:\/\/www.railscarma.com\/#\/schema\/person\/5f2228a2dec7549056e709de6eb85d21"},"headline":"Get More Out of Queries in Rails Using Bullet in Just 3 Steps","datePublished":"2016-03-30T11:45:23+00:00","dateModified":"2021-06-06T12:30:08+00:00","mainEntityOfPage":{"@id":"https:\/\/www.railscarma.com\/de\/blog\/technical-articles\/holen-sie-mit-bullet-in-nur-3-schritten-mehr-aus-abfragen-in-rails-heraus\/"},"wordCount":770,"commentCount":0,"publisher":{"@id":"https:\/\/www.railscarma.com\/#organization"},"image":{"@id":"https:\/\/www.railscarma.com\/de\/blog\/technical-articles\/holen-sie-mit-bullet-in-nur-3-schritten-mehr-aus-abfragen-in-rails-heraus\/#primaryimage"},"thumbnailUrl":"https:\/\/www.railscarma.com\/wp-content\/uploads\/2016\/03\/rc.jpg","keywords":["bullet gem","gem"],"articleSection":["Technical Articles"],"inLanguage":"sv-SE","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.railscarma.com\/de\/blog\/technical-articles\/holen-sie-mit-bullet-in-nur-3-schritten-mehr-aus-abfragen-in-rails-heraus\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.railscarma.com\/de\/blog\/technical-articles\/holen-sie-mit-bullet-in-nur-3-schritten-mehr-aus-abfragen-in-rails-heraus\/","url":"https:\/\/www.railscarma.com\/de\/blog\/technical-articles\/holen-sie-mit-bullet-in-nur-3-schritten-mehr-aus-abfragen-in-rails-heraus\/","name":"Get More Out of Queries in Rails Using Bullet in Just 3 Steps","isPartOf":{"@id":"https:\/\/www.railscarma.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.railscarma.com\/de\/blog\/technical-articles\/holen-sie-mit-bullet-in-nur-3-schritten-mehr-aus-abfragen-in-rails-heraus\/#primaryimage"},"image":{"@id":"https:\/\/www.railscarma.com\/de\/blog\/technical-articles\/holen-sie-mit-bullet-in-nur-3-schritten-mehr-aus-abfragen-in-rails-heraus\/#primaryimage"},"thumbnailUrl":"https:\/\/www.railscarma.com\/wp-content\/uploads\/2016\/03\/rc.jpg","datePublished":"2016-03-30T11:45:23+00:00","dateModified":"2021-06-06T12:30:08+00:00","description":"It is recommended to use third party tools like Bullet Gem for the maintenance, security and optimization of codes.","breadcrumb":{"@id":"https:\/\/www.railscarma.com\/de\/blog\/technical-articles\/holen-sie-mit-bullet-in-nur-3-schritten-mehr-aus-abfragen-in-rails-heraus\/#breadcrumb"},"inLanguage":"sv-SE","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.railscarma.com\/de\/blog\/technical-articles\/holen-sie-mit-bullet-in-nur-3-schritten-mehr-aus-abfragen-in-rails-heraus\/"]}]},{"@type":"ImageObject","inLanguage":"sv-SE","@id":"https:\/\/www.railscarma.com\/de\/blog\/technical-articles\/holen-sie-mit-bullet-in-nur-3-schritten-mehr-aus-abfragen-in-rails-heraus\/#primaryimage","url":"https:\/\/www.railscarma.com\/wp-content\/uploads\/2016\/03\/rc.jpg","contentUrl":"https:\/\/www.railscarma.com\/wp-content\/uploads\/2016\/03\/rc.jpg","width":800,"height":300},{"@type":"BreadcrumbList","@id":"https:\/\/www.railscarma.com\/de\/blog\/technical-articles\/holen-sie-mit-bullet-in-nur-3-schritten-mehr-aus-abfragen-in-rails-heraus\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.railscarma.com\/"},{"@type":"ListItem","position":2,"name":"Get More Out of Queries in Rails Using Bullet in Just 3 Steps"}]},{"@type":"WebSite","@id":"https:\/\/www.railscarma.com\/#website","url":"https:\/\/www.railscarma.com\/","name":"RailsCarma - Ruby on Rails Development Company specialiserat p\u00e5 Offshore Development","description":"RailsCarma \u00e4r ett Ruby on Rails Development Company i Bangalore. Vi \u00e4r specialiserade p\u00e5 Offshore Ruby on Rails Development baserat i USA och Indien. Anst\u00e4ll erfarna Ruby on Rails-utvecklare f\u00f6r den ultimata webbupplevelsen.","publisher":{"@id":"https:\/\/www.railscarma.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.railscarma.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"sv-SE"},{"@type":"Organization","@id":"https:\/\/www.railscarma.com\/#organization","name":"RailsCarma","url":"https:\/\/www.railscarma.com\/","logo":{"@type":"ImageObject","inLanguage":"sv-SE","@id":"https:\/\/www.railscarma.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.railscarma.com\/wp-content\/uploads\/2020\/08\/railscarma_logo.png","contentUrl":"https:\/\/www.railscarma.com\/wp-content\/uploads\/2020\/08\/railscarma_logo.png","width":200,"height":46,"caption":"RailsCarma"},"image":{"@id":"https:\/\/www.railscarma.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/RailsCarma\/","https:\/\/x.com\/railscarma","https:\/\/www.linkedin.com\/company\/railscarma\/","https:\/\/myspace.com\/railscarma","https:\/\/in.pinterest.com\/railscarma\/","https:\/\/www.youtube.com\/channel\/UCx3Wil-aAnDARuatTEyMdpg"]},{"@type":"Person","@id":"https:\/\/www.railscarma.com\/#\/schema\/person\/5f2228a2dec7549056e709de6eb85d21","name":"administration","image":{"@type":"ImageObject","inLanguage":"sv-SE","@id":"https:\/\/www.railscarma.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/308867ca6c81f3aba146080c601000087180326f752c4116849ea9f514c6a4fa?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/308867ca6c81f3aba146080c601000087180326f752c4116849ea9f514c6a4fa?s=96&d=mm&r=g","caption":"admin"},"sameAs":["https:\/\/www.railscarma.com\/hire-ruby-on-rails-developer\/"]}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.railscarma.com\/sv\/wp-json\/wp\/v2\/posts\/7773","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.railscarma.com\/sv\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.railscarma.com\/sv\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.railscarma.com\/sv\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.railscarma.com\/sv\/wp-json\/wp\/v2\/comments?post=7773"}],"version-history":[{"count":0,"href":"https:\/\/www.railscarma.com\/sv\/wp-json\/wp\/v2\/posts\/7773\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.railscarma.com\/sv\/wp-json\/wp\/v2\/media\/31937"}],"wp:attachment":[{"href":"https:\/\/www.railscarma.com\/sv\/wp-json\/wp\/v2\/media?parent=7773"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.railscarma.com\/sv\/wp-json\/wp\/v2\/categories?post=7773"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.railscarma.com\/sv\/wp-json\/wp\/v2\/tags?post=7773"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}