Re: SQL Functions and plan time - Mailing list pgsql-general

From Tom Lane
Subject Re: SQL Functions and plan time
Date
Msg-id 24777.1057678414@sss.pgh.pa.us
Whole thread Raw
In response to Re: SQL Functions and plan time  (Richard Huxton <dev@archonet.com>)
Responses Re: SQL Functions and plan time  (Richard Huxton <dev@archonet.com>)
List pgsql-general
Richard Huxton <dev@archonet.com> writes:
> So why am I getting substantially different times for identical queries
> (except for parameter substitution)

> [41] LOG:  query: SELECT zzz2('2003-07-07 17:00:00+01','2003-07-07
> 17:20:00+01');
> [42-1] LOG:  query:
> [42-2] DELETE FROM stats_telcon WHERE st_hour >= $1 AND st_hour < $2;
> ...
> [43] LOG:  duration: 7.524765 sec

> [44] LOG:  query: DELETE FROM stats_telcon WHERE st_hour>='2003-07-07
> 17:00:00+01' AND st_hour<'2003-07-07 17:20:00+01';
> [45] LOG:  duration: 0.032860 sec

They're not the same query from the planner's viewpoint: one has
constants from which it can infer the number of rows to be fetched,
the other has only parameter symbols.

My guess is that the parameterized query is getting stuck with a seqscan
plan, but it's hard to be sure without more data.

            regards, tom lane

pgsql-general by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: Backwards index scan
Next
From: "Maksim Likharev"
Date:
Subject: Re: PG crash on simple query, story continues