Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 6F6C09FB8EB for ; Thu, 12 Apr 2007 19:22:55 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 38847-01 for ; Thu, 12 Apr 2007 19:22:52 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 2366D9FB86F for ; Thu, 12 Apr 2007 19:22:52 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id l3CMMofK009458; Thu, 12 Apr 2007 18:22:50 -0400 (EDT) To: Steve cc: PostgreSQL Performance Subject: Re: Strangely Variable Query Performance In-reply-to: References: <57271CC2-BCB1-4ACA-A177-4FF64F1BC33F@brandeis.edu> <16E9A17C-ADFA-43B2-B7EA-5C7A4D7E96D1@event-s.net> <0914C05F-BA1B-4A6C-A1B1-52256BC851A4@event-s.net> <1176396964.13754.16.camel@state.g2switchworks.com> <5772.1176413092@sss.pgh.pa.us> <9213.1176415301@sss.pgh.pa.us> Comments: In-reply-to Steve message dated "Thu, 12 Apr 2007 18:03:47 -0400" Date: Thu, 12 Apr 2007 18:22:49 -0400 Message-ID: <9457.1176416569@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200704/271 X-Sequence-Number: 24148 Steve writes: > 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)); > } > } [ itch... ] That code is just completely wrong, because the contents of a TEXT datum aren't guaranteed null-terminated. It'd be better to invoke bttextcmp and negate its result. That's not relevant to your immediate problem, but if you've noticed any strange behavior with your text_revop indexes, that's the reason... regards, tom lane