Re: multiple sql update w/ major time issues
| От | Tom Lane |
|---|---|
| Тема | Re: multiple sql update w/ major time issues |
| Дата | |
| Msg-id | 12898.992370840@sss.pgh.pa.us обсуждение исходный текст |
| Ответ на | multiple sql update w/ major time issues (iu_23@hotmail.com (Dawn)) |
| Список | pgsql-sql |
iu_23@hotmail.com (Dawn) writes:
> I have a sql update statement that is dealing with hundreds of
> thousands of records. It takes hours and hours to complete (if it
> does complete and not take down the server).
No wonder, if you write it like that. You're forcing a fresh select
from gl_totals for each row of aud_member_ext_attributes; then you're
doing it again for each UPDATE command.
If you were using Postgres (which I surmise you are not, because it
doesn't accept aliases in UPDATE) you could do
update aud_member_ext_attributes
setEXTVALUE217 = gl_totals.MTD,EXTVALUE223 = gl_totals.YTD,EXTVALUE229 = gl_totals.R12
where gl_totals.category = 'tankrent' and gl_totals.CUST_NO = EXTVALUE101 and gl_totals.DIST_NO = EXTVALUE102 and
gl_totals.SUB_NO= EXTVALUE105 and gl_totals.FUEL_TYPE = EXTVALUE123;
regards, tom lane
В списке pgsql-sql по дате отправления: