久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    <small id='nepMR'></small><noframes id='nepMR'>

  1. <i id='nepMR'><tr id='nepMR'><dt id='nepMR'><q id='nepMR'><span id='nepMR'><b id='nepMR'><form id='nepMR'><ins id='nepMR'></ins><ul id='nepMR'></ul><sub id='nepMR'></sub></form><legend id='nepMR'></legend><bdo id='nepMR'><pre id='nepMR'><center id='nepMR'></center></pre></bdo></b><th id='nepMR'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='nepMR'><tfoot id='nepMR'></tfoot><dl id='nepMR'><fieldset id='nepMR'></fieldset></dl></div>

      <legend id='nepMR'><style id='nepMR'><dir id='nepMR'><q id='nepMR'></q></dir></style></legend>
        <bdo id='nepMR'></bdo><ul id='nepMR'></ul>
    1. <tfoot id='nepMR'></tfoot>

    2. 在 Rails 中使用特定的 mysql 索引

      Use specific mysql index with rails(在 Rails 中使用特定的 mysql 索引)
        • <bdo id='rCVng'></bdo><ul id='rCVng'></ul>
          <i id='rCVng'><tr id='rCVng'><dt id='rCVng'><q id='rCVng'><span id='rCVng'><b id='rCVng'><form id='rCVng'><ins id='rCVng'></ins><ul id='rCVng'></ul><sub id='rCVng'></sub></form><legend id='rCVng'></legend><bdo id='rCVng'><pre id='rCVng'><center id='rCVng'></center></pre></bdo></b><th id='rCVng'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='rCVng'><tfoot id='rCVng'></tfoot><dl id='rCVng'><fieldset id='rCVng'></fieldset></dl></div>

              <small id='rCVng'></small><noframes id='rCVng'>

            1. <legend id='rCVng'><style id='rCVng'><dir id='rCVng'><q id='rCVng'></q></dir></style></legend>
                <tbody id='rCVng'></tbody>
              <tfoot id='rCVng'></tfoot>

                本文介紹了在 Rails 中使用特定的 mysql 索引的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                限時送ChatGPT賬號..

                我有這個 ActiveRecord 查詢

                I have this ActiveRecord query

                issue = Issue.find(id)
                issue.articles.includes(:category).merge(Category.where(permalink: perma))
                

                翻譯成mysql查詢

                SELECT `articles`.`id` AS t0_r0, `articles`.`title` AS t0_r1, 
                       `articles`.`hypertitle` AS t0_r2, `articles`.`html` AS t0_r3,
                       `articles`.`author` AS t0_r4, `articles`.`published` AS t0_r5,
                       `articles`.`category_id` AS t0_r6, `articles`.`issue_id` AS t0_r7,
                       `articles`.`date` AS t0_r8, `articles`.`created_at` AS t0_r9, 
                       `articles`.`updated_at` AS t0_r10, `articles`.`photo_file_name` AS t0_r11,
                       `articles`.`photo_content_type` AS t0_r12, `articles`.`photo_file_size` AS t0_r13,
                       `articles`.`photo_updated_at` AS t0_r14, `categories`.`id` AS t1_r0,
                       `categories`.`name` AS t1_r1, `categories`.`permalink` AS t1_r2,
                       `categories`.`created_at` AS t1_r3, `categories`.`updated_at` AS t1_r4,
                       `categories`.`issued` AS t1_r5, `categories`.`order_articles` AS t1_r6 
                        FROM `articles` LEFT OUTER JOIN `categories` ON 
                       `categories`.`id` = `articles`.`category_id` WHERE 
                       `articles`.`issue_id` = 409 AND `categories`.`permalink` = 'Διεθν?' LIMIT 1
                

                在這個查詢的解釋中,我看到使用了錯誤的索引

                In the explation of this query I saw that uses wrong index

                +----+-------------+------------+-------+---------------------------------------------------------------------------+-------------------------------+---------+-------+------+----------+-------------+
                | id | select_type | table      | type  | possible_keys                                                             | key                           | key_len | ref   | rows | filtered | Extra       |
                +----+-------------+------------+-------+---------------------------------------------------------------------------+-------------------------------+---------+-------+------+----------+-------------+
                |  1 | SIMPLE      | categories | const | PRIMARY,index_categories_on_permalink                                     | index_categories_on_permalink | 768     | const |    1 |   100.00 |             |
                |  1 | SIMPLE      | articles   | ref   | index_articles_on_issue_id_and_category_id, index_articles_on_category_id | index_articles_on_category_id | 2       | const |   10 |   100.05 | Using where |
                +----+-------------+------------+-------+---------------------------------------------------------------------------+-------------------------------+---------+-------+------+----------+-------------+
                

                我有兩個索引,category_idissue_id - category_id.

                I have two indexes, category_id alone and issue_id - category_id.

                在此查詢中,我使用 issue_idcategory_id 進行搜索,使用 index_articles_on_issue_id_and_category_idindex_articles_on_category_id.

                In this query I'm searching with issue_id and category_id which is much faster when using the index_articles_on_issue_id_and_category_id than the index_articles_on_category_id.

                如何通過活動記錄查詢選擇正確的索引?

                How can I select the correct index with active record query?

                推薦答案

                你可以像這樣方便使用索引:

                You can facilitate arel like so to use an index:

                 class Issue
                   def self.use_index(index)
                     # update: OP fixed my mistake
                     from("#{self.table_name} USE INDEX(#{index})")
                   end
                 end
                
                 # then
                 Issue.use_index("bla").where(some_condition: true)
                

                這篇關于在 Rails 中使用特定的 mysql 索引的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                SQL query to get all products, categories and meta data woocommerce/wordpress(獲取所有產品、類別和元數據的 SQL 查詢 woocommerce/wordpress)
                How to use MySQL in WSL (Windows Subsystem for Linux)?(如何在 WSL(Linux 的 Windows 子系統)中使用 MySQL?)
                PowerShell MySQL Backup Script Error in Task Scheduler 0x00041301(任務計劃程序中的 PowerShell MySQL 備份腳本錯誤 0x00041301)
                Import the data from the XML files into a MySQL database(將數據從 XML 文件導入 MySQL 數據庫)
                installed Xampp on Windows 7 32-bit. Errors when starting(在 Windows 7 32 位上安裝 Xampp.啟動時的錯誤)
                Mysql lower case table on Windows xampp(Windows xampp 上的 Mysql 小寫表)
                <tfoot id='xLf3M'></tfoot>

                  <bdo id='xLf3M'></bdo><ul id='xLf3M'></ul>

                  <small id='xLf3M'></small><noframes id='xLf3M'>

                    <tbody id='xLf3M'></tbody>

                        • <legend id='xLf3M'><style id='xLf3M'><dir id='xLf3M'><q id='xLf3M'></q></dir></style></legend>
                          <i id='xLf3M'><tr id='xLf3M'><dt id='xLf3M'><q id='xLf3M'><span id='xLf3M'><b id='xLf3M'><form id='xLf3M'><ins id='xLf3M'></ins><ul id='xLf3M'></ul><sub id='xLf3M'></sub></form><legend id='xLf3M'></legend><bdo id='xLf3M'><pre id='xLf3M'><center id='xLf3M'></center></pre></bdo></b><th id='xLf3M'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='xLf3M'><tfoot id='xLf3M'></tfoot><dl id='xLf3M'><fieldset id='xLf3M'></fieldset></dl></div>
                          主站蜘蛛池模板: 国产福利一区二区 | 久久国产精品一区二区三区 | 亚洲国产精品99久久久久久久久 | 一级片在线观看 | 成人国产精品色哟哟 | 日干夜操 | 中文在线a在线 | 日韩精品免费视频 | 国产精品美女久久久久aⅴ国产馆 | 成人免费小视频 | 自拍 亚洲 欧美 老师 丝袜 | 久久新| 中文字幕 欧美 日韩 | 色吧久久 | 九九国产在线观看 | 免费色网址 | 欧洲亚洲一区二区三区 | 伊久在线| 亚洲国产一区在线 | 国产精品久久精品 | 亚洲精品乱码久久久久久按摩观 | 狠狠躁夜夜躁人人爽天天高潮 | 国产精品视频在线播放 | 精品久久久久久 | 久久久99国产精品免费 | 国产成人在线视频免费观看 | 日韩欧美在线一区 | www.亚洲免费| 国外成人在线视频网站 | 精品国产乱码久久久久久a丨 | 日本一二三区电影 | 亚洲国产一区二区三区 | 日韩一区二区在线视频 | 免费av手机在线观看 | 欧美另类视频在线 | 国产成人精品一区二区在线 | 亚洲欧洲一区二区 | 国产激情综合五月久久 | 性欧美xxxx| 一区二区三区视频免费观看 | 夜夜爽99久久国产综合精品女不卡 |