pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Steve <cheetah@tanabi.org>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: PostgreSQL Performance <pgsql-performance@postgresql.org>
Subject: Re: Strangely Variable Query Performance
Date: Thu, 12 Apr 2007 18:03:47 -0400 (EDT)
Message-ID: <Pine.GSO.4.64.0704121757060.17955@kittyhawk.tanabi.org> (raw)
In-Reply-To: <9213.1176415301@sss.pgh.pa.us>
References: <57271CC2-BCB1-4ACA-A177-4FF64F1BC33F@brandeis.edu>
	<E1HbzJr-0005VG-GC@elasmtp-curtail.atl.sa.earthlink.net>
	<16E9A17C-ADFA-43B2-B7EA-5C7A4D7E96D1@event-s.net>
	<E1Hc0lc-0001iE-La@elasmtp-banded.atl.sa.earthlink.net>
	<0914C05F-BA1B-4A6C-A1B1-52256BC851A4@event-s.net>
	<1176396964.13754.16.camel@state.g2switchworks.com>
	<Pine.LNX.4.64.0704121000570.32187@glacier.frostconsultingllc.com>
	<Pine.GSO.4.64.0704121653030.17955@kittyhawk.tanabi.org>
	<5772.1176413092@sss.pgh.pa.us>
	<Pine.GSO.4.64.0704121735000.17955@kittyhawk.tanabi.org>
	<9213.1176415301@sss.pgh.pa.us>

>
> Oy vey ... I hope this is a read-mostly table, because having that many
> indexes has got to be killing your insert/update performance.

 	Hahaha yeah these are read-only tables.  Nightly inserts/updates. 
Takes a few hours, depending on how many records (between 4 and 10 
usually).  But during the day, while querying, read only.

> I see that some of the revop indexes might be considered relevant to
> this query, so how exactly have you got those opclasses defined?
> There's built-in support for reverse sort as of CVS HEAD, but in
> existing releases you must have cobbled something together, and I wonder
> if that could be a contributing factor ...

Here's the revops (the c functions are at the bottom):

CREATE FUNCTION ddd_date_revcmp(date, date) RETURNS integer
     AS '/usr/local/pgsql/contrib/cmplib.so', 'ddd_date_revcmp'
     LANGUAGE c STRICT;

CREATE FUNCTION ddd_int_revcmp(integer, integer) RETURNS integer
     AS '/usr/local/pgsql/contrib/cmplib.so', 'ddd_int_revcmp'
     LANGUAGE c STRICT;

CREATE FUNCTION ddd_text_revcmp(text, text) RETURNS integer
     AS '/usr/local/pgsql/contrib/cmplib.so', 'ddd_text_revcmp'
     LANGUAGE c STRICT;

CREATE OPERATOR CLASS date_revop
     FOR TYPE date USING btree AS
     OPERATOR 1 >(date,date) ,
     OPERATOR 2 >=(date,date) ,
     OPERATOR 3 =(date,date) ,
     OPERATOR 4 <=(date,date) ,
     OPERATOR 5 <(date,date) ,
     FUNCTION 1 ddd_date_revcmp(date,date);

CREATE OPERATOR CLASS int4_revop
     FOR TYPE integer USING btree AS
     OPERATOR 1 >(integer,integer) ,
     OPERATOR 2 >=(integer,integer) ,
     OPERATOR 3 =(integer,integer) ,
     OPERATOR 4 <=(integer,integer) ,
     OPERATOR 5 <(integer,integer) ,
     FUNCTION 1 ddd_int_revcmp(integer,integer);

CREATE OPERATOR CLASS text_revop
     FOR TYPE text USING btree AS
     OPERATOR 1 >(text,text) ,
     OPERATOR 2 >=(text,text) ,
     OPERATOR 3 =(text,text) ,
     OPERATOR 4 <=(text,text) ,
     OPERATOR 5 <(text,text) ,
     FUNCTION 1 ddd_text_revcmp(text,text);

Datum   ddd_date_revcmp(PG_FUNCTION_ARGS){
         DateADT         arg1=PG_GETARG_DATEADT(0);
         DateADT         arg2=PG_GETARG_DATEADT(1);

         PG_RETURN_INT32(arg2 - arg1);
}


Datum   ddd_int_revcmp(PG_FUNCTION_ARGS){
         int32           arg1=PG_GETARG_INT32(0);
         int32           arg2=PG_GETARG_INT32(1);

         PG_RETURN_INT32(arg2 - arg1);
}

Datum   ddd_text_revcmp(PG_FUNCTION_ARGS){
         char*           arg1=(char*)VARDATA(PG_GETARG_TEXT_P(0));
         char*           arg2=(char*)VARDATA(PG_GETARG_TEXT_P(1));

         if((*arg1) != (*arg2)){
                 PG_RETURN_INT32(*arg2 - *arg1);
         }else{
                 PG_RETURN_INT32(strcmp(arg2,arg1));
         }
}





view thread (29+ messages)  latest in thread

Message-ID: <Pine.GSO.4.64.0704121757060.17955@kittyhawk.tanabi.org>
Permalink:  ../Pine.GSO.4.64.0704121757060.17955@kittyhawk.tanabi.org/
Also on:    postgresql.org/message-id/Pine.GSO.4.64.0704121757060.17955@kittyhawk.tanabi.org

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-performance@postgresql.org
  Cc: cheetah@tanabi.org, tgl@sss.pgh.pa.us
  Subject: Re: Strangely Variable Query Performance
  In-Reply-To: <Pine.GSO.4.64.0704121757060.17955@kittyhawk.tanabi.org>
  References: <57271CC2-BCB1-4ACA-A177-4FF64F1BC33F@brandeis.edu> <E1HbzJr-0005VG-GC@elasmtp-curtail.atl.sa.earthlink.net> <16E9A17C-ADFA-43B2-B7EA-5C7A4D7E96D1@event-s.net> <E1Hc0lc-0001iE-La@elasmtp-banded.atl.sa.earthlink.net> <0914C05F-BA1B-4A6C-A1B1-52256BC851A4@event-s.net> <1176396964.13754.16.camel@state.g2switchworks.com> <Pine.LNX.4.64.0704121000570.32187@glacier.frostconsultingllc.com> <Pine.GSO.4.64.0704121653030.17955@kittyhawk.tanabi.org> <5772.1176413092@sss.pgh.pa.us> <Pine.GSO.4.64.0704121735000.17955@kittyhawk.tanabi.org> <9213.1176415301@sss.pgh.pa.us> <Pine.GSO.4.64.0704121757060.17955@kittyhawk.tanabi.org>

* 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