A very simple query. PostgreSQL 8.4. I have no idea why the simple query is 7 times faster than the EXPLAIN ANALYZE version. Any ideas? Anyone?
test_counters=# SELECT COUNT(*), xtype FROM test GROUP BY xtype ORDER BY xtype;
count | xtype
---------+-------
669000 | A
84000 | B
63000 | D
15000 | E
159000 | G
7866000 | H
1000000 | N
144000 | NI
(8 rows)
Time: 3366,822 ms
test_counters=# explain analyze SELECT COUNT(*), xtype FROM test GROUP BY xtype ORDER BY xtype;
QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------
Sort (cost=243136.22..243136.24 rows=8 width=2) (actual time=24544.883..24544.889 rows=8 loops=1)
Sort Key: xtype
Sort Method: quicksort Memory: 25kB
-> HashAggregate (cost=243136.00..243136.10 rows=8 width=2) (actual time=24544.838..24544.848 rows=8 loops=1)
-> Seq Scan on test (cost=0.00..193136.00 rows=10000000 width=2) (actual time=0.012..11501.738 rows=10000000 loops=1)
Total runtime: 24544.980 ms
(6 rows)
Edition:
It turned out that there is a problem with the gettimeofday() function as Tom Lane wrote:
You’ve got a machine where gettimeofday() is really slow. This is common on cheap PC hardware
![]()
http://archives.postgresql.org/pgsql-general/2010-03/msg00770.php
And I really have no idea what to do.
Related posts:
- Are SQL Database Joins So Bad? Last time on many forums there were endless discussions about...
- How to Allow For Max 4 Rows in Update (PostgreSQL) The Problem Question found on the net: how to restrict...
- PostgreSQL FOUND Problem FOUND is a global variable that exists in the plpgsql...
- PostgreSQL Collation – part 1 PostgreSQL is (IMHO) much better than MySQL but unfortunately it ...
- Great PostgreSQL Tuning – by Josh Berkus Thanx Josh Bookmark It ...
- How to check PostgreSQL privileges. Someone asked me how to list all tables that a...













0 Responses
Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.