Unexplainable slow down... - Mailing list pgsql-general

From Ron Snyder
Subject Unexplainable slow down...
Date
Msg-id F888C30C3021D411B9DA00B0D0209BE8026E2DA2@cvo-exchange.cvo.roguewave.com
Whole thread Raw
Responses Re: Unexplainable slow down...  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
List pgsql-general
We've got this bizarre problem that we're unable to explain and solve, and I
need some pointers.  All pointers to documentation or clues will be
gratefully received.

-ron

Here's the timing information for the query that we first noticed the
problem on:

$ time psql quickview pgsql72  -c "select * from builds where
product='sourcepro_db' and state != 'N' and state != 'W' and finished >=
'03/12/2002' and finished < '03/13/2002' order by
machine,os,compiler,threadlib,debug,exportlevel,stdlibtype,linktype,state,id
,submitted,started,finished,user2,user1;" > test.out

real    1m52.781s
user    0m0.080s
sys     0m0.040s

######We removed the "ORDER BY" stuff, and limited the number of columns we
were interested in, and still see results similar:
$ time psql quickview pgsql72  -c "select finished from builds where
product='sourcepro_db' and state != 'N' and state != 'W' and finished >=
'03/12/2002' and finished < '03/13/2002';" > test.out

real    1m56.346s
user    0m0.010s
sys     0m0.000s

######We played around with LIMIT, and see the following type of thing (Note
the HUGE time increase when going from "limit 14" to "limit 15"):
$ time psql quickview pgsql72  -c "select * from builds where
product='sourcepro_db' and state != 'N' and state != 'W' and finished >=
'03/12/2002' and finished < '03/13/2002' limit 14;" > test.out

real    0m1.884s
user    0m0.000s
sys     0m0.010s
$ ls -al test.out
-rw-r--r--    1 snyder   sysadmin     8831 Mar 13 12:42 test.out
$ time psql quickview pgsql72  -c "select * from builds where
product='sourcepro_db' and state != 'N' and state != 'W' and finished >=
'03/12/2002' and finished < '03/13/2002' limit 15;" > test.out

real    0m48.913s
user    0m0.010s
sys     0m0.000s
$ ls -al test.out
-rw-r--r--    1 snyder   sysadmin     9383 Mar 13 12:43 test.out

Here's an "explain":
# explain select * from builds where product='sourcepro_db' and state != 'N'
and state != 'W' and finished >= '03/12/2002' and finished < '03/13/2002'
limit 15;
NOTICE:  QUERY PLAN:

Limit  (cost=0.00..833.71 rows=15 width=426)
  ->  Seq Scan on builds  (cost=0.00..123873.38 rows=2229 width=426)

EXPLAIN

Here's an explain without a "WHERE" clause, so it looks like the index on :
# explain select * from builds;
NOTICE:  QUERY PLAN:

Seq Scan on builds  (cost=0.00..121841.50 rows=162550 width=426)

EXPLAIN

Here's what the table looks like:

$  psql quickview pgsql72  -c "\d builds"
                     Table "builds"
     Attribute     |           Type           | Modifier
-------------------+--------------------------+----------
 id                | integer                  | not null
 visible           | boolean                  |
 state             | character(1)             |
 evaluated         | boolean                  |
 product           | character varying(30)    |
 compiler          | character varying(30)    |
 os                | character varying(30)    |
 stdlibtype        | character varying(30)    |
 linktype          | character varying(30)    |
 threadlib         | character varying(30)    |
 exportlevel       | character varying(30)    |
 usermode          | character varying(30)    |
 postbuildclean    | character varying(30)    |
 prebuildclean     | character varying(30)    |
 submitted         | timestamp with time zone |
 started           | timestamp with time zone |
 finished          | timestamp with time zone |
 machine           | character varying(100)   |
 errors            | integer                  |
 warnings          | integer                  |
 testsattempted    | integer                  |
 testspassed       | integer                  |
 testsfailed       | integer                  |
 examplesattempted | integer                  |
 examplespassed    | integer                  |
 examplesfailed    | integer                  |
 ping              | timestamp with time zone |
 start_count       | integer                  |
 user1             | character varying(50)    |
 user2             | character varying(50)    |
 user3             | character varying(50)    |
 user4             | character varying(50)    |
 user5             | character varying(50)    |
 user6             | character varying(50)    |
 debug             | character varying(30)    |
Indices: builds_compiler,
         builds_machine,
         builds_os,
         builds_pkey,
         builds_product,
         builds_product_os_compiler,
         builds_product_state_finished,
         builds_product_state_submitted,
         builds_started,
         builds_vis_compiler_fin_state,
         builds_vis_compiler_submitted,
         builds_vis_machine_fin_state,
         builds_vis_machine_submitted,
         builds_vis_os_fin_state,
         builds_vis_os_submitted,
         builds_vis_prod_fin_state,
         builds_visible_product,
         builds_visible_product_submitte


pgsql-general by date:

Previous
From: bombadil@wanadoo.es
Date:
Subject: Re: Referential integrity violation
Next
From: Martijn van Oosterhout
Date:
Subject: Re: Newbie: Copy from and dates