Re: Performance issue with 8.2.3 - "C" application

From: Tom Lane
Subject: Re: Performance issue with 8.2.3 - "C" application
Date: ,
Msg-id: 29633.1185331558@sss.pgh.pa.us
(view: Whole thread, Raw)
In response to: Performance issue with 8.2.3 - "C" application  (Karl Denninger)
Responses: Re: Performance issue with 8.2.3 - "C" application  (Karl Denninger)
List: pgsql-performance

Tree view

Performance issue with 8.2.3 - "C" application  (Karl Denninger, )
 Re: Performance issue with 8.2.3 - "C" application  (Tom Lane, )
  Re: Performance issue with 8.2.3 - "C" application  (Karl Denninger, )
   Re: Performance issue with 8.2.3 - "C" application  ("Merlin Moncure", )
    Re: Performance issue with 8.2.3 - "C" application  (Karl Denninger, )
     Re: Performance issue with 8.2.3 - "C" application  (Tom Lane, )
      Re: Performance issue with 8.2.3 - "C" application  (Karl Denninger, )
       Re: Performance issue with 8.2.3 - "C" application  (Karl Denninger, )
 Re: Performance issue with 8.2.3 - "C" application  (Nis Jørgensen, )
 Re: Performance issue with 8.2.3 - "C" application  (Gregory Stark, )

Karl Denninger <> writes:
> But.... here's the query that has a habit of taking the most time....

> select forum, * from post where toppost = 1 and (replied > (select
> lastview from forumlog where login='theuser' and forum=post.forum and
> number is null)) is not false AND (replied > (select lastview from
> forumlog where login='theuser' and forum=post.forum and
> number=post.number)) is not f
> alse order by pinned desc, replied desc offset 0 limit 20

Did that ever perform well for you?  It's the sub-selects that are
likely to hurt ... in particular,

>          ->  Index Scan using post_top on post  (cost=0.00..57266.37
> rows=113 width=757)
>                Index Cond: (toppost = 1)
>                Filter: (((replied > (subplan)) IS NOT FALSE) AND
> ((replied > (subplan)) IS NOT FALSE))

versus

>  Index Scan using post_top on post  (cost=0.00..632.03 rows=1013 width=11)
>    Index Cond: (toppost = 1)

The planner thinks that the two subplan filter conditions will eliminate
about 90% of the rows returned by the bare indexscan (IIRC this is
purely a rule of thumb, not based on any statistics) and that testing
them 1013 times will add over 50000 cost units to the basic indexscan.
That part I believe --- correlated subqueries are expensive.

            regards, tom lane


pgsql-performance by date:

From: valgog
Date:
Subject: Re: multicolumn index column order
From: Dave Page
Date:
Subject: Re: Table Statistics with pgAdmin III