Re: [SQL] Grabbing Newest Records From Duplicates

2007-03-16 Thread Tom Lane
"Travis Whitton" <[EMAIL PROTECTED]> writes: > One last question, using the "weather report" example, is it going to > improve performance for the DISTINCT ON query to add an index to the > location and time columns? A two-column index matching the ORDER BY that you use might help, or then again m

Re: [SQL] Grabbing Newest Records From Duplicates

2007-03-16 Thread Travis Whitton
One last question, using the "weather report" example, is it going to improve performance for the DISTINCT ON query to add an index to the location and time columns? Thanks a lot, Travis On 3/16/07, Tom Lane <[EMAIL PROTECTED]> wrote: "Travis Whitton" <[EMAIL PROTECTED]> writes: > Given the fo

Re: [SQL] Grabbing Newest Records From Duplicates

2007-03-16 Thread Tom Lane
"Travis Whitton" <[EMAIL PROTECTED]> writes: > Given the following test table, I want to grab only the newest record and > disregard any older duplicates based on name. Is this the most efficient way > to do it? No, it's gonna be pretty awful. The best way I know of involves DISTINCT ON (see the

[SQL] Grabbing Newest Records From Duplicates

2007-03-16 Thread Travis Whitton
Given the following test table, I want to grab only the newest record and disregard any older duplicates based on name. Is this the most efficient way to do it? Will the indicies even make a difference? The table below demonstrates a simple proof of concept. My final table will have millions of re