Re: Sleep functions

Поиск
Список
Период
Сортировка
От Jim C. Nasby
Тема Re: Sleep functions
Дата
Msg-id 20050822214604.GH72767@pervasive.com
обсуждение исходный текст
Ответ на Re: Sleep functions  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On Mon, Aug 22, 2005 at 11:53:22AM -0400, Tom Lane wrote:
> Robert Treat <xzilla@users.sourceforge.net> writes:
> >> On Aug 22, 2005, at 12:40 AM, Michael Fuhr wrote:
> >>> To others who've written their own sleep() function: what are you
> >>> using it for?
> 
> > I know I've used one for a script that reindexes various tables on an
> > old 7.3 server. I put a sleep of 20 seconds between reindexes to let
> > built up transactions have a few moments to catch up, thereby smoothing
> > out i/o. For a long time I used a cpu hogging plpgsql version (since I
> > had cpu to spare) until I switched to a better pltcl version. If a
> > server side one existed I would certainly have used that. 
> 
> Tell you the truth, this "use case" qualifies as a poster child for my
> concern that a server-side sleep would encourage people to write code
> that sits on locks.  If you'd coded some kind of plpgsql loop that did
> a REINDEX, sleep N seconds, another REINDEX, etc, you'd have been
> sitting on the exclusive lock for each table until the end of the whole
> transaction.  Your approach makes lots of sense if you commit each
> REINDEX transaction and sleep *outside* the transaction --- but a server
> sleep function would do exactly not that.

ISTM that when someone thinks they need a sleep in the database they'll
go to the docs to see if such a capability exists. When they find out it
does, hopefully they'll read far enough to see the nice big warning
we'll put in there about it being a foot-gun. Then they'll be better
informed about if they should actually be doing what they're thinking
about doing.

Right now, they see the function is missing and just cobble something
else together, possibly without regard to the side-effects.
-- 
Jim C. Nasby, Sr. Engineering Consultant      jnasby@pervasive.com
Pervasive Software        http://pervasive.com        512-569-9461


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: enable_constraint_exclusion GUC name
Следующее
От: "Joshua D. Drake"
Дата:
Сообщение: Re: beginning hackers