pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Frederic Jolliton <fred-pg@jolliton.com>
To: pgsql-performance@postgresql.org
Subject: Re: Important speed difference between a query and a
Date: Thu, 24 Apr 2003 18:33:35 +0200
Message-ID: <86bryvsvmo.fsf@mau.localdomain> (raw)
In-Reply-To: <14131.1051199816@sss.pgh.pa.us>
References: <8665p56qx8.fsf@mau.localdomain>
	<86el3rsxqu.fsf@mau.localdomain>
	<14131.1051199816@sss.pgh.pa.us>

> Frederic Jolliton <fred-pg@jolliton.com> writes:
>>> To "emulate" a parametred view, I created a function as follow:
>>> 
>>> CREATE FUNCTION get_info (integer) RETURNS SETOF type_get_info
>>> AS '...' <- here the query show below, where 'LIMIT $1' is used instead of 'LIMIT 10'
>>> LANGUAGE sql;
>
>> So, the query in the function is not using index but the exact same
>> query alone does !

Tom Lane <tgl@sss.pgh.pa.us> writes:
> But it's not the same query, is it?  With "LIMIT $1" the planner can't
> know what the limit value is exactly, so it has to generate a plan that
> won't be too unreasonable for either a small or a large limit.

Ok. So the query is optimized once and not each time.. I understand
now.

But, since I "know" better that PostgreSQL that query must use index
in most of case, can I force in some manner the function when
declaring it to take this in account ? I suppose (not tested) that
setting enable_seqscan just before will probably do it, but what about
dump/restore of the database when recreating the function and keep
this "fix" automatically ?




view thread (10+ messages)  latest in thread

Message-ID: <86bryvsvmo.fsf@mau.localdomain>
Permalink:  ../86bryvsvmo.fsf@mau.localdomain/
Also on:    postgresql.org/message-id/86bryvsvmo.fsf@mau.localdomain

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-performance@postgresql.org
  Cc: fred-pg@jolliton.com
  Subject: Re: Important speed difference between a query and a
  In-Reply-To: <86bryvsvmo.fsf@mau.localdomain>
  References: <8665p56qx8.fsf@mau.localdomain> <86el3rsxqu.fsf@mau.localdomain> <14131.1051199816@sss.pgh.pa.us> <86bryvsvmo.fsf@mau.localdomain>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox