Re: DELETE with LIMIT (or my first hack)
От | Daniel Loureiro |
---|---|
Тема | Re: DELETE with LIMIT (or my first hack) |
Дата | |
Msg-id | AANLkTim+dhH9FQ4K8KPTUA3YqheC5xs_akvmkko58aAD@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: DELETE with LIMIT (or my first hack) (Jaime Casanova <jaime@2ndquadrant.com>) |
Ответы |
Re: DELETE with LIMIT (or my first hack)
|
Список | pgsql-hackers |
good point. But when you use a LIMIT in a SELECT statement you WANT n RANDOM tuples - its wrong to get RANDOM tuples ? So,in the same logic, its wrong to exclude n random tuples ? Besides, if you want DELETE just 1 tuple, why the executor haveto scan the entire table, and not just stoping after find the 1 tuple ? Why the LIMIT clause should be used to speeduponly SELECT statements ? if the programmer know the expected number of affected rows why not use it to speed up DELETE/UPDATE?<br /><br />cheers,<br />--<br clear="all" />Daniel Loureiro<br /><a href="http://diffcoder.blogspot.com/">http://diffcoder.blogspot.com/</a><br/><br /><div class="gmail_quote">2010/11/30 JaimeCasanova <span dir="ltr"><<a href="mailto:jaime@2ndquadrant.com">jaime@2ndquadrant.com</a>></span><br /><blockquoteclass="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left:1ex;"><div class="im">On Mon, Nov 29, 2010 at 9:08 PM, Daniel Loureiro <<a href="mailto:loureirorg@gmail.com">loureirorg@gmail.com</a>>wrote:<br /> ><br /> > 3) change the executor to stopafter “n” successful iterations. Is<br /> > this correct ?<br /> ><br /><br /></div>no. it means you will deletethe n first tuples that happen to be<br /> found, if you don't have a WHERE clause that means is very possible<br />you delete something you don't want to... the correct solution is to<br /> use always try DELETE's inside transactionsand only if you see the<br /> right thing happening issue a COMMIT<br /><br /> besides i think this has beenproposed and rejected before<br /><font color="#888888"><br /> --<br /> Jaime Casanova <a href="http://www.2ndQuadrant.com"target="_blank">www.2ndQuadrant.com</a><br /> Professional PostgreSQL: Soporte y capacitaciónde PostgreSQL<br /></font></blockquote></div><br />
В списке pgsql-hackers по дате отправления: