Re: [GENERAL] Using ctid in delete statement

2017-02-16 Thread David G. Johnston
On Thu, Feb 16, 2017 at 7:52 AM, pinker wrote: > Adrian Klaver-4 wrote > > https://www.postgresql.org/docs/9.6/static/sql-truncate.html > > > > https://www.postgresql.org/docs/9.6/static/sql-delete.html > > There is nothing about FOR UPDATE clause on those pages... > ​Both truncate and delete ar

Re: [GENERAL] Using ctid in delete statement

2017-02-16 Thread Adrian Klaver
On 02/16/2017 07:42 AM, pinker wrote: Adrian Klaver-4 wrote Exactly, they do not have it whereas: https://www.postgresql.org/docs/9.6/static/sql-select.html#SQL-FOR-UPDATE-SHARE Still not much. The documentation could be more verbose on this topic. I can only presume that since there is an ex

Re: [GENERAL] Using ctid in delete statement

2017-02-16 Thread pinker
Adrian Klaver-4 wrote > Exactly, they do not have it whereas: > > https://www.postgresql.org/docs/9.6/static/sql-select.html#SQL-FOR-UPDATE-SHARE Still not much. The documentation could be more verbose on this topic. I can only presume that since there is an example with select: SELECT * FROM (SE

Re: [GENERAL] Using ctid in delete statement

2017-02-16 Thread Adrian Klaver
On 02/16/2017 06:52 AM, pinker wrote: > Adrian Klaver-4 wrote >> https://www.postgresql.org/docs/9.6/static/sql-truncate.html >> >> https://www.postgresql.org/docs/9.6/static/sql-delete.html > > There is nothing about FOR UPDATE clause on those pages... Exactly, they do not have it whereas: http

Re: [GENERAL] Using ctid in delete statement

2017-02-16 Thread pinker
Adrian Klaver-4 wrote > https://www.postgresql.org/docs/9.6/static/sql-truncate.html > > https://www.postgresql.org/docs/9.6/static/sql-delete.html There is nothing about FOR UPDATE clause on those pages... -- View this message in context: http://postgresql.nabble.com/Using-ctid-in-delete-st

Re: [GENERAL] Using ctid in delete statement

2017-02-16 Thread Adrian Klaver
On 02/16/2017 02:04 AM, pinker wrote: Thank you Tom for clarification. Does it mean that FOR UPDATE clause works with other operations as well? i.e. TRUNCATE, DELETE? https://www.postgresql.org/docs/9.6/static/sql-truncate.html https://www.postgresql.org/docs/9.6/static/sql-delete.html --

Re: [GENERAL] Using ctid in delete statement

2017-02-16 Thread pinker
Thank you Tom for clarification. Does it mean that FOR UPDATE clause works with other operations as well? i.e. TRUNCATE, DELETE? -- View this message in context: http://postgresql.nabble.com/Using-ctid-in-delete-statement-tp5944434p5944658.html Sent from the PostgreSQL - general mailing list ar

Re: [GENERAL] Using ctid in delete statement

2017-02-15 Thread Tom Lane
Vick Khera writes: > On Wed, Feb 15, 2017 at 10:32 AM, pinker wrote: >> DELETE FROM table_name WHERE ctid = any ( array ( select tn.ctid from >> table_name tn JOIN items i on tn.itemid=i.itemid WHERE tn.clock < extract ( >> epoch FROM now() - i.history * interval '10 day')::int + 6 limit 100)); >

Re: [GENERAL] Using ctid in delete statement

2017-02-15 Thread pinker
thank you for the answer -- View this message in context: http://postgresql.nabble.com/Using-ctid-in-delete-statement-tp5944434p591.html Sent from the PostgreSQL - general mailing list archive at Nabble.com. -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make ch

Re: [GENERAL] Using ctid in delete statement

2017-02-15 Thread Vick Khera
On Wed, Feb 15, 2017 at 10:32 AM, pinker wrote: > DELETE FROM table_name WHERE ctid = any ( array ( select tn.ctid from > table_name tn JOIN items i on tn.itemid=i.itemid WHERE tn.clock < extract ( > epoch FROM now() - i.history * interval '10 day')::int + 6 limit 100)); > > Could I be sure that

[GENERAL] Using ctid in delete statement

2017-02-15 Thread pinker
Hi, is it safe to use ctid in following query? : DELETE FROM table_name WHERE ctid = any ( array ( select tn.ctid from table_name tn JOIN items i on tn.itemid=i.itemid WHERE tn.clock < extract ( epoch FROM now() - i.history * interval '10 day')::int + 6 limit 100)); Could I be sure that ctid will