X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 1D47ED1B543 for ; Sun, 26 Oct 2003 20:02:29 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 88216-10 for ; Sun, 26 Oct 2003 16:01:58 -0400 (AST) Received: from dogbert.ozaba.cx (as14-2-3.ars.s.bonet.se [217.215.218.89]) by svr1.postgresql.org (Postfix) with ESMTP id 78E65D1B50F for ; Sun, 26 Oct 2003 16:01:56 -0400 (AST) Received: from ratbert.ozaba.cx (ratbert.ozaba.cx [192.168.8.100]) by dogbert.ozaba.cx (8.12.10/8.12.10) with ESMTP id h9QK1i61010654 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sun, 26 Oct 2003 21:01:44 +0100 Message-ID: X-Mailer: http://www.courier-mta.org/cone/ From: sarek@ozaba.cx To: pgsql-sql@postgresql.org X-Accept-Language: Swedish, English X-Location: Stockholm, Sweden X-PGP-Key: http://www.ozaba.cx/files/sarek_gpg.asc X-URL: http://www.ozaba.cx Subject: index and min() Date: Sun, 26 Oct 2003 21:01:42 +0100 Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset="US-ASCII" Content-Disposition: inline Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/335 X-Sequence-Number: 15735 Hello, I have a table that contains logs from a radius accounting server. Currently the table contains 1,780,470 rows and is about 350Mb on the disk. It is running on a mssql server at the moment but I would like to move it over to a postgresql server and postgresql seems to be somewhat fast than mssql on most things except one. SELECT min(inserttime) FROM acc_pb; which takes about 11 seconds to complete. On the mssql server this takes less than 1 second. On the mssql server the inserttime column has a cluster index which if I understand correctly means that the index is ordered which would explain why the min() and max() functions are fast. Is there an ordered index on postgresql or is the problem something else? I have a b-tree index on the inserttime column in postgresql but it isn't used somehow. test=# EXPLAIN ANALYZE SELECT min(inserttime) from accounting; QUERY PLAN ---------------------------------------------------------------------------- Aggregate (cost=55162.88..55162.88 rows=1 width=8) (actual time=11798.27..11798.27 rows=1 loops=1) -> Seq Scan on accounting (cost=0.00..50711.70 rows=1780470 width=8) (actual time=0.14..8703.67 rows=1780470 loops=1) Total runtime: 11798.39 msec (3 rows) Time: 11799.69 ms Any help is greatly appreciated. Best Regards Magnus