Re: Query much slower when run from postgres function

From: Tom Lane
Subject: Re: Query much slower when run from postgres function
Date: ,
Msg-id: 27649.1236616294@sss.pgh.pa.us
(view: Whole thread, Raw)
In response to: Query much slower when run from postgres function  (Mario Splivalo)
Responses: Re: Query much slower when run from postgres function  (Guillaume Cottenceau)
Re: Query much slower when run from postgres function  (Mario Splivalo)
Re: Query much slower when run from postgres function  ( (Frank Ch. Eigler))
List: pgsql-performance

Tree view

Query much slower when run from postgres function  (Mario Splivalo, )
 Re: Query much slower when run from postgres function  (Tom Lane, )
  Re: Query much slower when run from postgres function  (Guillaume Cottenceau, )
   Re: [JDBC] Query much slower when run from postgres function  (Guillaume Smet, )
    Re: [JDBC] Query much slower when run from postgres function  (Tom Lane, )
     Re: [JDBC] Query much slower when run from postgres function  (Andreas Wenk, )
     Re: [JDBC] Query much slower when run from postgres function  (Dave Cramer, )
      Re: [JDBC] Query much slower when run from postgres function  (James Mansion, )
    Re: [JDBC] Query much slower when run from postgres function  (Scott Carey, )
   Re: Query much slower when run from postgres function  (Mario Splivalo, )
  Re: Query much slower when run from postgres function  (Mario Splivalo, )
   Re: Query much slower when run from postgres function  (Tom Lane, )
    Re: Query much slower when run from postgres function  (Mario Splivalo, )
     Re: Query much slower when run from postgres function  (Tom Lane, )
  Re: Query much slower when run from postgres function  ( (Frank Ch. Eigler), )
   Re: Query much slower when run from postgres function  (Tom Lane, )
    Re: Query much slower when run from postgres function  (decibel, )
     Re: Query much slower when run from postgres function  (Віталій Тимчишин, )
 Re: Query much slower when run from postgres function  (decibel, )

Mario Splivalo <> writes:
> Now I'm confused, why is 'sql' function much slower than 'direct' SELECT?

Usually the reason for this is that the planner chooses a different plan
when it has knowledge of the particular value you are searching for than
when it does not.  I suppose 'service_id' has a very skewed distribution
and you are looking for an uncommon value?

            regards, tom lane


pgsql-performance by date:

From: Mario Splivalo
Date:
Subject: Re: Query much slower when run from postgres function
From: Tom Lane
Date:
Subject: Re: Query much slower when run from postgres function