<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
span.EstiloDeEmail17
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 3.0cm 70.85pt 3.0cm;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=PT-BR link="#0563C1" vlink="#954F72" style='word-wrap:break-word'><div class=WordSection1><p class=MsoNormal>Hi,<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><span lang=EN-US>I am trying to update a flag indicating if a point is inside a country. I have a table with 27 states (tb_state) and a partitioned table with points (tb_heat), child tables per year, from tb_heat_2000 to tb_heat_2025.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>The update longs forever, and I have to cancel. I don’t’t know if is a postgresql tune problem, or a SQL problem.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>tb_state has index for column state_area<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>tb_heat and childs have index for columns din_heat, point_heat<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>tb_state - 27 rows<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>tb_heat - From ‘2020-12-09 00:00:00’ to ‘2020-12-10 00:00:00’ (1day) – 4002 rows<o:p></o:p></span></p><p class=MsoNormal style='background:white;text-autospace:none'><span lang=EN-US style='font-family:"Times New Roman",serif;color:black'><br></span><b><span lang=EN-US style='font-family:"Courier New";color:blue'>UPDATE </span></b><span lang=EN-US style='font-family:"Courier New";color:black'>tb_heat </span><b><span lang=EN-US style='font-family:"Courier New";color:blue'>SET </span></b><span lang=EN-US style='font-family:"Courier New";color:black'>flg_insidecountry = ST_CONTAINS(foo.country, tb_heat.point_heat) </span><b><span lang=EN-US style='font-family:"Courier New";color:blue'>FROM </span></b><span lang=EN-US style='font-family:"Courier New";color:black'>(</span><b><span lang=EN-US style='font-family:"Courier New";color:blue'>SELECT </span></b><span lang=EN-US style='font-family:"Courier New";color:black'>ST_UNION(tb_state.area_state) </span><b><span lang=EN-US style='font-family:"Courier New";color:blue'>as </span></b><span lang=EN-US style='font-family:"Courier New";color:black'>country </span><b><span lang=EN-US style='font-family:"Courier New";color:blue'>FROM </span></b><span lang=EN-US style='font-family:"Courier New";color:black'>tb_state) </span><b><span lang=EN-US style='font-family:"Courier New";color:blue'>AS </span></b><span lang=EN-US style='font-family:"Courier New";color:black'>foo <br></span><b><span lang=EN-US style='font-family:"Courier New";color:blue'>WHERE </span></b><span lang=EN-US style='font-family:"Courier New";color:black'>tb_heat.din_heat >= </span><span lang=EN-US style='font-family:"Courier New";color:red'>'2020-12-09 00:00:00' </span><b><span lang=EN-US style='font-family:"Courier New";color:blue'>and </span></b><span lang=EN-US style='font-family:"Courier New";color:black'>tb_heat.din_heat < </span><span lang=EN-US style='font-family:"Courier New";color:red'>'2020-12-10 00:00:00'<br><br><o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:PT-BR'>Regards,<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:PT-BR'><o:p> </o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:PT-BR'>Liglio<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p></div></body></html>