<span style="font-family: verdana,sans-serif;">While we could always check for the query performance reasons, I rather
thinkthat this is an overkill for the purpose of mere line numbers.</span><br style="font-family: verdana,sans-serif;"
/><brstyle="font-family: verdana,sans-serif;" /><span style="font-family: verdana,sans-serif;">If such queries don't
changefrequently, you could be better off using a simple function that instead adds a 'rownumber' field to the output
ofthe inner SQL query. The 'rownumber' could instead be calculated by simply incrementing it within a FOR loop for each
row.</span><brstyle="font-family: verdana,sans-serif;" /><br style="font-family: verdana,sans-serif;" /><b
style="font-family:verdana,sans-serif;">Robins</b><br /><br /><div class="gmail_quote">On Wed, May 14, 2008 at 5:24 AM,
Gavin'Beau' Baumanis <<a href="mailto:gavinb@eclinic.com.au" target="_blank">gavinb@eclinic.com.au</a>> wrote:<br
/><blockquoteclass="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex;
padding-left:1ex;">Hi Everyone,<br /><br /> After spending some time searching through our good friend Mr. Google and
themailing list I found a post that provided me with a query that does just what I need.<br /><br /> However, the query
takesFOREVER and although this is stated in the original mail I thought I would ask if there was any advice that you
mightbe able to provide to speed things up a little.<br /><br /> And while the query does return over 27,000 rows in my
case,I didn't expect it to take 9 minutes and 11 seconds!<br /><br /> Please find the query below - and of course -
thanksin advance for any assistance you might be able to provide me with!<br /><br /> select<br /> (select<br />
count(*)<br /> from<br /> myTable as myCount<br /> where<br /> myCount.contactdate <=
myTable.contactdate<br/> ) as rownum,<br /> contactdate<br /> from<br /> myTable<br /> where<br />
contactdate> '2007-06-30 23:59:59'<br /> order by<br /> contactdate;<br /><br /><br /> -Gavin<br /><font
color="#888888"><br/> -- <br /> Sent via pgsql-sql mailing list (<a href="mailto:pgsql-sql@postgresql.org"
target="_blank">pgsql-sql@postgresql.org</a>)<br/> To make changes to your subscription:<br /><a
href="http://www.postgresql.org/mailpref/pgsql-sql"target="_blank">http://www.postgresql.org/mailpref/pgsql-sql</a><br
/></font></blockquote></div><br/>