pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: eVl <evl.evl@gmail.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: optimization downgrade perfomance?
Date: Fri, 23 Sep 2005 23:09:09 -0400
Message-ID: <8872.1127531349@sss.pgh.pa.us> (raw)
In-Reply-To: <652316563.20050923212351@gmail.com>
References: <133614678.20050923012716@gmail.com>
	<3192.1127482808@sss.pgh.pa.us>
	<652316563.20050923212351@gmail.com>

eVl <evl.evl@gmail.com> writes:
>> You tell us --- let's see EXPLAIN ANALYZE results for both cases.

> Here EXPLAIN ANALYZE results for both queries attached.

The problem seems to be that the is_uaix() function is really slow
(somewhere around 4 msec per call it looks like).  Look at the
first scan over stats:

  ->  Index Scan using cdate_cluster on stats s  (cost=0.00..201.51 rows=6 width=25) (actual time=5.231..2165.145 rows=418 loops=1)
        Index Cond: (cdate = '2005-09-01'::date)
        Filter: ((fromip << '192.168.0.0/16'::inet) AND (NOT (toip << '192.168.0.0/16'::inet)) AND (CASE is_uaix(toip) WHEN true THEN 'local'::text ELSE 'global'::text END = 'global'::text))

versus

  ->  Index Scan using cdate_cluster on stats s  (cost=0.00..165.94 rows=1186 width=25) (actual time=0.131..43.258 rows=578 loops=1)
        Index Cond: (cdate = '2005-09-01'::date)
        Filter: ((fromip << '192.168.0.0/16'::inet) AND (NOT (toip << '192.168.0.0/16'::inet)))

The 578 evaluations of the CASE are adding over 2100msec.  There's
another 1600 evaluations needed in the other arm of the UNION...

Better look at exactly what is_uaix() is doing, because the CASE structure
is surely not that slow.

			regards, tom lane



view thread (3+ messages)

Message-ID: <8872.1127531349@sss.pgh.pa.us>
Permalink:  ../8872.1127531349@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/8872.1127531349@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: tgl@sss.pgh.pa.us, evl.evl@gmail.com
  Subject: Re: optimization downgrade perfomance?
  In-Reply-To: <8872.1127531349@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox