pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jim C. Nasby <jnasby@pervasive.com>
To: nicky <nicky@valuecare.nl>
Cc: pgsql-performance@postgresql.org
Subject: Re: Speeding up query, Joining 55mil and 43mil records.
Date: Wed, 21 Jun 2006 13:48:03 -0500
Message-ID: <20060621184803.GC93655@pervasive.com> (raw)
In-Reply-To: <44994DE7.5070801@valuecare.nl>
References: <44994DE7.5070801@valuecare.nl>

On Wed, Jun 21, 2006 at 03:47:19PM +0200, nicky wrote:
> WHERE   substr(t0.code,1,2) not in ('14','15','16','17')
> AND     (substr(t0.correctie,4,1) <> '1' OR t0.correctie is null)
> AND     EXTRACT(YEAR from t1.datum) > 2004;

How much data do you expect to be getting back from that where clause?
Unless you plan on inserting most of the table, some well-placed indexes
would probably help, and fixing the datum portion might as well
(depending on how far back the data goes). Specifically:

CREATE INDEX t0_code_partial ON t0(substr(code,1,2));
(yeah, I know t0 is an alias, but I already snipped the table name)

and

AND t1.datum >= '1/1/2005'

(might need to cast that to a date or whatever).
-- 
Jim C. Nasby, Sr. Engineering Consultant      jnasby@pervasive.com
Pervasive Software      http://pervasive.com    work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf       cell: 512-569-9461



view thread (11+ messages)  latest in thread

Message-ID: <20060621184803.GC93655@pervasive.com>
Permalink:  ../20060621184803.GC93655@pervasive.com/
Also on:    postgresql.org/message-id/20060621184803.GC93655@pervasive.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: jnasby@pervasive.com, nicky@valuecare.nl
  Subject: Re: Speeding up query, Joining 55mil and 43mil records.
  In-Reply-To: <20060621184803.GC93655@pervasive.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