Re: A way to optimize sql about the last temporary-related row

2024-06-28 Thread agharta agharta
Sorry, my wrong settings on pc mail client. Sorry again. Agharta Il ven 28 giu 2024, 19:51 Richard Welty ha scritto: > not really in direct response to this conversation, but is there any reason > on the face of the planet why read receipts need to be sent to every single > recipient of the mail

Re: A way to optimize sql about the last temporary-related row

2024-06-28 Thread Richard Welty
not really in direct response to this conversation, but is there any reason on the face of the planet why read receipts need to be sent to every single recipient of the mailing list? just saying,   richard On Fri, 28 Jun 2024 03:20:26 -0400 wrote --- HOO-HA! This is HUGE! On

Re: A way to optimize sql about the last temporary-related row

2024-06-28 Thread aghart...@gmail.com
HOO-HA! This is HUGE! Only 2.2 seconds on my data Amazing! distinct on (field) *followed by "*" *is a hidden gem! Thank you so much and thanks to everyone who helped me!  Thank you very much!! Cheers, Agharta Il 27/06/24 6:16 PM, David Rowley ha scritto: On Fri, 28 Jun 2024, 3:20

Re: A way to optimize sql about the last temporary-related row

2024-06-27 Thread David Rowley
On Fri, 28 Jun 2024, 3:20 am aghart...@gmail.com, wrote: > > Now the query: > explain (verbose, buffers, analyze) > with last_table_ids as materialized( >select xx from ( >select LAST_VALUE(pk_id) over (partition by integer_field_2 order by > datetime_field_1 RANGE BETWEEN UNBOUNDED PRECE

Re: A way to optimize sql about the last temporary-related row

2024-06-27 Thread aghart...@gmail.com
Hi, Thanks for you reply. About syntax you're right, but I couldn't think of anything better :(((  I'm here for that too, to solve the problem in a fancy way, with your great support. In practice, I need to get back a dataset with the last association (the most datatime recent record) for a

Re: A way to optimize sql about the last temporary-related row

2024-06-27 Thread Ron Johnson
On Thu, Jun 27, 2024 at 11:33 AM aghart...@gmail.com wrote: > Hi, > > You are right. Too quickly copy-paste on my part :-) > > I take this opportunity to add a NOT insignificant detail. > > Before executing the select query I clear the cache: > > systemctl stop postgresql-16 && sync && echo 3 > /

Re: A way to optimize sql about the last temporary-related row

2024-06-27 Thread David G. Johnston
On Thursday, June 27, 2024, aghart...@gmail.com wrote: > > Now the query: > explain (verbose, buffers, analyze) > with last_table_ids as materialized( > select xx from ( > select LAST_VALUE(pk_id) over (partition by integer_field_2 order by > datetime_field_1 RANGE BETWEEN UNBOUNDED PRECEDING

Re: A way to optimize sql about the last temporary-related row

2024-06-27 Thread aghart...@gmail.com
Hi, You are right. Too quickly copy-paste on my part :-) I take this opportunity to add a NOT insignificant detail. Before executing the select query I clear the cache: systemctl stop postgresql-16 && sync && echo 3 > /proc/sys/vm/drop_caches  &&  systemctl start postgresql-16 I need to get

Re: A way to optimize sql about the last temporary-related row

2024-06-27 Thread Ron Johnson
On Thu, Jun 27, 2024 at 11:20 AM aghart...@gmail.com wrote: [snip] > -- insert 4M records > insert into test_table(pk_id) select generate_series(1,400,1); > > -- now set some random data, distribuited between specific ranges (as in > my production table) > update test_table set > datetime_fie

A way to optimize sql about the last temporary-related row

2024-06-27 Thread aghart...@gmail.com
Hello everyone, Sorry to bother you but I have a query that is driving me crazy. I need to have the last valid record at a temporal level according to a specific parameter. First some data: Linux Rocky 8.10 environment, minimal installation (on VM KVM with Fedora 40). Postgresql 16.3, instal