Re: Strange issue with GiST index scan taking far too long - Mailing list pgsql-hackers

From Mark Cave-Ayland
Subject Re: Strange issue with GiST index scan taking far too long
Date
Msg-id 484E41EE.1060906@siriusit.co.uk
Whole thread Raw
In response to Re: Strange issue with GiST index scan taking far too long  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Tom Lane wrote:

> Well, yeah, because the first thing it does is pg_detoast_datum.
> Just as a cross-check, try changing it to copy the value without
> forcibly detoasting --- I'll bet it's still slow then.

Yeah, that appears to be exactly the case. After some grepping through 
various header files I came up with this alternative:


PG_FUNCTION_INFO_V1(LWGEOM_mcatest);
Datum LWGEOM_mcatest(PG_FUNCTION_ARGS)
{        struct varlena *pgl = PG_GETARG_RAW_VARLENA_P(0);        void *mem;
        // Copy somewhere else        mem = palloc(VARSIZE_EXTERNAL(pgl));        memcpy(mem, pgl,
VARSIZE_EXTERNAL(pgl));
        PG_RETURN_POINTER(mem);
}


...and of course, this now takes the slower runtime of 2.5s.


ATB,

Mark.

-- 
Mark Cave-Ayland
Sirius Corporation - The Open Source Experts
http://www.siriusit.co.uk
T: +44 870 608 0063


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: a question about exec_simple_query()
Next
From: Zeugswetter Andreas OSB sIT
Date:
Subject: Re: Proposal - improve eqsel estimates by including histogram bucket numdistinct statistics