<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Retrieve a row from indexed spark data frame. in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/retrieve-a-row-from-indexed-spark-data-frame/m-p/20739#M14037</link>
    <description>&lt;P&gt;Hello guys, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm having an issue when trying to get a row values from spark data frame.&lt;/P&gt;&lt;P&gt;I have a DF with index column, and i need to be able to return a row based on index in fastest way possible .&lt;/P&gt;&lt;P&gt;I tried to partitionBy index column,  optimize with zorder on index column but its still take too much time to get a row. ( zorder didnt change a thing in table files)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;to retrieve a row values take 0.5 sec ~ 4 sec&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;some code i tried:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;row = df.where(df.index == x).collect()
--
row = df.where(df.index == x).take(1)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;When using where does spark go on all indexes? or when its found the right one it skip all the rest?&lt;/P&gt;&lt;P&gt;If someone have better so i would like to know.&lt;/P&gt;&lt;P&gt;Thanks for you help ! &lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 12 May 2022 08:30:00 GMT</pubDate>
    <dc:creator>Orianh</dc:creator>
    <dc:date>2022-05-12T08:30:00Z</dc:date>
    <item>
      <title>Retrieve a row from indexed spark data frame.</title>
      <link>https://community.databricks.com/t5/data-engineering/retrieve-a-row-from-indexed-spark-data-frame/m-p/20739#M14037</link>
      <description>&lt;P&gt;Hello guys, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm having an issue when trying to get a row values from spark data frame.&lt;/P&gt;&lt;P&gt;I have a DF with index column, and i need to be able to return a row based on index in fastest way possible .&lt;/P&gt;&lt;P&gt;I tried to partitionBy index column,  optimize with zorder on index column but its still take too much time to get a row. ( zorder didnt change a thing in table files)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;to retrieve a row values take 0.5 sec ~ 4 sec&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;some code i tried:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;row = df.where(df.index == x).collect()
--
row = df.where(df.index == x).take(1)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;When using where does spark go on all indexes? or when its found the right one it skip all the rest?&lt;/P&gt;&lt;P&gt;If someone have better so i would like to know.&lt;/P&gt;&lt;P&gt;Thanks for you help ! &lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2022 08:30:00 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/retrieve-a-row-from-indexed-spark-data-frame/m-p/20739#M14037</guid>
      <dc:creator>Orianh</dc:creator>
      <dc:date>2022-05-12T08:30:00Z</dc:date>
    </item>
  </channel>
</rss>

