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

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

    <tfoot id='qDZrG'></tfoot>
    <legend id='qDZrG'><style id='qDZrG'><dir id='qDZrG'><q id='qDZrG'></q></dir></style></legend>

      <i id='qDZrG'><tr id='qDZrG'><dt id='qDZrG'><q id='qDZrG'><span id='qDZrG'><b id='qDZrG'><form id='qDZrG'><ins id='qDZrG'></ins><ul id='qDZrG'></ul><sub id='qDZrG'></sub></form><legend id='qDZrG'></legend><bdo id='qDZrG'><pre id='qDZrG'><center id='qDZrG'></center></pre></bdo></b><th id='qDZrG'></th></span></q></dt></tr></i><div class="jmhl7mo" id='qDZrG'><tfoot id='qDZrG'></tfoot><dl id='qDZrG'><fieldset id='qDZrG'></fieldset></dl></div>
      • <bdo id='qDZrG'></bdo><ul id='qDZrG'></ul>
      1. Spark SQL/Hive 查詢永遠(yuǎn)需要加入

        Spark SQL/Hive Query Takes Forever With Join(Spark SQL/Hive 查詢永遠(yuǎn)需要加入)

          <tfoot id='JwRW7'></tfoot>
          <i id='JwRW7'><tr id='JwRW7'><dt id='JwRW7'><q id='JwRW7'><span id='JwRW7'><b id='JwRW7'><form id='JwRW7'><ins id='JwRW7'></ins><ul id='JwRW7'></ul><sub id='JwRW7'></sub></form><legend id='JwRW7'></legend><bdo id='JwRW7'><pre id='JwRW7'><center id='JwRW7'></center></pre></bdo></b><th id='JwRW7'></th></span></q></dt></tr></i><div class="sg8pigi" id='JwRW7'><tfoot id='JwRW7'></tfoot><dl id='JwRW7'><fieldset id='JwRW7'></fieldset></dl></div>
          • <bdo id='JwRW7'></bdo><ul id='JwRW7'></ul>

              <legend id='JwRW7'><style id='JwRW7'><dir id='JwRW7'><q id='JwRW7'></q></dir></style></legend>
                <tbody id='JwRW7'></tbody>
            1. <small id='JwRW7'></small><noframes id='JwRW7'>

                • 本文介紹了Spark SQL/Hive 查詢永遠(yuǎn)需要加入的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  所以我正在做一些應(yīng)該很簡(jiǎn)單的事情,但顯然它不在 Spark SQL 中.

                  So I'm doing something that should be simple, but apparently it's not in Spark SQL.

                  如果我在 MySQL 中運(yùn)行以下查詢,查詢會(huì)在幾分之一秒內(nèi)完成:

                  If I run the following query in MySQL, the query finishes in a fraction of a second:

                  SELECT ua.address_id
                  FROM user u
                  inner join user_address ua on ua.address_id = u.user_address_id
                  WHERE u.user_id = 123;
                  

                  但是,在 Spark (1.5.1) 下的 HiveContext 中運(yùn)行相同的查詢需要超過 13 秒.添加更多連接會(huì)使查詢運(yùn)行很長(zhǎng)時(shí)間(超過 10 分鐘).我不確定我在這里做錯(cuò)了什么以及如何加快速度.

                  However, running the same query in HiveContext under Spark (1.5.1) takes more than 13 seconds. Adding more joins makes the query run for a very very long time (over 10 minutes). I'm not sure what I'm doing wrong here and how I can speed things up.

                  這些表是 MySQL 表,它們作為臨時(shí)表加載到 Hive 上下文中.它在單個(gè)實(shí)例中運(yùn)行,數(shù)據(jù)庫(kù)在遠(yuǎn)程機(jī)器上.

                  The tables are MySQL tables that are loaded into the Hive Context as temporary tables.This is running in a single instance, with the database on a remote machine.

                  • 用戶表大約有 480 萬(wàn)行.
                  • user_address 表有 350,000 行.

                  表有外鍵字段,但在數(shù)據(jù)庫(kù)中沒有定義明確的 fk 關(guān)系.我正在使用 InnoDB.

                  The tables have foreign key fields, but no explicit fk relationships is defined in the db. I'm using InnoDB.

                  Spark 中的執(zhí)行計(jì)劃:

                  The execution plan in Spark:

                  計(jì)劃:

                  掃描JDBCRelation(jdbc:mysql://.user,[Lorg.apache.spark.Partition;@596f5dfc,{user=, password=, url=jdbc:mysql://, dbtable=user})[address_id#0L,user_address_id#27L]

                  Scan JDBCRelation(jdbc:mysql://.user,[Lorg.apache.spark.Partition;@596f5dfc, {user=, password=, url=jdbc:mysql://, dbtable=user}) [address_id#0L,user_address_id#27L]

                  過濾器 (user_id#0L = 123) 掃描JDBCRelation(jdbc:mysql://.user_address,[Lorg.apache.spark.Partition;@2ce558f3,{user=, password=,url=jdbc:mysql://, dbtable=user_address})[address_id#52L]

                  Filter (user_id#0L = 123) Scan JDBCRelation(jdbc:mysql://.user_address, [Lorg.apache.spark.Partition;@2ce558f3,{user=, password=, url=jdbc:mysql://, dbtable=user_address})[address_id#52L]

                  ConvertToUnsafe ConvertToUnsafe

                  ConvertToUnsafe ConvertToUnsafe

                  TungstenExchange hashpartitioning(address_id#52L) TungstenExchangehashpartitioning(user_address_id#27L) TungstenSort [address_id#52LASC], false, 0 TungstenSort [user_address_id#27L ASC], false, 0

                  TungstenExchange hashpartitioning(address_id#52L) TungstenExchange hashpartitioning(user_address_id#27L) TungstenSort [address_id#52L ASC], false, 0 TungstenSort [user_address_id#27L ASC], false, 0

                  SortMergeJoin [user_address_id#27L], [address_id#52L]

                  SortMergeJoin [user_address_id#27L], [address_id#52L]

                  == 物理計(jì)劃 == TungstenProject [address_id#0L]

                  == Physical Plan == TungstenProject [address_id#0L]

                  推薦答案

                  首先,您執(zhí)行的查詢類型極其低效.至于現(xiàn)在(Spark 1.5.0*)要執(zhí)行這樣的連接,每次執(zhí)行查詢時(shí)都必須對(duì)兩個(gè)表進(jìn)行混洗/散列分區(qū).對(duì)于 users 表,其中 user_id = 123 謂詞最有可能被下推,但仍然需要對(duì) user_address.

                  First of all type of query you perform is extremely inefficient. As for now (Spark 1.5.0*) to perform join like this, both tables has to be shuffled / hash-partitioned each time query is executed. It shouldn't be a problem in case of users table where user_id = 123 predicate is most likely pushed-down but still requires full shuffle on user_address.

                  此外,如果表只注冊(cè)而不緩存,那么每次執(zhí)行此查詢都會(huì)從 MySQL 獲取整個(gè) user_address 表到 Spark.

                  Moreover, if tables are only registered and not cached, then every execution of this query will fetch a whole user_address table from MySQL to Spark.

                  我不確定我在這里做錯(cuò)了什么以及如何加快速度.

                  I'm not sure what I'm doing wrong here and how I can speed things up.

                  不清楚為什么要將 Spark 用于應(yīng)用程序,但單機(jī)設(shè)置、小數(shù)據(jù)和查詢類型表明 Spark 不適合這里.

                  It is not exactly clear why you want to use Spark for application but single machine setup, small data and type of queries suggest that Spark is not a good fit here.

                  一般來說,如果應(yīng)用程序邏輯需要單條記錄訪問,那么 Spark SQL 的性能就不會(huì)很好.它專為分析查詢而設(shè)計(jì),而不是作為 OLTP 數(shù)據(jù)庫(kù)的替代品.

                  Generally speaking if application logic requires a single record access then Spark SQL won't perform well. It is designed for analytical queries not as a OLTP database replacement.

                  如果單個(gè)表/數(shù)據(jù)框小得多,您可以嘗試廣播.

                  If a single table / data frame is much smaller you could try broadcasting.

                  import org.apache.spark.sql.DataFrame
                  import org.apache.spark.sql.functions.broadcast
                  
                  val user: DataFrame = ???
                  val user_address: DataFrame = ???
                  
                  val userFiltered = user.where(???)
                  
                  user_addresses.join(
                    broadcast(userFiltered), $"address_id" === $"user_address_id")
                  

                  <小時(shí)>

                  * 這應(yīng)該在 Spark 1.6.0 中改變,SPARK-11410應(yīng)該啟用持久表分區(qū).

                  這篇關(guān)于Spark SQL/Hive 查詢永遠(yuǎn)需要加入的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  How to use windowing functions efficiently to decide next N number of rows based on N number of previous values(如何有效地使用窗口函數(shù)根據(jù) N 個(gè)先前值來決定接下來的 N 個(gè)行)
                  reuse the result of a select expression in the quot;GROUP BYquot; clause?(在“GROUP BY中重用選擇表達(dá)式的結(jié)果;條款?)
                  Does ignore option of Pyspark DataFrameWriter jdbc function ignore entire transaction or just offending rows?(Pyspark DataFrameWriter jdbc 函數(shù)的 ignore 選項(xiàng)是忽略整個(gè)事務(wù)還是只是有問題的行?) - IT屋-程序員軟件開發(fā)技
                  Error while using INSERT INTO table ON DUPLICATE KEY, using a for loop array(使用 INSERT INTO table ON DUPLICATE KEY 時(shí)出錯(cuò),使用 for 循環(huán)數(shù)組)
                  pyspark mysql jdbc load An error occurred while calling o23.load No suitable driver(pyspark mysql jdbc load 調(diào)用 o23.load 時(shí)發(fā)生錯(cuò)誤 沒有合適的驅(qū)動(dòng)程序)
                  How to integrate Apache Spark with MySQL for reading database tables as a spark dataframe?(如何將 Apache Spark 與 MySQL 集成以將數(shù)據(jù)庫(kù)表作為 Spark 數(shù)據(jù)幀讀取?)
                    <tfoot id='RnxHT'></tfoot>
                    • <bdo id='RnxHT'></bdo><ul id='RnxHT'></ul>

                        <legend id='RnxHT'><style id='RnxHT'><dir id='RnxHT'><q id='RnxHT'></q></dir></style></legend>

                          <tbody id='RnxHT'></tbody>

                            <i id='RnxHT'><tr id='RnxHT'><dt id='RnxHT'><q id='RnxHT'><span id='RnxHT'><b id='RnxHT'><form id='RnxHT'><ins id='RnxHT'></ins><ul id='RnxHT'></ul><sub id='RnxHT'></sub></form><legend id='RnxHT'></legend><bdo id='RnxHT'><pre id='RnxHT'><center id='RnxHT'></center></pre></bdo></b><th id='RnxHT'></th></span></q></dt></tr></i><div class="7fehr7i" id='RnxHT'><tfoot id='RnxHT'></tfoot><dl id='RnxHT'><fieldset id='RnxHT'></fieldset></dl></div>

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

                          • 主站蜘蛛池模板: 环氧铁红防锈漆_环氧漆_无溶剂环氧涂料_环氧防腐漆-华川涂料 | 耐酸碱泵-自吸耐酸碱泵型号「品牌厂家」立式耐酸碱泵价格-昆山国宝过滤机有限公司首页 | COD分析仪|氨氮分析仪|总磷分析仪|总氮分析仪-圣湖Greatlake | 睿婕轻钢别墅_钢结构别墅_厂家设计施工报价 | 江苏齐宝进出口贸易有限公司| 多米诺-多米诺世界纪录团队-多米诺世界-多米诺团队培训-多米诺公关活动-多米诺创意广告-多米诺大型表演-多米诺专业赛事 | CE认证_产品欧盟ROHS-REACH检测机构-商通检测 | 香蕉筛|直线|等厚|弧形|振动筛|香蕉筛厂家-洛阳隆中重工 | 盘扣式脚手架-附着式升降脚手架-移动脚手架,专ye承包服务商 - 苏州安踏脚手架工程有限公司 | hdpe土工膜-防渗膜-复合土工膜-长丝土工布价格-厂家直销「恒阳新材料」-山东恒阳新材料有限公司 ETFE膜结构_PTFE膜结构_空间钢结构_膜结构_张拉膜_浙江萬豪空间结构集团有限公司 | 衬塑管道_衬四氟管道厂家-淄博恒固化工设备有限公司 | 翻斗式矿车|固定式矿车|曲轨侧卸式矿车|梭式矿车|矿车配件-山东卓力矿车生产厂家 | 电子天平-华志电子天平厂家 | X光检测仪_食品金属异物检测机_X射线检测设备_微现检测 | OLChemim试剂-ABsciex耗材-广州市自力色谱科仪有限公司 | MTK核心板|MTK开发板|MTK模块|4G核心板|4G模块|5G核心板|5G模块|安卓核心板|安卓模块|高通核心板-深圳市新移科技有限公司 | 南京欧陆电气股份有限公司-风力发电机官网 | 英国雷迪地下管线探测仪-雷迪RD8100管线仪-多功能数字听漏仪-北京迪瑞进创科技有限公司 | 千斤顶,液压千斤顶-力良企业,专业的液压千斤顶制造商,shliliang.com | 高柔性拖链电缆_卷筒电缆_耐磨耐折聚氨酯电缆-玖泰特种电缆 | 医用空气消毒机-医用管路消毒机-工作服消毒柜-成都三康王 | 橡胶粉碎机_橡胶磨粉机_轮胎粉碎机_轮胎磨粉机-河南鼎聚重工机械制造有限公司 | ERP企业管理系统永久免费版_在线ERP系统_OA办公_云版软件官网 | 紫外线老化试验箱_uv紫外线老化试验箱价格|型号|厂家-正航仪器设备 | 空调风机,低噪声离心式通风机,不锈钢防爆风机,前倾皮带传动风机,后倾空调风机-山东捷风风机有限公司 | 超细|超微气流粉碎机|气流磨|气流分级机|粉体改性机|磨粉机|粉碎设备-山东埃尔派粉体科技 | 微波消解仪器_智能微波消解仪报价_高压微波消解仪厂家_那艾 | 球盟会·(中国)官方网站 | 隔离变压器-伺服变压器--输入输出电抗器-深圳市德而沃电气有限公司 | 渣土车电机,太阳能跟踪器电机,蜗轮蜗杆减速电机厂家-淄博传强电机 | 电动高压冲洗车_价格-江苏速利达机车有限公司 | 车件|铜件|车削件|车床加工|五金冲压件-PIN针,精密车件定制专业厂商【东莞品晔】 | 防火门-专业生产甲级不锈钢钢质防火门厂家资质齐全-广东恒磊安防设备有限公司 | 哈尔滨治「失眠/抑郁/焦虑症/精神心理」专科医院排行榜-京科脑康免费咨询 一对一诊疗 | 不锈钢酒柜|恒温酒柜|酒柜定制|酒窖定制-上海啸瑞实业有限公司 | 优考试_免费在线考试系统_培训考试系统_题库系统_组卷答题系统_匡优考试 | 浴室柜-浴室镜厂家-YINAISI · 意大利设计师品牌 | 咿耐斯 |-浙江台州市丰源卫浴有限公司 | 电竞学校_电子竞技培训学校学院-梦竞未来电竞学校官网 | 潜水搅拌机-双曲面搅拌机-潜水推进器|奥伯尔环保 | 电机修理_二手电机专家-河北豫通机电设备有限公司(原石家庄冀华高压电机维修中心) | 网站优化公司_北京网站优化_抖音短视频代运营_抖音关键词seo优化排名-通则达网络 |