Re: [SQL] Query with LIMIT clause

2012-09-09 Thread David Johnston
Always reply to list. It is also preferred to bottom-post. Indexes are never simple answers and there isn't enough info to really give good advice here. You should try different versions and estimate performance (read and write). My guess is that a compound index (2 columns) would work well t

Re: [SQL] Query with LIMIT clause

2012-09-09 Thread JORGE MALDONADO
Firstly, who should I reply to, you or the list? Your solution is working pretty fine, I appreciate your advice. Now, I am sure that an index is a good idea in order to make the query fast. What would be a good criteria to define an index? Will an index for final date and another for initial date i

[SQL] returning values from dynamic SQL to a variable

2012-09-09 Thread James Sharrett
I have a PG function ( using plpgsql) that calls a number of sub functions also in plpgsql. I have two main problems that seem to be variations on the same theme of running dynamic SQL from a variable with the EXECUTE statement and returning the results back to a variable defined in the calling fu

Re: [SQL] Query with LIMIT clause

2012-09-09 Thread David Johnston
From: pgsql-sql-ow...@postgresql.org [mailto:pgsql-sql-ow...@postgresql.org] On Behalf Of JORGE MALDONADO Sent: Sunday, September 09, 2012 1:26 PM To: pgsql-sql@postgresql.org Subject: [SQL] Query with LIMIT clause I have the following records that I get from a query, the fields are date type in d

[SQL] Query with LIMIT clause

2012-09-09 Thread JORGE MALDONADO
I have the following records that I get from a query, the fields are date type in day/month/year format: - Initial Final DateDate - 27/08/2012 04/09/2012 29/08/2012 09/09/2012 28/08/2012 09/09/2012