1 Nov 2009 01:08
Re: Speed up UPDATE query?
Scott Marlowe <scott.marlowe <at> gmail.com>
2009-11-01 00:08:06 GMT
2009-11-01 00:08:06 GMT
On Thu, Oct 29, 2009 at 11:50 AM, Lee Hachadoorian <lee.hachadoorian <at> gmail.com> wrote: > I'm trying to update several tables (all child tables of the same > parent), and as the number of records increases, the length of time it > takes to run the update is shooting up exponentially. I have imported > the new data to an import table, and then join the import table to the > update table. The update statement looks like: > > UPDATE > household_2000 h > SET > hhincome = new_hhincome > FROM ( > SELECT > serial, new_hhincome > FROM > import > WHERE > year = 2000 > ) r > WHERE > h.serial = r.serial > > household_2000 is a child table of a household table that, as you > might guess, only contains records from the year 2000. I am putting a > year = 2000 restriction on the import table and then linking on the > unique identifier. > > For different child tables, this is how long the update takes to run > (numbers are approximate):(Continue reading)

RSS Feed