RE: Temp tables

From: "2(dot)andriychuk" <2(dot)andriychuk(at)gmail(dot)com>
To: jose fuenmayor <jafn82(at)gmail(dot)com>, pgsql-admin(at)postgresql(dot)org
Subject: RE: Temp tables
Date: 2020-08-15 00:01:01
Message-ID: 5f3725c0.1c69fb81.da202.4a8d@mx.google.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin


Hi Jose,If table2 is really big and you run this update on regular base just make sure you have a covering index on pair x and field2 with field1 in include option, then put both x=z and a.field2=b.field2 to where clause. You don't have to use subquery, just table straight forward, index will do the trick for you.Create index <index name> on table2(x, field2) include(field1);But include is available starting from v11. If version of your PostgreSQL < 11, use with to express your subquery, then use it in join.Best,IgorSent from my Verizon, Samsung Galaxy smartphone
-------- Original message --------From: jose fuenmayor <jafn82(at)gmail(dot)com> Date: 8/14/20 16:27 (GMT-08:00) To: pgsql-admin(at)postgresql(dot)org Subject: Temp tables Hi all , i have a doubt wich query performs betterUpdate table a set field1=b.field 1From (select field1,field2From table2 where x=z) bWhere a.field2=b.field2OrCreate temp table y asselect field1,field2From table2 where x=z;Update table a set field1=b.field1From y as bWhere a.field2=b.field2I ve been told not to use subquerys, but i think this refers toSelect * from table where field1 in (select field1 from table2)Any thoughts?Thanks people y'all

In response to

  • Temp tables at 2020-08-14 23:26:36 from jose fuenmayor

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message jose fuenmayor 2020-08-15 00:09:05 Fwd: Temp tables
Previous Message jose fuenmayor 2020-08-14 23:26:36 Temp tables