pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Thomas Zaksek <zaksek@ptt.uni-due.de>
To: pgsql-performance@postgresql.org
Subject: Re: Join Query Perfomance Issue
Date: Wed, 13 Feb 2008 12:45:04 +0100
Message-ID: <47B2D840.6060802@ptt.uni-due.de> (raw)
In-Reply-To: <4544e0330802121234l33be13a9g5dec39ef032f6268@mail.gmail.com>
References: <47B08F19.8000500@ptt.uni-due.de>
	<4544e0330802121234l33be13a9g5dec39ef032f6268@mail.gmail.com>

We have tried some recoding now, using a materialized view we could 
reduce the query to a join over too tables without any functions inside 
the query, for example:

explain analyse SELECT '12.11.2007 18:04:00 UTC' AS zeit,
                       'M' AS ganglinientyp,
                       zs_de,
                   j_ges,
                       j_lkw,
                       v_pkw,
                       v_lkw,
                   p_bel
                   FROM  messungen_v_dat_2007_11_12 m
                       LEFT JOIN messwerte_mv w on w.nr = m.messpunkt
                       WHERE  m.ganglinientyp = 'M'   
               AND 992 = m.minute_tag;

Nested Loop Left Join  (cost=0.00..32604.48 rows=3204 width=14) (actual 
time=11.991..2223.227 rows=2950 loops=1)
   ->  Index Scan using 
messungen_v_dat_2007_11_12_messpunkt_minute_tag_idx on 
messungen_v_dat_2007_11_12 m  (cost=0.00..5371.09 rows=3204 width=4) 
(actual time=0.152..12.385 rows=2950 loops=1)
         Index Cond: ((ganglinientyp = 'M'::bpchar) AND (992 = minute_tag))
   ->  Index Scan using messwerte_mv_nr_idx on messwerte_mv w  
(cost=0.00..8.49 rows=1 width=18) (actual time=0.730..0.734 rows=1 
loops=2950)
         Index Cond: (w.nr = m.messpunkt)
 Total runtime: 2234.143 ms
(6 rows)

To me this plan looks very clean and nearly optimal, BUT ~2seconds for 
the nested loop can't be that good, isn't it?
The behavior of this query and the database is quite a mystery for me, 
yesterday i had it running in about 100ms, today i started testing with 
the same query and 2000-3000ms :(

Could this be some kind of a postgresql server/configuration problem? 
This queries are very perfomance dependend, they are called a lot of 
times in a comlex physical real time simulation of traffic systems. 
200ms would be ok here, but >1sec is perhaps not functional.

The old version just used one big (partitioned) table without any joins, 
performing this query in 10-300ms, depended on the server load.



view thread (12+ messages)  latest in thread

Message-ID: <47B2D840.6060802@ptt.uni-due.de>
Permalink:  ../47B2D840.6060802@ptt.uni-due.de/
Also on:    postgresql.org/message-id/47B2D840.6060802@ptt.uni-due.de

 · 

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: zaksek@ptt.uni-due.de
  Subject: Re: Join Query Perfomance Issue
  In-Reply-To: <47B2D840.6060802@ptt.uni-due.de>

* 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