pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

    <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="awwquea" 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="w2wek2q" 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 索引的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                問(wèn)題描述

                限時(shí)送ChatGPT賬號(hào)..

                我有這個(gè) 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
                

                在這個(gè)查詢的解釋中,我看到使用了錯(cuò)誤的索引

                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 |
                +----+-------------+------------+-------+---------------------------------------------------------------------------+-------------------------------+---------+-------+------+----------+-------------+
                

                我有兩個(gè)索引,category_idissue_id - category_id.

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

                在此查詢中,我使用 issue_idcategory_id 進(jìn)行搜索,使用 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.

                如何通過(guò)活動(dòng)記錄查詢選擇正確的索引?

                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)
                

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

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

                相關(guān)文檔推薦

                SQL query to get all products, categories and meta data woocommerce/wordpress(獲取所有產(chǎn)品、類別和元數(shù)據(jù)的 SQL 查詢 woocommerce/wordpress)
                How to use MySQL in WSL (Windows Subsystem for Linux)?(如何在 WSL(Linux 的 Windows 子系統(tǒng))中使用 MySQL?)
                PowerShell MySQL Backup Script Error in Task Scheduler 0x00041301(任務(wù)計(jì)劃程序中的 PowerShell MySQL 備份腳本錯(cuò)誤 0x00041301)
                Import the data from the XML files into a MySQL database(將數(shù)據(jù)從 XML 文件導(dǎo)入 MySQL 數(shù)據(jù)庫(kù))
                installed Xampp on Windows 7 32-bit. Errors when starting(在 Windows 7 32 位上安裝 Xampp.啟動(dòng)時(shí)的錯(cuò)誤)
                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="y2gmmgc" id='xLf3M'><tfoot id='xLf3M'></tfoot><dl id='xLf3M'><fieldset id='xLf3M'></fieldset></dl></div>
                          主站蜘蛛池模板: 重庆监控_电子围栏设备安装公司_门禁停车场管理系统-劲浪科技公司 | 合肥触摸一体机_触摸查询机厂家_合肥拼接屏-安徽迅博智能科技 | 耐破强度测试仪-纸箱破裂强度试验机-济南三泉中石单品站 | 筛分机|振动筛分机|气流筛分机|筛分机厂家-新乡市大汉振动机械有限公司 | 阁楼货架_阁楼平台_仓库仓储设备_重型货架_广州金铁牛货架厂 | 成都思迪机电技术研究所-四川成都思迪编码器 | 耐磨陶瓷管道_除渣器厂家-淄博浩瀚陶瓷科技有限公司 | 一路商机网-品牌招商加盟优选平台-加盟店排行榜平台 | 南京泽朗生物科技有限公司-液体饮料代加工_果汁饮料代加工_固体饮料代加工 | 郑州墨香品牌设计公司|品牌全案VI设计公司 | DDoS安全防护官网-领先的DDoS安全防护服务商 | 新疆系统集成_新疆系统集成公司_系统集成项目-新疆利成科技 | 铣刨料沥青破碎机-沥青再生料设备-RAP热再生混合料破碎筛分设备 -江苏锡宝重工 | 【甲方装饰】合肥工装公司-合肥装修设计公司,专业从事安徽办公室、店面、售楼部、餐饮店、厂房装修设计服务 | 湖南教师资格网-湖南教师资格证考试网 | 吲哚菁绿衍生物-酶底物法大肠菌群检测试剂-北京和信同通科技发展有限公司 | 致胜管家软件服务【在线免费体验】 | 拉力机-拉力试验机-万能试验机-电子拉力机-拉伸试验机-剥离强度试验机-苏州皖仪实验仪器有限公司 | 浙江建筑资质代办_二级房建_市政_电力_安许_劳务资质办理公司 | 四川职高信息网-初高中、大专、职业技术学校招生信息网 | 中矗模型-深圳中矗模型设计有限公司| 金库门,金库房,金库门厂家,金库门价格-河北特旺柜业有限公司 | 活动策划,舞台搭建,活动策划公司-首选美湖上海活动策划公司 | 针焰试验仪,灼热丝试验仪,漏电起痕试验仪,水平垂直燃烧试验仪 - 苏州亚诺天下仪器有限公司 | 山东聚盛新型材料有限公司-纳米防腐隔热彩铝板和纳米防腐隔热板以及钛锡板、PVDF氟膜板供应商 | 恒温水槽与水浴锅-上海熙浩实业有限公司 | 西安展台设计搭建_西安活动策划公司_西安会议会场布置_西安展厅设计西安旭阳展览展示 | 天品互联-北京APP开发公司-小程序开发制作-软件开发 | 线粒体膜电位荧光探针-细胞膜-标记二抗-上海复申生物科技有限公司 | 大型冰雕-景区冰雕展制作公司,3D创意设计源头厂家-[赛北冰雕] | 杭州可当科技有限公司—流量卡_随身WiFi_AI摄像头一站式解决方案 | 翰墨AI智能写作助手官网_人工智能问答在线AI写作免费一键生成 | 垃圾处理设备_餐厨垃圾处理设备_厨余垃圾处理设备_果蔬垃圾处理设备-深圳市三盛环保科技有限公司 | 安平县鑫川金属丝网制品有限公司,声屏障,高速声屏障,百叶孔声屏障,大弧形声屏障,凹凸穿孔声屏障,铁路声屏障,顶部弧形声屏障,玻璃钢吸音板 | 多物理场仿真软件_电磁仿真软件_EDA多物理场仿真软件 - 裕兴木兰 | 实验室隔膜泵-无油防腐蚀隔膜泵-耐腐蚀隔膜真空泵-杭州景程仪器 电杆荷载挠度测试仪-电杆荷载位移-管桩测试仪-北京绿野创能机电设备有限公司 | 间甲酚,间甲酚厂家-山东祥东新材料| 废水处理-废气处理-工业废水处理-工业废气处理工程-深圳丰绿环保废气处理公司 | 货车视频监控,油管家,货车油管家-淄博世纪锐行电子科技 | 南京办公用品网-办公文具用品批发-打印机耗材采购 | 高低温万能试验机-复合材料万能试验机-馥勒仪器 |