Re: Strangely Variable Query Performance - Mailing list pgsql-performance

From Tom Lane
Subject Re: Strangely Variable Query Performance
Date
Msg-id 9457.1176416569@sss.pgh.pa.us
Whole thread Raw
In response to Re: Strangely Variable Query Performance  (Steve <cheetah@tanabi.org>)
Responses Re: Strangely Variable Query Performance
List pgsql-performance
Steve <cheetah@tanabi.org> 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

pgsql-performance by date:

Previous
From: Guido Neitzer
Date:
Subject: Re: Slow Postgresql server
Next
From: Steve
Date:
Subject: Re: Strangely Variable Query Performance