pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: eVl <evl.evl@gmail.com>
To: pgsql-performance@postgresql.org
Subject: optimization downgrade perfomance?
Date: Fri, 23 Sep 2005 01:27:16 +0300
Message-ID: <133614678.20050923012716@gmail.com> (raw)

Hello!

	Got a DB with traffic statictics stored. And a SELECT statement which shows traffic volume per days also divided by regions - local traffic and global.
       Thus SELECT statement returns about some (in about 10-20) rows paired like this:

ttype (text)| volume (int)| tdate (date)
----------------------------------------
local       | xxxxx       | some-date
global      | xxxxx       | some-date

	When executing this SELECT (see SELECT.A above) it executes in about 700 ms, but when I want wipe out all info about local traffic, with query like this:
      SELECT * FROM ( SELECT.A ) a WHERE type = 'global';
It executes about 10000 ms - more then 10 TIMES SLOWER!

 Why this could be?



-------------------------------------------------
Initial Query - SELECT.A (executes about 700 ms)

SELECT 
      CASE is_local(aa.uaix) WHEN true THEN 'local' 
                             ELSE 'global' END AS TType, 
      aa.cDate AS TDate,
      SUM(aa.data) AS Value 
FROM (
      SELECT 
            a.uaix AS uaix, 
            cDate AS cDate, 
            SUM(a.data) AS data 
      FROM (
	     (
             SELECT toIP AS uaix, 
                    cDate AS cDate, 
                    SUM(packetSize) AS data
	      FROM vw_stats
             WHERE interface <> 'inet'
                  AND cdate = '01.09.2005'
                  AND fromIP << '192.168.0.0/16'
                  AND NOT (toIP << '192.168.0.0/16')
             GROUP BY 1,2
	    )
           UNION 
           (
            SELECT fromIP AS uaix, 
                   cDate AS cDate, 
                   SUM(packetSize) AS data
             FROM vw_stats
             WHERE interface <> 'inet'
                   AND cdate = '01.09.2005'
                   AND toIP << '192.168.0.0/16'
                   AND NOT (fromIP << '192.168.0.0/16')
             GROUP BY 1,2
            )
      ) a
      GROUP BY 1,2
) aa
GROUP BY 1,2
ORDER BY 1,2

-----------------------------------------------------------
Query with local info filtered (executes about 10000 ms)

SELECT * FROM (
<HERE PLACED SELECT.A>
) aaa WHERE aaa.TType = 'global';


-----------------------------------------------------------

Running Postgresql 8.0.3 on FreeBSD 5.3

  

-- 
Best regards,
 eVl                          mailto:evl.evl@gmail.com





view thread (3+ messages)  latest in thread

Message-ID: <133614678.20050923012716@gmail.com>
Permalink:  ../133614678.20050923012716@gmail.com/
Also on:    postgresql.org/message-id/133614678.20050923012716@gmail.com

 · 

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: evl.evl@gmail.com
  Subject: Re: optimization downgrade perfomance?
  In-Reply-To: <133614678.20050923012716@gmail.com>

* 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