Re: Strange issue with GiST index scan taking far too long

From: Mark Cave-Ayland <mark(dot)cave-ayland(at)siriusit(dot)co(dot)uk>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Strange issue with GiST index scan taking far too long
Date: 2008-06-10 08:57:18
Message-ID: 484E41EE.1060906@siriusit.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Zeugswetter Andreas OSB sIT 2008-06-10 09:01:02 Re: Proposal - improve eqsel estimates by including histogram bucket numdistinct statistics
Previous Message Pavan Deolasee 2008-06-10 05:32:48 VACUUM Improvements - WIP Patch