[PERFORM] index on two tables or Howto speedup max/aggregate-function

2009-10-13 Thread Michael Schwipps
Hi, I want to select the last contact of person via mail. My sample database is build with the following shell-commands | createdb -U postgres test2 | psql -U postgres test2 < mail_db.sql | mailtest.sh | psql -U postgres I call to get the answer | SELECT address, max(sent) from mail inner join

Re: [PERFORM] index on two tables or Howto speedup max/aggregate-function

2009-10-13 Thread Grzegorz Jaƛkiewicz
On Tue, Oct 13, 2009 at 9:59 AM, Michael Schwipps wrote: > Hi, > > I want to select the last contact of person via mail. > My sample database is build with the following shell-commands > > | createdb -U postgres test2 > | psql -U postgres test2 < mail_db.sql > | mailtest.sh | psql -U postgres > >

Re: [PERFORM] index on two tables or Howto speedup max/aggregate-function

2009-10-13 Thread Jacques Caron
Hi, CREATE INDEX mail_id_sent_idx ON mail(id,sent) should do the trick? Of course you can only replace one of the two scans by an index scan since there are no other conditions... Jacques. At 09:59 13/10/2009, Michael Schwipps wrote: Hi, I want to select the last contact of person via mail