Re: Execution Plan Cost

Lists: pgsql-hackers
From: Luis Vargas <Luis(dot)Vargas(at)cl(dot)cam(dot)ac(dot)uk>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Execution Plan Cost
Date: 2008-05-08 17:11:58
Message-ID: Prayer.1.2.0pre.0805081811580.32631@hermes-1.csi.cam.ac.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

At the backend, I'm measuring the cost of executing (via SPI_execute_plan)
the read-only plan of a simple query with no reference to tables. E.g.
simpleplan(int) AS SELECT $1 > 5

Executing this plan via SPI_execute takes around 70% more time than
directly executing the relevant operator function (int4gt) and using
DatumGetBool. Can anyone give me any insight into what operations account
for the extra execution time?

Thanks,

Luis Vargas


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Luis Vargas <Luis(dot)Vargas(at)cl(dot)cam(dot)ac(dot)uk>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Execution Plan Cost
Date: 2008-05-08 17:19:36
Message-ID: 4197.1210267176@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Luis Vargas <Luis(dot)Vargas(at)cl(dot)cam(dot)ac(dot)uk> writes:
> At the backend, I'm measuring the cost of executing (via SPI_execute_plan)
> the read-only plan of a simple query with no reference to tables. E.g.
> simpleplan(int) AS SELECT $1 > 5

> Executing this plan via SPI_execute takes around 70% more time than
> directly executing the relevant operator function (int4gt) and using
> DatumGetBool.

Only that much? I'd have expected it to be several hundred times
slower, considering that int4gt is an utterly trivial function and
executor startup/shutdown is a fairly heavyweight operation.

regards, tom lane