Re: Query timing increased from 3s to 55s when used as a function instead of select
От | A. Kretschmer |
---|---|
Тема | Re: Query timing increased from 3s to 55s when used as a function instead of select |
Дата | |
Msg-id | 20100525103026.GA25341@a-kretschmer.de обсуждение исходный текст |
Ответ на | Query timing increased from 3s to 55s when used as a function instead of select (Tyler Hildebrandt <tyler@campbell-lange.net>) |
Ответы |
Re: Query timing increased from 3s to 55s when used as a
function instead of select
|
Список | pgsql-performance |
In response to Tyler Hildebrandt : > We're using a function that when run as a select statement outside of the > function takes roughly 1.5s to complete whereas running an identical > query within a function is taking around 55s to complete. > > select * from fn_medirota_get_staff_leave_summary(6); > Time: 57375.477 ms I think, your problem is here: SELECT INTO current_user * FROM fn_medirota_validate_rota_master(in_currentuser); The planner has no knowledge about how many rows this functions returns if he don't know the actual parameter. Because of this, this query enforce a seq-scan. Try to rewrite that to something like: execute 'select * from fn_medirota_validate_rota_master(' || in_currentuser' || ')' into current_user *untested* HTH, Andreas -- Andreas Kretschmer Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header) GnuPG: 0x31720C99, 1006 CCB4 A326 1D42 6431 2EB0 389D 1DC2 3172 0C99
В списке pgsql-performance по дате отправления: