<span id="mktg5"></span>

<i id="mktg5"><meter id="mktg5"></meter></i>

        <label id="mktg5"><meter id="mktg5"></meter></label>
        最新文章專題視頻專題問答1問答10問答100問答1000問答2000關(guān)鍵字專題1關(guān)鍵字專題50關(guān)鍵字專題500關(guān)鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關(guān)鍵字專題關(guān)鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
        問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
        當(dāng)前位置: 首頁 - 科技 - 知識(shí)百科 - 正文

        What'snewinEdgeRails:EXPLAIN

        來源:懂視網(wǎng) 責(zé)編:小采 時(shí)間:2020-11-09 13:16:49
        文檔

        What'snewinEdgeRails:EXPLAIN

        What'snewinEdgeRails:EXPLAIN:What's new in Edge Rails: EXPLAIN: There are some new features related to EXPLAIN in the forthcoming Ruby on Rails 3.2 we'd like to share: Running EXPLAIN manually Automatic EXPLAIN for slow queries Silencing automatic EXPLAIN As of this w
        推薦度:
        導(dǎo)讀What'snewinEdgeRails:EXPLAIN:What's new in Edge Rails: EXPLAIN: There are some new features related to EXPLAIN in the forthcoming Ruby on Rails 3.2 we'd like to share: Running EXPLAIN manually Automatic EXPLAIN for slow queries Silencing automatic EXPLAIN As of this w

        What's new in Edge Rails: EXPLAIN: There are some new features related to EXPLAIN in the forthcoming Ruby on Rails 3.2 we'd like to share: Running EXPLAIN manually Automatic EXPLAIN for slow queries Silencing automatic EXPLAIN As of this w

        What's new in Edge Rails: EXPLAIN:
        There are some new features related to EXPLAIN in the forthcoming Ruby on Rails 3.2 we'd like
        to share:

      1. Running EXPLAIN manually
      2. Automatic EXPLAIN for slow queries
      3. Silencing automatic EXPLAIN
      4. As of this writing they are available for the adapters sqlite3, mysql2, and postgresql.

        Running EXPLAIN Manually

        You can now run EXPLAIN on the SQL generated by a relation this way:

        User.where(:id => 1).joins(:posts).explain
        The result of that method call is a string that carefully imitates the output of database shells.


        Please note that explain runs the query or queries and asks the database for their respective query plan afterwards. This is because due to eager loading a relation may trigger several queries to fetch the records and their associations, and in such cases some queries need the result of the previous ones.


        If the relation triggers several queries the method still returns a single string with all the query plans. This is an output meant for human consumption so we preferred to present everything as a string in a format which is familiar right away rather than a structure.


        Automatic EXPLAIN For Slow Queries

        Rails 3.2 has the ability to help in detecting slow queries.

        New applications get

        config.active_record.auto_explain_threshold_in_seconds = 0.5

        in config/environments/development.rb. Active Record monitors queries and if they take more than that threshold their query plan will be logged using warn.


        That works for anything running find_by_sql (which is almost everything, since most of Active Record ends up calling that method). In the particular case of relations, the threshold is compared against the total time needed to fetch the records, not against the time taken by each individual query. Because conceptually we are concerned with the cost of the call

        User.where(:id => 1).joins(:posts).explain

        rather than the cost of the different queries that call may trigger due to the implementation.

        By default the threshold is nil in the test and production environments, which means the feature is disabled.


        The value of that parameter is nil also if the threshold is not set, so existing applications will need to add it by hand if they migrate to 3.2 to be able to enable automatic EXPLAIN.

        Silencing Automatic EXPLAIN

        With automatic EXPLAIN enabled, it could still be the case that some queries are just slow and you know they have to be. For example, a heavyweight report in the backoffice.

        The macro silence_auto_explain allows you to avoid having EXPLAIN run repeatedly in those areas of code:


        ActiveRecord::Base.silence_auto_explain do
         # no automatic EXPLAIN here
        end

        Interpreting Query Plans

        The interpretation of the query plans is another topic, these are some pointers:
      5. SQLite: EXPLAIN QUERY PLAN
      6. MySQL: EXPLAIN Output Format
      7. PostgreSQL: Using EXPLAIN
      8. Happy debugging!

        聲明:本網(wǎng)頁內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問題請及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

        文檔

        What'snewinEdgeRails:EXPLAIN

        What'snewinEdgeRails:EXPLAIN:What's new in Edge Rails: EXPLAIN: There are some new features related to EXPLAIN in the forthcoming Ruby on Rails 3.2 we'd like to share: Running EXPLAIN manually Automatic EXPLAIN for slow queries Silencing automatic EXPLAIN As of this w
        推薦度:
        標(biāo)簽: EDGE new what
        • 熱門焦點(diǎn)

        最新推薦

        猜你喜歡

        熱門推薦

        專題
        Top
        主站蜘蛛池模板: 亚洲精品视频免费| 亚洲中文无码亚洲人成影院| 国产偷国产偷亚洲高清在线| 成人奭片免费观看| 2020久久精品亚洲热综合一本| 嫩草成人永久免费观看| 亚洲AV日韩AV永久无码免下载| 在线观看免费黄网站| 亚洲av无码片在线播放| 国产情侣久久久久aⅴ免费| 亚洲AV无码国产丝袜在线观看 | yy6080久久亚洲精品| 国产成人亚洲午夜电影| 波多野结衣一区二区免费视频| 国产精品亚洲综合| 亚洲一本大道无码av天堂| 99视频在线观看免费| 7777久久亚洲中文字幕蜜桃| 一色屋成人免费精品网站| 亚洲丶国产丶欧美一区二区三区| 国产在线观看免费完整版中文版 | 亚洲精品在线播放视频| 久久精品无码一区二区三区免费| 亚洲国产日韩视频观看| 手机看片久久国产免费| 丝袜足液精子免费视频| 亚洲日本在线播放| 国产精品免费看久久久无码| 国产免费MV大全视频网站| 久久亚洲私人国产精品vA| 亚洲第一成年免费网站| 曰批全过程免费视频观看免费软件| 国产亚洲精品无码拍拍拍色欲| 久章草在线精品视频免费观看| 亚洲一卡2卡4卡5卡6卡在线99| 免费在线观看亚洲| 免费在线观看一级片| 亚洲精品无码成人片久久不卡| 亚洲午夜无码片在线观看影院猛| 97在线视频免费| 特级毛片A级毛片免费播放|