Re: enhance the efficiency of migrating particularly large tables

2024-05-02 Thread David Rowley
On Fri, 3 May 2024 at 09:33, David Zhang wrote: > Is there a simple way to get the min of ctid faster than using min(), but > similar to get the max of ctid using pg_relation_size? The equivalent approximation is always '(0,1)'. David

Re: enhance the efficiency of migrating particularly large tables

2024-05-02 Thread David Zhang
Thanks a lot David Rowley for your suggestion in details. On 2024-04-08 3:23 p.m., David Rowley wrote: On Tue, 9 Apr 2024 at 09:52, David Zhang wrote: Finding the exact ctid seems overkill for what you need. Why you could just find the maximum block with: N = pg_relation_size('name_of_your_ta

Re: enhance the efficiency of migrating particularly large tables

2024-04-08 Thread David Rowley
On Tue, 9 Apr 2024 at 11:02, Tom Lane wrote: > > David Rowley writes: > > Unsure if such a feature is worthwhile. I think maybe not for just > > min(ctid)/max(ctid). However, there could be other reasons, such as > > the transform OR to UNION stuff that Tom worked on a few years ago. > > That nee

Re: enhance the efficiency of migrating particularly large tables

2024-04-08 Thread Tom Lane
David Rowley writes: > Unsure if such a feature is worthwhile. I think maybe not for just > min(ctid)/max(ctid). However, there could be other reasons, such as > the transform OR to UNION stuff that Tom worked on a few years ago. > That needed to eliminate duplicate rows that matched both OR branc

Re: enhance the efficiency of migrating particularly large tables

2024-04-08 Thread David Rowley
On Tue, 9 Apr 2024 at 09:52, David Zhang wrote: > However, when executing SELECT min(ctid) and max(ctid), it performs a > Seq Scan, which can be slow for a large table. Is there a way to > retrieve the minimum and maximum ctid other than using the system > functions min() and max()? Finding the e